예제 #1
0
        // Runs the "Normal-To view" command for a feature's sketch (this is the Ctrl+8 user shortcut in Solidworks)
        public int RunNormalToSketchCommand()
        {
            Console.WriteLine("  Running 'Normal-To' command...");
            ModelDoc2 thisModel = default(ModelDoc2);

            try
            {
                thisModel = (ModelDoc2)swApp.ActiveDoc;  // Get the part
                if (thisModel == null)
                {
                    return(-1);
                }
                int    currentCommandID    = 169;                        // // enum int for the NormalTo command (defined in 'swCommands_e')
                string currentCommandTitle = "Normal-To";                // custom name for the command to be run, arbitrary

                swApp.RunCommand(currentCommandID, currentCommandTitle); // Run the Normal-To command
                thisModel.ViewZoomtofit2();
            }
            catch (Exception e)
            {
                ShowFatalErrorMessage(e.ToString());
                throw;
            }

            return(0);
        }