API Error for Start Command Method

Valued Contributor
Valued Contributor

Has anyone used the Start Command in Solid Edge Frame Work API for Updating All Links in Assembly document?

 

I can't get the start command method to work this is my line of code:

 

application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyAssemblyToolsUpdateAllLinks);

 

But it tell me that I am passing an invalid argument

5 REPLIES

Re: API Error for Start Command Method

Phenom
Phenom

I am unable to reproduce the problem.

Do you have a screenshot of the error ?

 

I had set Automatic Update both on and off but still there is no problem.

 

Check if you have added reference to the SE constants library ?

Re: API Error for Start Command Method

Valued Contributor
Valued Contributor

Hello, thanks for your reply,

 

I was getting 2 error messages :

 

1) Error 6 The best overloaded method match for 'SolidEdgeFramework.Application.StartCommand(SolidEdgeFramework.SolidEdgeCommandConstants)' has some invalid arguments C:\TFS\SolidBuilder\SolidBuilder\onEdge.cs 167 13 SolidBuilder

 

2) Error 7 Argument 1: cannot convert from 'SolidEdgeConstants.AssemblyCommandConstants' to 'SolidEdgeFramework.SolidEdgeCommandConstants' C:\TFS\SolidBuilder\SolidBuilder\onEdge.cs 167 38 SolidBuilder

Re: API Error for Start Command Method

Phenom
Phenom

I have seen error (1) and (2) before but did not actually solve using the method I am sugegsting here:

Try DirectCast or CType as below:

 

oApp.StartCommand(DirectCast(SolidEdgeConstants.AssemblyCommandConstants.AssemblyAssemblyToolsUpdateAllLinks, SolidEdgeFramework.SolidEdgeCommandConstants))

 

Else, try using CType instead of DirectCast, with the arguments remaining same.

 

If you are using CSharp, cast as below:

 

oApp.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)(SolidEdgeConstants.AssemblyCommandConstants.AssemblyAssemblyToolsUpdateAllLinks));

 

Re: API Error for Start Command Method

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Tushar is absolutely correct. This particular API method is not very friendly because you must cast the parameter as SolidEdgeFramework.SolidEdgeCommandConstants. Just be sure that you use the correct enum depending on the current environment as each environment has its own enum for command constants. I cover this in my Spy for Solid Edge Introduction video.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: API Error for Start Command Method

Valued Contributor
Valued Contributor

Thank you Tushar and Jason, the error went a way with the casting. I still need to run it. Hey Jason this is Sergio Vallejo we spoke at the developer Day at SEU 2014 in ATL and at the brewery, I was trying to follow you in github and I opened an account but did not know how to follow you or to register into your group. Regards Sergio