why do these Commands operate differently in an ASM?

Valued Contributor
Valued Contributor

why can i use this on an ASM enviroment :

 

application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartFormatShadedwithVisibleEdges);

 

But i can not use this:

 

application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartSketchHideAllSketches);

Nathan M. Gardner

https://www.etsy.com/people/NathanMGardner

Be sure to check out my work!!
Made in Maine Wood Carvings

4 REPLIES

Re: why do these Commands operate differently in an ASM?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I really, really loathe StartCommand()...

 

First off, PartCommandConstants are intended for the Part environment. The fact that you can use it in Assembly and it actually does something is just coincidence. If you look across the various CommandConstants, a lot of common commands have the same numeric value, but not all. For documented Assembly commands, you should use AssemblyCommandConstants. As you are likely aware, it would seem that the various environment CommandConstants are not 100% completely documented as you can clearly call StartCommand() with some int if you know what value to use.

 

All that said, I ALWAYS look for an alternative approach to StartCommand(). For altering the view, I would point you to SolidEdgeFramework.View.RenderModeType. You can get to the view via Application.ActiveWindow.View. If you'll use that approach, you can forget StartCommand() all together.

 

Regarding hiding all sketches, I see no reason you couldn't code it yourself. I haven't tried it but it should be fairly easy.

 

StartCommand() looks so convienent but it's quicksand, for many reasons.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: why do these Commands operate differently in an ASM?

Valued Contributor
Valued Contributor

Thanks for the input. very much apperciated. i was thinking along those lines but i wanted to hear it from an expert.

 

I would like to hear more about your dislike of "StartCommand()" if you have time.

Nathan M. Gardner

https://www.etsy.com/people/NathanMGardner

Be sure to check out my work!!
Made in Maine Wood Carvings

Re: why do these Commands operate differently in an ASM?

Phenom
Phenom

To me, StartCommand() is like the SendKeys() in old VB which I have been told should be avoided.

~Tushar

 

Re: why do these Commands operate differently in an ASM?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The main issue with StartCommand() is that it is an asynchronous operation. That means that you have no way to know when the command is completed (other than listening for the AfterCommandRun event). When you call StartCommand(), the method returns immediately and your code continues to execute. The command may not have time to complete before your code moves on doing other things.

 

For example, image that you called a potentially long running command like DetailCommandConstants.DetailDrawingViewsUpdateViews. Your code returns immediately, you save and close the file. There is a good chance that the command did not have time to complete yet you have no way to know for sure.

 

There are times that using StartCommand() is appropriate. It just needs to be used with caution and as a last resort.

Jason Newell
Applications Architect
www.jasonnewell.net