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:

Mass Edit Rotary Axis


Recommended Posts

I'm looking at a mass edit to change all of the rotary diameter's in the toolpaths. Later to edit other boxes and even later creating toolpaths.

It wouldn't let me add the OperationIDs to a list unless I labeled the list as <int[]> do they have a different ID system than geometry?

I believed I have set up the parameters for the RotaryAxisParams but I'm not sure how to load it into the operation. My best guess is that it has something to do with my list not populating correctly.

            void changeOperations() {
                var operations = new List<int[]>();
                var rotaryPD = 0.0;
                DialogManager.AskForNumber("Enter New Rotary PD", ref rotaryPD);
                OperationsManager.RefreshOperationsManager(true);
                operations.Add(SearchManager.GetOperationIDs(true));
                var axisSub = new RotaryAxisSubstitution{
                     
                };
                var axisParams = new RotaryAxisParams{
                    Enabled = true, 
                    Diameter = rotaryPD,
                    AxisSubstitution = axisSub  
                };

                foreach (var selectedOperation in operations){
                    selectedOperation.RotaryAxis = axisParams;
                    selectedOperation.commit();
                }
                OperationsManager.RefreshOperationsManager(true);
            }

            changeOperations();

 

Link to comment
Share on other sites

A couple things. 

 var operations = new List<int[]>();

1> No. You don't want a List of arrays (of integers).

2> You have not retrieved the actual "operation" here. You are looping through the IDs.

  foreach (var selectedOperation in operations){
                    selectedOperation.RotaryAxis = axisParams;
                    selectedOperation.commit();
                }

 

Try this...

        private void ChangeOperations()
        {
            var rotaryPD = 0.0;
            DialogManager.AskForNumber("Enter New Rotary PD", ref rotaryPD);
            OperationsManager.RefreshOperationsManager(true);
            var operationIDs = SearchManager.GetOperationIDs(true);
            var axisSub = new RotaryAxisSubstitution
            {

            };
            var axisParams = new RotaryAxisParams
            {
                Enabled = true,
                Diameter = rotaryPD,
                AxisSubstitution = axisSub
            };

            foreach (var opID in operationIDs)
            {
                var op = SearchManager.GetOperation(opID);
                op.RotaryAxis = axisParams;
                op.Commit();
            }
            OperationsManager.RefreshOperationsManager(true);
        }

 

Link to comment
Share on other sites

I also had to change "var axisSub = new RotaryAxisSubstitution". But everything works other than that, thank you.

Additionally, it does not make ALL the operations dirty, only some of them. Should I have it regen the toolpaths just in case?

 

            void ChangeOperations(){
                var rotaryPD = 0.0;
                DialogManager.AskForNumber("Enter New Rotary PD", ref rotaryPD);
                OperationsManager.RefreshOperationsManager(true);
                var operationIDs = SearchManager.GetOperationIDs(true);

                var axisParams = new RotaryAxisParams
                {
                    Enabled = true,
                    Diameter = rotaryPD,
                    Type = RotaryAxisPositionType.AxisSubstitution
                };

                foreach (var opID in operationIDs)
                {
                    var op = SearchManager.GetOperation(opID);
                    op.RotaryAxis = axisParams;
                    op.Commit();
                }
                OperationsManager.RefreshOperationsManager(true);
            }

            ChangeOperations();

 

Link to comment
Share on other sites

Awesome, thank you. Works like a charm :D

 

            void ChangeOperations(){
                var rotaryPD = 0.0;
                DialogManager.AskForNumber("Enter New Rotary PD", ref rotaryPD);
                OperationsManager.RefreshOperationsManager(true);
                var operationIDs = SearchManager.GetOperationIDs(true);
                var axisParams = new RotaryAxisParams
                {
                    Enabled = true,
                    Diameter = rotaryPD,
                    Type = RotaryAxisPositionType.AxisSubstitution,
                    Direction = RotaryAxisDirection.CW,
                    AxisSubstitution = RotaryAxisSubstitution.SubsituteX
                };

                foreach (var opID in operationIDs){
                    var op = SearchManager.GetOperation(opID);
                    op.RotaryAxis = axisParams;
                    op.MarkDirty();
                    op.Commit();
                }
                OperationsManager.RefreshOperationsManager(true);
            }
            ChangeOperations();
            return MCamReturn.NoErrors;

 

Link to comment
Share on other sites

I thought I was being clever by adding 

                        var array = ((ChainBasedOperation)op).GetChainArray();
                        op.RotaryAxis = axisParams;
                        ((ChainBasedOperation)op).SetChainArray(array);

But it didn't work 😅 I still lose the avoidance region and containment region of the geometry selection.

Link to comment
Share on other sites

These are the two different programs we use. Same toolpaths, different rotary diameter.

Even the surface programs have their rotary diameter changed. The only issue is when the toolpath has additional geometry.

Selected geometry is kept, avoidance/containment geometry is lost.

 

toolpath list 2.png

toolpath list 1.png

Link to comment
Share on other sites

It works. Thank you. 😊

            void ChangeOperations(){
                var rotaryPD = 0.0;
                DialogManager.AskForNumber("Enter New Rotary PD", ref rotaryPD);
                OperationsManager.RefreshOperationsManager(true);
                var operationIDs = SearchManager.GetOperationIDs(true);
                var axisParams = new RotaryAxisParams
                {
                    Enabled = true,
                    Diameter = rotaryPD,
                    Type = RotaryAxisPositionType.AxisSubstitution,
                    Direction = RotaryAxisDirection.CW,
                    AxisSubstitution = RotaryAxisSubstitution.SubsituteY
                };

                foreach (var opID in operationIDs){
                    var op = SearchManager.GetOperation(opID);
                    op.RotaryAxis = axisParams;
                    op.MarkDirty();
                    op.Commit(false);
                }
                OperationsManager.RefreshOperationsManager(true);
            }
            ChangeOperations();
            return MCamReturn.NoErrors;

 

Link to comment
Share on other sites

Something file in your memory about the NET-Hook API -
Whenever you are doing Commit on an Operation.
If you have not altered the geometry (chains, drill points, etc.) assigned to that operation.
In other words, you are just updating "parameters" of the operation.
Use the Commit overload that takes a boolean parameter and pass "false" -> op.Commit(false);

"false" here tells it not to look at (or touch) the geometry in the operation when doing the Commit (update).

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