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:

Select Geometry


Recommended Posts

I am trying to select the result of an offset chain. I can't get the mask to select anything no matter the mask type but I CAN get it to select everything at once.

            SelectionManager.SelectAllGeometry();
            SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Wireframe);

In it's entirety ""

            var selectedChain = ChainManager.GetOneChain("Select a Chain");

            int createdUpperLevel = 500;
            int createdLowerLevel = 501;
            
            var upperChainLarge = selectedChain.OffsetChain2D(OffsetSideType.Right,
                                                          .0225,
                                                          OffsetRollCornerType.None,
                                                          .5,
                                                          false,
                                                          .005,
                                                          false);

            var upperLargeGeometry = ChainManager.GetGeometryInChain(upperChainLarge);
            SearchManager.GetResultGeometry();
            SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Result);
            GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperLevel, true);
            

            var upperChainSmall = selectedChain.OffsetChain2D(OffsetSideType.Left,
                                              .0025,
                                              OffsetRollCornerType.None,
                                              .5,
                                              false,
                                              .005,
                                              false);

            var upperSmallGeometry = ChainManager.GetGeometryInChain(upperChainSmall);
            SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Result);
            GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperLevel, true);

            var lowerChainLarge = selectedChain.OffsetChain2D(OffsetSideType.Right,
                                              .0025,
                                              OffsetRollCornerType.None,
                                              .5,
                                              false,
                                              .005,
                                              false);

            var lowerLargeGeometry = ChainManager.GetGeometryInChain(lowerChainLarge);
            SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Result);
            GeometryManipulationManager.MoveSelectedGeometryToLevel(createdLowerLevel, true);

            var lowerChainSmall = selectedChain.OffsetChain2D(OffsetSideType.Left,
                                              .0385,
                                              OffsetRollCornerType.None,
                                              .5,
                                              false,
                                              .005,
                                              false);

            var lowerSmallGeometry = ChainManager.GetGeometryInChain(lowerChainSmall);
            SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Result);
            GeometryManipulationManager.MoveSelectedGeometryToLevel(createdLowerLevel, true);

            foreach (var entity in upperLargeGeometry)
            {
                entity.Commit();
            }

            foreach (var entity in upperSmallGeometry)
            {
                entity.Commit();
            }

            foreach (var entity in lowerLargeGeometry)
            {
                entity.Commit();
            }

            foreach (var entity in lowerSmallGeometry)
            {
                entity.Commit();
            }

			//Code works
            //SelectionManager.SelectAllGeometry();
			//Code doesn't work
            // SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Wireframe);

 

Link to comment
Share on other sites

Once we have created an offset contour you want to move the new geometry to another level.

// The new geometry created by OffsetChain2D is marked as a “result”. 
var upperChainLarge = selectedChain.OffsetChain2D(. . .);
           
// To mark the “result” geometry as “selected” we can do this ->
SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Result);

// Now we move this “selected” geometry to another level.
GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperLevel, true);

Or we can do this –>

// The new geometry created by OffsetChain2D is marked as a “result”. 
var upperChainLarge = selectedChain.OffsetChain2D(. . .);
// Get the “result” geometry
var resultGeometry = SearchManager.GetResultGeometry();
// To mark the “result” geometry as “selected” we can do this ->
foreach (var item in resultGeometry)
   {
   item.Selected = true;
   item.Commit();
   }
// Now we move this “selected” geometry to another level.
GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperLevel, true);

Or if we just wish to move the new offset geometry to another level (without marking them as "selected") ->

// The new geometry created by OffsetChain2D is marked as a “result”. 
var upperChainLarge = selectedChain.OffsetChain2D(. . .);
// Get the “result” geometry
var resultGeometry = SearchManager.GetResultGeometry();
// Change the level on each to the “result” geometries
 foreach (var entity in resultGeometry)
   {
   entity.Level = createdUpperLevel;
   entity.Commit();
   }

 

Link to comment
Share on other sites

Thank you Roger!

I'm not sure why that first option "SelectionManager.SelectGeometryByMask(Mastercam.IO.Types.QuickMaskType.Result);" doesn't work for me, but the other two certainly do.

Even taught me about more tools in the API, although it still looks sloppy and overly complicated.

On to my next challenge.

Thank you!

 

        public Mastercam.App.Types.MCamReturn CustomNethookRun(Mastercam.App.Types.MCamReturn notused)
        {
            var selectedChain = ChainManager.GetOneChain("Select a Chain");
            int createdUpperLevel = 500;
            int createdLowerLevel = 501;
            LevelsManager.SetLevelName(500, "Upper Created Geo");
            LevelsManager.SetLevelName(501, "Lower Created Geo");

            var upperChainLarge = selectedChain.OffsetChain2D(OffsetSideType.Right,.0225,OffsetRollCornerType.None,.5,false,.005,false);
            var upperLargeGeometry = ChainManager.GetGeometryInChain(upperChainLarge);
           
            var upperChainSmall = selectedChain.OffsetChain2D(OffsetSideType.Left,.0025,OffsetRollCornerType.None,.5,false,.005,false);
            var upperSmallGeometry = ChainManager.GetGeometryInChain(upperChainSmall);

            var resultGeometry = SearchManager.GetResultGeometry();
            foreach (var entity in resultGeometry)
            {
                entity.Color = 11;
                entity.Selected = true;
                entity.Commit();
            }
            GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperLevel, true);
            GraphicsManager.ClearColors(new GroupSelectionMask(true));

            var lowerChainLarge = selectedChain.OffsetChain2D(OffsetSideType.Right,.0025,OffsetRollCornerType.None,.5,false,.005,false);
            var lowerLargeGeometry = ChainManager.GetGeometryInChain(lowerChainLarge);

            var lowerChainSmall = selectedChain.OffsetChain2D(OffsetSideType.Left,.0385,OffsetRollCornerType.None,.5,false,.005,false);
            var lowerSmallGeometry = ChainManager.GetGeometryInChain(lowerChainSmall);

            var resultGeometryNew = SearchManager.GetResultGeometry();
            foreach (var entity in resultGeometryNew)
            {
                entity.Color = 10;
                entity.Selected = true;
                entity.Commit();
            }
            GeometryManipulationManager.MoveSelectedGeometryToLevel(createdLowerLevel, true);
            GraphicsManager.ClearColors(new GroupSelectionMask(true));

            foreach (var entity in upperLargeGeometry)            {                entity.Commit();            }
            foreach (var entity in upperSmallGeometry)            {                entity.Commit();            }
            foreach (var entity in lowerLargeGeometry)            {                entity.Commit();            }
            foreach (var entity in lowerSmallGeometry)            {                entity.Commit();            }

            return MCamReturn.NoErrors;

        }

 

Link to comment
Share on other sites
1 hour ago, JKLINE said:
  foreach (var entity in upperLargeGeometry)            {                entity.Commit();            }
            foreach (var entity in upperSmallGeometry)            {                entity.Commit();            }
            foreach (var entity in lowerLargeGeometry)            {                entity.Commit();            }
            foreach (var entity in lowerSmallGeometry)            {                entity.Commit();            }

Remove these lines from your code. They do not look to being doing anything useful here.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

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