Is there any way to link macro feature to a macro .swp file to update it if needed? Or Should make it run a macro remotely by using swApp.RunMacro2 ...
Do you mean you want to run another macro by macro feature? If yes then you can use the RunMacro2 command in the macro feature.
My purpose is to change variables(for instance. a list of string) inside macro feature if I need to, is that possible?
I might do this via another macro that can be accessed within file system by runmacro command.
I am not sure whether I understood truly. Could you give me any example what you want? Maybe you need event handler. When you changed something in Solidworks, did you wanted to run macro automatically?
I am using event handler in macro feature. It is in a drawing and it is just for to automaticaly control some information. And I am asking is there a way to change the macro feature whenever I want, remotely, without modifying macro feature inserted document?Is there a way to trigger events without any user input beside macro feature and an add-in?
If you control some information automatically, you don't need macro feature. You can use event handler in Solidworks Add-in. You can check this topic which I create https://forum.solidworks.com/message/812795Part Number Generation Tool Add-Ins As Free
I create part generation tool. If you open new part, my code will work automatically. Then change part name. You can write similar code. If you want to control in drawing, you can use save file file event. If user click save button in Solidworks drawing, your code will works automatically. Do you want like this?
Thanks for that. Are you willing to provide source code?
the source code to start with is in the API SDK that comes with solidworks.
install the sdk and you will have a template in Visual studio to start with.
If the macro feature is inserted with VBA using IFeatureManager.InsertMacroFeatureX then the last argument lets you specify whether the macro is embedded in the file. You would need it to not be embedded. As for whether you could modify the referenced SWP, I don't know, depends on what part of the macro you need to change. I would just try it.
Is there a way to trigger events without any user input beside macro feature and an add-in?
Macro features can only trigger something when the model gets rebuilt, so that might not be reliable, though a macro feature can travel with the document, unlike an addin.
SolidWorks API Training and Services
Thank you. Like you said, last variable in InsertMacroFeature is supposed to be the option to select macro to be embed or not, but I don't know what is the opposite of swMacroFeatureEmbedMacroFile entry
2015 SOLIDWORKS API Help - swMacroFeatureOptions_e Enumeration
it is bitmask, it means that you can combine options with OR.
as example if you want embed macro file and you want to put feature at the end of featuretree then
options = swMacroFeatureAlwaysAtEnd OR swMacroFeatureEmbedMacroFile
If you want to use linked file then skip swMacroFeatureEmbedMacroFile
options = swMacroFeatureByDefault
Thank you for valuable information. It doesn't matter if I try to choose swMacroFeatureByDefault or swMacroFeatureEmbedMacroFile, it simply embeds macro in document. Outsourced macro feature can't be done I guess, I couldn't do that right now
can you post your InsertMacroFeature3 code here?
MacroFeatures main purpose is a custom feature inside of solidworks. there are a few that exist in the Main solidworks application.
These all modify a body and are the same as a normal feature like revolve ect. they are just completely open features that can do whatever you want them to.
they can build a website for you. (hehe, but seriously they could)
they can create bodies
they can modify bodies
their purpose is not to set variables up nor be used as events.
certain things if executed during a macrofeatures regeneration method can cause some serious issues. you must be careful not to modify dimensions across configurations, modify anything that would force a rebuild as it would be an endless cycle of regeneration.
Thank you for your suggestions
Retrieving data ...