Macro Features
Macro Features
(OP)
Hi,
I need to find a way to suppress a feature (without using a design table) based on the value of an equation. Seems like an inline macro feature is the only way to do this?
Documentation and examples of macrofeatures seem sparse? I'm not positive how to pass the equation value into the macros if statement. And I'm not sure how the macro feature actually ends up in the feature tree?
TIA
Zander
I need to find a way to suppress a feature (without using a design table) based on the value of an equation. Seems like an inline macro feature is the only way to do this?
Documentation and examples of macrofeatures seem sparse? I'm not positive how to pass the equation value into the macros if statement. And I'm not sure how the macro feature actually ends up in the feature tree?
TIA
Zander






RE: Macro Features
The macro feature is the separete SolidWorks feature that reacts on several events such as rebuild and edit definition.
You can put the code for reading the equation and the suppressing the feature in the Regen function.
Please let me know if you need more assistance.
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: Macro Features
Thanks for the info. I'm curious, how does the macro feature actually get inserted into the feature tree? Does it happen the first time you run it?
Thanks,
RE: Macro Features
If you are using VBA macro feature you can embed it directly to model file so the link to initial macro file brokes.
Please refer the attached sample macro which creates a macro feature.
Please do not hesitate to contact me if you have any questions.
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: Macro Features
I've got it working in theory - but in the rebuild section I need to figure out how to pass the equation value into a macro variable.
Thanks,
RE: Macro Features
Thanks again.
RE: Macro Features
I've got everything working except for the actual suppresion. Does the macrofeature need to occur before the feature to be suppressed in the tree?
It seems like the last line of the if statement block:
bRet = swModel.EditSuppress2
Doesnt' error but doesn't suppress the selected feature.
Here is the block:
equation3 = swEqnMgr.Value(3)
If equation3 < 61 Then
Set swEditPart = swEditModel
Set swFeat = swPart.FeatureByName("MD1-left")
bRet = swFeat.Select2(False, 1)
bRet = swModel.EditSuppress2
End If
Any ideas?
RE: Macro Features
...
swFeat.SetSuppression2(swFeatureSuppressionAction_e.swSuppressFeature, swInConfigurationOpts_e.swAllConfiguration, Empty)
...
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: Macro Features
Everything is working, both suppress and unsupress depending on equation value. I dragged the macrofeature to before the feature being suppressed, but I don't know if I should have.
Also, when I changed the model and rebuild, the vba editor is invoked and the rebuild function is in 'step' mode. I don't know why though?
RE: Macro Features
Now I have one last question: If I want to alter the code of my macrofeature is this possible by using editdefinition? The canned stuff in the sample macro just creates a msgbox saying 'edit definition', but it would be cool if it could invoke the vba editor.
Thanks,
RE: Macro Features
If you would like to change the code of the macro feature. You shouldn't embed it to the model file so the link to .swb-file remains. If so you can open this macro in VBA-editor and alter the code.
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: Macro Features
Thanks - I didn't embed my macro (don't actually know how, although I read it can be done). Instead, I edit the source, delete the old feature and rerun.
What would trigger the edit definition section?
Zander
RE: Macro Features
The "Edit Feature" command calls this event. Please refer the attached picture.
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: Macro Features
RE: Macro Features
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com