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:

C# Set Main Color & Invoke A Command


Recommended Posts

Ok... I give up trying to figure out these simple tasks in C# for 2017 using VS2013. Any help you can provide would be greatly appreciated. I downloaded Mick's example for SettingsManager but I am obviously way too inexperienced to make the connection to what I thought was the right direction.

 

I have a Nethook that I want to do many things but for starters I want to simply set the MainColor to 224 prior to the next function.

 

I also would like to know how to invoke a command like bounding box or Dynamic Plane as if to emulate the user clicking the command.

 

Thank you in advance from an old man on the brink of insanity.

 

Below is my attempt at this and it's no bueno.

 

 

        public class Main
        {
            private int colorNum = 224;

            public static int MainColor { set; get; }

            public Main( int colorNum )
            {
                MainColor = colorNum;
            }
        }


        private void intFile_Click(object sender, EventArgs e)
        {
            SetLevelNames();
            SolidPart();
            Surfaces();
            Move1to9004();
            TurnAllOn();
            TurnAllOff();
            LevelsManager.SetLevelVisible(2, true);
            LevelsManager.SetLevelVisible(6, true);
            GraphicsManager.Repaint(true);
            Main();                                             //Want to set MainColor here
            Close();
           
        }

Link to comment
Share on other sites

I need to have my function wait until the invoked command is finished. Currently is executes passed it.

 

Below is what I tried but it acts the same as without this code.

 

 

        private void CreateBndBox()
        {
            ExternalAppsManager.PostFTCommand("create_bbox");
            //this.Close();
        }

 

 

        private void BndBox_Click(object sender, EventArgs e)
        {
            SelectionManager.UnselectAllGeometry();
            LevelsManager.SetMainLevel(6);
            TurnAllOff();
            LevelsManager.SetLevelVisible(2, true);
            LevelsManager.RefreshLevelsManager();
            GraphicsManager.Repaint(true);
            SettingsManager.MainColor = 224;

            Task t = Task.Run(() => CreateBndBox());
            t.Wait();

 

            LevelsManager.SetMainLevel(4);
            LevelsManager.SetLevelVisible(2, false);
            MoveSolidto5();
            SelectionManager.UnselectAllGeometry();
            LevelsManager.SetMainLevel(2);
            TurnAllOff();
            LevelsManager.SetLevelVisible(2, true);
            LevelsManager.SetLevelVisible(4, true);
            LevelsManager.SetLevelVisible(6, true);
            LevelsManager.RefreshLevelsManager();
            GraphicsManager.Repaint(true);

            Close();
        }

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