-
Re: InsertMacroFeature Issue's SolidWorks 2014
Keith Rice Jan 12, 2014 9:39 PM (in response to Jakob Deslippe)Jakob,
You may already know this, but when you insert a macro feature using IFeatureManager::InsertMacroFeature3, the last argument lets you specify whether to embed the macro feature if the macro is written in VBA. If you choose to embed, there is no way to switch to a non-embedded macro feature. You would need to delete out the macro feature and then reinsert it with the last argument in InsertMacroFeature3 changed to not embed.
Also note concerning embedded macro features and macros added to the design binder: you cannot edit them once they are added. You have to delete them out, make the changes you want to the macro, then re-insert them. Editing the temp macro file will not modify the macro that is actually embedded in the part.
Keith
-
Re: InsertMacroFeature Issue's SolidWorks 2014
Jakob Deslippe Jan 13, 2014 6:34 AM (in response to Keith Rice)Keith,
Thank for your reply, I am using the embed argument and the macro is written in VBA. The problem is when I delete that feature I cannot insert it again for some reason. Its really hit or miss, sometimes it will work and other times it doesn't. Thats why I was curious if it had something to do with temp files.
Here is the code that inserts the macro feature and the embed argument:
Dim MacroFeatOptions As Long
MacroFeatOptions = swMacroFeatureOptions_e.swMacroFeatureAlwaysAtEnd + _
swMacroFeatureOptions_e.swMacroFeatureEmbedMacroFile
Set cmd_MacroFeat = swFeatMan.InsertMacroFeature("Stock block", "", _
(MacroMethods), (ParamNames), (ParamTypes), (ParamValues), _
Nothing, MacroFeatOptions)
I cannot seem to figure out why this macro is not inserting everytime it runs.
-
Re: InsertMacroFeature Issue's SolidWorks 2014
Jakob Deslippe Jan 13, 2014 6:43 AM (in response to Jakob Deslippe)Keith,
I forgot to mention another really weird thing, If I run this macro from the VBA editor (Play Button) it works every time with no problems.
-
Re: InsertMacroFeature Issue's SolidWorks 2014
Keith Rice Jan 14, 2014 4:48 PM (in response to Jakob Deslippe)What you are describing probably isn't related to macro features. If you run a macro with multiple sub procedures using Tools-->Macro-->Run, SolidWorks doesn't know what sub-procedure to run first (the "entry sub procedure"). In your case, you want it to run the one with InsertMacroFeature3. But it might be running another sub-procedure.
There's a few options.
First, try putting the sub procedure with InsertMacroFeature3 last in your module---assuming you have only one module. I have found that, by default, the last sub procedure in a single-module macro will always get run first.
If you have more than one module in your macro, then you can never rely on the Run button starting with the right sub-procedure. Maybe there is some criteria by which the entry sub procedure is picked, but I don't know what it is. So instead what you need to do is run your macro from a macro shortcut button, because there you can specify your desired entry sub procedure.
Directions on how to set up a macro shortcut button.
Hope this helps.
Keith
-
-
-