Hi all,
Can't seem to find anything on this but pleanty on macros, anyway, is it possible to add VB code to part or assembly files as opposed to creating separate macros? I thought it would be simple like in Inventor but can't seem to work it out..
What I wan't to do is be able to control my geometry of a part and also control the simulation variables from one form. At the end of the form I will have a button called mesh and run for example. Each form and associated code will be used for that part only so can I store it in the part file like I can with Inventor, word and Excel? I don't need to create the geometry with the code, I only need to control the dimension value, like linking an equation to the VBA code. I guess a macro would also be ok but is there any way to embed it or link it to a particular part file?
Programming is not the problem, just trying to understand how it links in with Solidworks or if it is a current limitation. If anyone has some information or examples that would be great.
Cheers.
SolidworksApi macros
Sorry, I missed the simulation variables part. Too late at work. Anyway, I don't know enough about Simulation, but I pretty much doubt it. I would imagine that you would have to get into the Simulation API to access those variables.
Writing such a macro to control variables/dimensions etc. for a specific file wouldn't be much easier than writing one macro that could examine the document and look for variables/dimensions that are named a certain way and put them into a form. That way you only write the code once.
You could also Paste the VB code onto the Design binder in the Part file.
Devon Sowell
http://www.3-ddesignsolutions.com
You could try a macro feature. There is an option to embed VBA macro directly to macro feature in the model.
You could setup you macro feature to react Edit Definition command and for example show the user form next.
Again, I can only speak with experience about the non-simulation stuff, but there are a few ways you can sort of "mark" dimensions or annotations for reference in the future.
Attached are a couple of macros I wrote. Depending on how much time you have, they may or may not be so helpful to your specific task.
In the "TabulateAllDimsWithCriticals", I use an Attribute feature to store the names of all the "important" dimensions and parameters of the specific file I am working on. The main thread detailing actual use of this macro is:
https://forum.solidworks.com/thread/26226
In Make_Note_Group I took a different strategy. Annotations that I wanted to recall later were named with a prefix and then a pseudo-random number (integer number of seconds since midnight). That way they could be found later by looking at the name.