Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

AnshuP

Verified Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by AnshuP

  1. 19 hours ago, Roger Martin from CNC Software said:

    With SearchManger you can retrieve point "entities".
    What you show in the video is not finding/selecting point entities.
    Using Dynamic you are snapping to a location (is this case the end of an edge) and then telling Mastercam to make (move) the location to the origin.
    You cannot do this with a NET-Hook type add-in unless you have a From point position and here there is no point entities to find.
    With a C-Hook add-in you could create the edges of the Solid and then go through the endpoints of each edge.
    You would need to have some criteria to know which edge endpoint you want to use.
    (i.e. Always using the upper-left in XY endpoint location?)
    What happens if the Solid is not a rectangular shaped, but some arbitrary shaped solid?
    (i.e. You have a free-form chained output that was using to created an extruded solid.)
     

    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..?

  2. 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..?

  3. 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?

  4. 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..

  5. 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..

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...