I was able to export equations to and link equations with an external file by GUI. Is there examples for macros that can execute these two actions ?
Have you tried recording the actions you have already done?
I haven't used it much, but I'd guess the results would be a fairly messy un-optimized script, but it will give you a starting point with which to search the API documentation.
Having a closer look at the equations manager GUI, did you use the "Link to external file"?
If so, I would think this to be a permanent change and anything you modify in the external file should be represented in your model. Is this not what you are seeing? I am not sure why you would need a macro here as it is a one-time action. Can you explain the problem you are trying to solve by using macros?
Thank you for your reply.
I have tried recording he macro. But the actions of "link to external file" and "export equations to file" can not be recorded.
The reason I want to do this with macro, is because I am trying to call SOLIDWORKS with external programs.
Any idea about the macro ?
I definitely do not fully understand what problem you are trying to solve with this, but the first question I'd ask yourself is, "Do you have to do this action more than 10 times in the foreseeable future?" (I'm often the victim of my own optimism in thinking I can speed anything up with a script, but depending on how many times you will use it, it is often more time efficient just to do it by hand). This doesn't sound like something that would be more efficient via a script, unless you are trying to enable this for hundreds of files.
Can you please describe the problem you are trying to solve by writing this macro? Are you creating new parts via macros? Adjusting a single dimension in a hundred different existing files or what? I can likely help a bit more if I know more about the problem itself as each problem would have a different solution. What do you mean by "I am trying to call SOLIDWORKS with external programs." Which external programs and what are you trying to modify/create in solidworks via this program?
I can't imagine a use-case where what you describe would be more helpful than another approach, but again I don't know exactly what you are trying to do. In general, I'd think if you wanted to do anything via macros dealing with changing dimensions, you'd be storing variables in your script and editing the dimension (2020 SOLIDWORKS API Help - IDimension Interface ) within the code, not relying on some external csv or excel file. Again, happy to help, but need to know more about the use-case before I can recommend anything further.
I really cannot tell you the details about why I am trying to do this. But "Do you have to do this action more than 10 times in the foreseeable future?" Yes, it will probably be done for more than thousands of times.
This is what I am trying to do. I am trying to access a SOLIDWORKS model by using my own program to read the information in the model, and it needs to be in batch mode without opening the GUI.
Also with the following assumptions
1. The parameters in the model has been linked with an external file. I need to know that the file name is, so that I can open that file by my program and get the info.
2. The parameters in the model has NOT been linked with an external file. I need to link certain parameters with specific naming convention (for example, myPara_*), and dump the info to an external file. Then I can read from that file.
I see. Thank you for the details you could provide.
>1. The parameters in the model has been linked with an external file. I need to know that the file name is, so that I can open that file by my program and get the info.
I assume you mean you need to handle both of these situations, i.e. if 1.) then do something, if 2.) do something else? (They seem conflicting otherwise).
It looks like most of what you'll need can be found within the [IEquationMgr Interface](2019 SOLIDWORKS API Help - IEquationMgr Interface ). There are few examples of its use in the link above as well. If you look at the [members](2019 SOLIDWORKS API Help - IEquationMgr Interface Members ) you can check whether it is linked to an external file by getting the [LinkToFile](2019 SOLIDWORKS API Help - LinkToFile Property (IEquationMgr) ) property, and if that returns True, you can get the path to that file via the [FilePath](2019 SOLIDWORKS API Help - FilePath Property (IEquationMgr) ) property. Let me know if you need any help past that, but that looks pretty spot on to me.
There is a lot of information there. I browse through it, and found a lot of useful leads. It will take me sometimes to filter out all of them. But, it is really useful. Thank you !
Retrieving data ...