Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pre/Post menu actions (API)

Status
Not open for further replies.

krz177

Mechanical
Jan 11, 2015
14
I am trying to find a way to bind a custom dll to an existing button in Solidworks. Basically when the user hits the print button, I want that action to trigger my code to run first, then once execution is completed, continue on with the normal print function. I am used to having this functionality when programming for NX by loading custom menu files that I can push out to the whole organization. I have not been able to find similar editing of the menu capability in Solidworks. Through my searching commandOpenPreNotify looks the most promising and in testing it will indeed trigger my function. My problem is isolating it to run just when the print button is hit. At the moment it will run when a user does anything in the software. It is my understanding that I can pass an integer to this function in order to specify on what existing command it should be triggered (please correct me if I'm wrong). If this is the case I am having issues finding what this integer would be. I latched on with my debugger and have set countless watch points trying to see the result of what menu item the user selects, but with no luck.

I just started API programming for Solidworks a few days ago. More or less I have to emulate the same custom functions I've programmed for NX and "port" them for Solidworks. I am making headway but this triggering of my custom functions is what is holding me back currently.

Using vb.net or c#,

Thankyou ahead of time
 
Replies continue below

Recommended for you

So I don't know how I didn't see this one before but there is a printNotfiy event handler which I missed in the documentation. Have to see if I can have it be able to trigger before actually printing the document but we will see, looks promising from the documentation.
 
Seems like huge trouble. What about killing the print button in the UI through a standard "copy settings wiz" file and substituting your own macro button that looks the same but runs your code? Much more lightweight than having your dll always watching every single thing the user does.

-handleman, CSWP (The new, easy test)
 
I settled on just making a new menu to trigger the functionality I'm coding. The project kind of ballooned with more functionality that is better served by the user running separate functions that is not longer tied to when the user prints. Thanks for the suggestion anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor