xarial / xcad

Framework for developing CAD applications for SOLIDWORKS, including add-ins, stand-alone applications, macro features, property manager pages, etc.
https://xcad.net
MIT License
126 stars 25 forks source link

Create Assembly Feature result in Exception: Preview context is not specified #112

Closed MJyee closed 9 months ago

MJyee commented 9 months ago

hi Im trying to make my feature be an assembly feature, the feature itself is just a measurement feature so it does not need to show any preview or generate any bodies, how do it fix this exception ?

artem1t commented 9 months ago

You can either create a base macro feature without the property page (you will need to manage it yourself, e.g. inherit SwMacroFeatureDefinition) or you can provide the preview context by overriding the ProvidePreviewContext method. But you are right, that preview context should not be called if there are no bodies, so I have changed this in the new version (please upgrade to the latest beta) so it will work without context unless you have preview bodies (in this case use the override method mentioned above to specify the context (e.g. component, by default it is using the editing component, but you can assign any component)

MJyee commented 9 months ago

Thanks for your help my macro now works in assemblies