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:

Chain Offset Contour


Recommended Posts

22 minutes ago, JKLINE said:

If you create a box around all the geometry, and use 'area' upon selection, everything turns out correctly 🤦‍♂️

I don't see a way to capture area as a chain.             System.Console.CursorLeft? 😅

I'm sorry, I don't understand the question

Link to comment
Share on other sites

In your earlier post, you said I can not get the outcome I desire because they are not closed chains.

That gave me the idea of using the 'area' method in the Chain Selection UI. (Inside a bounding box).

Since there's no 'area' method in the ChainManager, I'm thinking I could automate the user input portion.

ex. Hotkey "a" then Mouse.LeftButton = pressed

Link to comment
Share on other sites
32 minutes ago, JKLINE said:

In your earlier post, you said I can not get the outcome I desire because they are not closed chains.

That gave me the idea of using the 'area' method in the Chain Selection UI. (Inside a bounding box).

Since there's no 'area' method in the ChainManager, I'm thinking I could automate the user input portion.

ex. Hotkey "a" then Mouse.LeftButton = pressed

There is an area member of chain, if its a closed chain

You can attempt to convert your open chains into closed chains by drawing a line from the first and last endpoint, which would give you a closed chain you could use to get a direction, see drawing

image.thumb.png.06c51e44b25abbb483e5f138fa061ae3.png


public : property double Area { get; }
    Member of Mastercam::Database::Chain

Summary:
Gets the area within the chain, assuming it's closed.

 

Link to comment
Share on other sites

Just get the entities in the chain then get the bounding box of the entities & see if it falls inside the area you want, 

After re-reading your post I think this is what you are after 

 

Mastercam::IO::SelectionManager::BoxSelectGeometry(System::String^, Mastercam::Database::Types::GeometryMask, Mastercam::IO::Types::BoxSelectionType)

Link to comment
Share on other sites

Solution.

It's about as ugly as it gets. 🤣😅🥲😢😭

            void offsetCutchain80(){
                var commonParams = new BoundingBoxCommonParams { CreateLinesArcs = true };
                var rectangularParams = new BoundingBoxRectangularParams {ExpandXMinus = 2.0,ExpandXPlus = 2.0,ExpandYMinus = 2.0,ExpandYPlus = 2.0};
                var boundingBox = Mastercam.GeometryUtility.GeometryCreationManager.RectangularBoundingBox(commonParams, rectangularParams);
                var boundingBoxChain = ChainManager.ChainGeometry(boundingBox);
                GraphicsManager.FitScreen();
                void SendLeftClick(int posX, int posY){
                    Cursor.Position = new Point(posX, posY);
                    mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
                    Thread.Sleep(100);
                    mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
                }
                new System.Threading.Timer((x) => { GraphicsManager.SetFocusToGraphicsWindow(); }, null, 1000, Timeout.Infinite);
                new System.Threading.Timer((x) => { SendKeys.SendWait("{A}"); }, null, 2000, Timeout.Infinite);
                new System.Threading.Timer((x) => { SendLeftClick(1200,600); }, null, 3000, Timeout.Infinite);
                new System.Threading.Timer((x) => { SendKeys.SendWait("{ENTER}"); }, null, 6000, Timeout.Infinite);
                var selectedCutChain = ChainManager.GetMultipleChains("");
                foreach (var chain in selectedCutChain){
                    foreach (var t in boundingBoxChain){
                        if (chain.Area != t.Area){
                            chain.Direction = ChainDirectionType.Clockwise;
                            chain.OffsetChain2D(OffsetSideType.Right, .0225, OffsetRollCornerType.None, .5, false, .0001, false);
                            GraphicsManager.ClearColors(new GroupSelectionMask(true));
                        }
                    }
                }
                foreach (var entity in boundingBox){
                    entity.Retrieve();
                    entity.Delete(true);
                }
                GraphicsManager.Repaint(true);
            } 
            offsetCutchain80();
            return MCamReturn.NoErrors;

 

Link to comment
Share on other sites
  • 1 month later...

Ever seen anything like this? I've ran out of debug ideas 😭

Original geo is the white line. Chained it and offset with OffsetChain2D both directions.

Input chain has 4 entities, meanwhile one of the results has 5 entities and the other has 6 entities.

I've verified that the chain going into the OffsetChain2D method has only 4 entities. I've also offset the chains by hand and that worked as intended. I extracted the geometry to a fresh Mastercam file and ran only the OffsetChain2D method on it and it worked as intended. Meaning my code works and the geometry isn't the problem.

Why would my result have more entities than the starting chain? 🤔

 

Untitled.png

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