Hi. First of all I am very new to this (less than a month of programming with VB or solid edge, no programming outside the classroom, and nothing close to this advanced), so I apologize for my ignorance on some things.
I am using the templates from Github (thanks a lot Jason Newell and anyone else who helped) and have had some success. I am trying to find a way to have an event (for example one with the CommandID 45163) trigger a method. Is there a way to do this? Or is there a much better way to do it?
I am trying to trigger a Windows Form (that I originally wrote as a macro) to run at the start of each new document. I have it currently set up to run in OnConnectToEnvironment and it works great, but I want to set it up to run as stated above.
Thanks again for all the help posted on here, it is what got me this far, and Jason again for the Spy for Solid Edge program.
Thanks in advance
I have updated the addin demo in the Solid Edge Community Samples on GitHub. We typically publish these samples to CodePlex on roughly a monthly schedule but you can go get the latest copy of the source by clicking the Download link on the GitHub page. Once you download the .zip, extract it and navigate to the folder \vb\SolidEdge\MyAddin and open MyAddIn.sln.
Once you have the solution open, take a look at the OnConnection() method. I have comments on how to connect to various Solid Edge events. The ApplicationEvents are already hooked up so you'll want to put your code to detect a command in either the AfterCommandRun() or BeforeCommandRun() event hooks. Also look at the AfterNewDocumentOpen() event hook where you were wanting to show a form. For an example on how to show a modal dialog from an addin, look at Ribbon3d.vb in the OnControlClick() method. There are some good examples in there.
I ended up getting it working using the AfterNewDocumentOpen() event like you suggested, don't know how I didn't see that the first time using Spy for Solid Edge.
While I don't quite understand what you have done, I will keep trying to figure it out. I will also use the modal dialog as that is better for what I am trying to do then my previous attempts.
Thanks for the update Keegan. Regarding your comment "While I don't quite understand what you have done, I will keep trying to figure it out", what can I do to help you (and others) get up to speed with all of the open source stuff I'm doing. I'm working on training videos but I am very much open to suggestions and ideas.
I am sure my problem is due to my inexperience with Visual Basic or any advanced programming. The extent of my formal education is a high school course in Java, and a first year engineering course in C. Even when I first posted, I had almost no understanding of what "events" were. I don't really know more now other then I can "handle them". Haha.
I am just working through teaching myself. Right now I am having the same problem as this person:
Your demo's are very useful, and thanks again for them.
But with your "OnConnection" method, I just don't really know what I am looking at.
Understood. No doubt it is a considerable time effort required to get up to speed with not only modern programming languages and methodologies but also really any CAD API as they tend to be very large. You really do just have to dig in and spend time trying to understand everything but don't be afraid to ask questions. We all get stumped at some point and have to ask for help.
Besides the help and support you get in these forums, you might also consider attending the next Solid Edge University. We have a Developer Day dedicated to Solid Edge automation with beginner and advanced tracks with multiple speakers including myself. It's really a rare opportunity to get face time with people like myself. I am also available for the other days of the conference if anyone needs one-on-one time with me.
Regarding the other post you mentioned, I'll try to take a look at it over the weekend.
Hi, I'm quite new at programming in SE and .net even if I had a training 2 or 3 years ago. I'm able to do a few things but when it comes to events I'm a bit stuck.
My question is about blocks. Is it possible to show a windows form after a specific block occurrence is placed in a sheet ?
In my case I have a block with many labels, and when I drag it in place, I want to replace the standard block properties window (which I can avoir showing just by setting the labels options properly) by a more complex one (a windows form) with a lot of options to select from (once these options are chosen, the labels are filled accordingly).
Each block occurrence will have different values in the labels of course.
The windows form will also have to be shown if I edit the block (but in this case to do it simply I'll just add a button to the addin to edit the selected occurrence of the block).
The whole idea behind this is that I didn't found a way to place a block with interactivy from the user. If i could click on button, then show the form, and then place the block interactively (as it does when you just drag and drop it from the block library) I wouldn't bother with the events.
So I guess I'll have some reading within the links provided, but I want to know if one of my 2 ideas is possible (either place the block interactively where I want after clicking a button from the addin, knowing that I know how to place the block on desired coordinates), or show the windows form after a specific block is placed from the library (drag and drop, click in the sheet, show the form).
Best regards and thanks for the many advices found here.