AnshuP
-
Posts
9 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Store
eMastercam Wiki
Blogs
Gallery
Events
Posts posted by AnshuP
-
-
1 hour ago, Roger Martin from CNC Software said:
See the SearchManager.GetGeometry methods in the API
Basically, I am trying to automate the steps I am doing manually as attached in the video.
If I would've got the BasePoint, then it would have been easy for me to MoveToOrigin. But as it doesn't have BasePoint, it is getting difficult for me to get the points.
And I can't even give hardcoded values for Points in MoveToOrigin API, because those points might change for another geometry.
Any help you can do here..?
-
9 minutes ago, Roger Martin from CNC Software said:
See the SearchManager.GetGeometry methods in the API
Looked at all the methods, none of them is giving any reference to points...
Do u see any method which gives me the ref..?
-
1 hour ago, Roger Martin from CNC Software said:
If the geometry in question is a "non-primitive" Solid (i.e. created doing an extrude of some chain), what would be the points on this?
It does not have any defined "base" point. It is a Solid Body with Faces and Edges.
So, when I ask user to select the point on the geometry, for eg :
PointMask endPoint = Mastercam.IO.Types.PointMask.EndPoint;
Point3D p1 = new Point3D ();
bool v = SelectionManager.AskForPoint("Select point", endPoint, ref p1);
I get the values in p1.x, p1.y and p1.z.
Similarly, I want those points without asking USER to select them...that way I am not able to find.
I don't wanna askForPoint, I want to get all the points directly..What would be the way here?
-
On 4/29/2021 at 7:01 PM, AnshuP said:
Thanks Roger, I'll give it a try.!! will get back to you if I face any issue..
Hey Roger,
If let's say that geometry isn't created with any of the given method and as u said Based point will always be 0,0,0 for such geometry.
In that case, how can I get the geometry points?
-
On 4/28/2021 at 2:07 AM, Roger Martin from CNC Software said:
If it is a Simple (primitive) type Solid: Cylinder, Block, Sphere, Cone, or Torus, it will have a BasePoint.
If it was not created using one of the above methods, it does not have a real BasePoint and you'll always get 0,0,0 if you ask for the BasePoint.Create some Solids that are of the "simple" type and some that are not. (e.g. Extruded from a Chain)
This code will report some info about the geometries you select.namespace GetGeometryAddIn { using Mastercam.App.Types; using Mastercam.Database; using Mastercam.IO; using Mastercam.Database.Types; using Mastercam.Solids; using System.Windows.Forms; public class GetGeometry : Mastercam.App.NetHook3App { /// <summary> Displays some type data about the Geometry object. </summary> /// /// <remarks> If we want "type specific details" about it, we need to cast it to its specific type. If you just need /// the Level #, Color#, etc., those are available and the "base" Geometry level. </remarks> /// /// <param name="geometry"> The geometry object to be processed. </param> /// <param name="moveToOrigin"> (Optional) True to move to the origin, only if a "simple" Solid. </param> private void ShowEntityData(Geometry geometry, bool moveToOrigin = false) { if (geometry != null) { var msg = string.Empty; // Cast it to its specific type... if (geometry is Mastercam.BasicGeometry.PointGeometry) { msg = "It is a Point!"; } else if (geometry is Mastercam.Curves.LineGeometry) { msg = "It is a Line!"; } else if (geometry is Mastercam.Curves.ArcGeometry) { msg = "It is an Arc!"; } else if (geometry is SurfaceGeometry) { // Cast it to a SurfaceGeometry type object var surf = (SurfaceGeometry)geometry; var isReversed = surf.IsNormalReversed; // type specific property msg = surf is Mastercam.Surfaces.TrimmedSurface ? "It is a Trimmed Surface!" : "It is a Surface!"; } else if (geometry is SolidGeometry solid) // Cast it to a SolidGeometry type object { if (solid is BlockSolid) { msg = $"It is a primitive 'Block' solid! - Base: {solid.BasePoint}"; } else if (solid is SphereSolid) { msg = $"It is a primitive 'Sphere' solid! - Base: {solid.BasePoint}"; } else if (solid is ConeSolid) { msg = $"It is a primitive 'Cone' solid! - Base: {solid.BasePoint}"; } else if (solid is TorusSolid) { msg = $"It is a primitive 'Torus' solid! - Base: {solid.BasePoint}"; } else if (solid is CylinderSolid) { msg = $"It is a primitive 'Cylinder' solid! - Base: {solid.BasePoint}"; } else { msg = $"It is a Solid! - Base: {solid.BasePoint}"; } if (moveToOrigin) { solid.BasePoint = new Mastercam.Math.Point3D(); solid.Commit(); } } // For non-specific type properties, we don't need to cast the Geometry object. var level = geometry.Level; var color = geometry.Color; msg += "\n" + string.Format($"It is on Level#:{level} and is Color#:{color}"); MessageBox.Show(msg, "Entity Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } public override MCamReturn Run(int param) { GeometryMask geomMask = new GeometryMask(true); geomMask.xlines = false; geomMask.PMeshes = false; geomMask.PSplines = false; var geom = SelectionManager.AskForGeometry("Select a Geometry item", geomMask); ShowEntityData(geom); return MCamReturn.NoErrors; } } }
Thanks Roger, I'll give it a try.!! will get back to you if I face any issue..
-
17 hours ago, Roger Martin from CNC Software said:
What point would this be?
Is this a "primitive" Solid? (e.g. Bock, Cylinder, etc.)
It is a Block with some thickness. Any example of the code would be better..?
-
Hi,
I am new to Mastercam NetHook Development.
I am trying to get a 3d-point (x,y,z) of the Solid Geometry, but I am not able to find any function for that.
I tried the "BasePoint" function, but it always gives (x,y,z ) points as (0,0,0), though my geometry is not at 0.
Which function is there to get the exact x,y,z points? please help..
-
Hi,
I am new to Mastercam NetHook Development.
I am trying to get a 3d-point (x,y,z) of the Solid Geometry, but I am not able to find any function for that.
I tried the "BasePoint" function, but it always gives (x,y,z ) points as (0,0,0), though my geometry is not at 0.
Which function is there to get the exact x,y,z points? please help..
NETHOOK : Getting Geometry Point
in Mastercam C-Hook, NET-Hook and VBScript Development
Posted
I am not seeing any API in searchManager to retrieve point "entities".
Can you please give an example if you have or direct me to the API..?