solidworks-api
solidworks-api copied to clipboard
Can we wrap AccessSelections/ModifyDefinition?
The current method for changing feature definitions can be made more user-friendly. These are the current steps:
- Get the xFeatureData object from IFeature.GetDefinition
- Call AccessSelections on the FeatureData object. Pass the part object + null or assembly + component.
- Call any method or set any property that requires user selection
- Call IFeature.ModifyDefinition. Pass the part object + null or assembly + component.
The protocol is pretty straightforward, but can we make it more user-friendly? Some ideas:
- Create a big switch for every feature type, cast the FeatureData object to the correct type and call AccessSelections on that.
- Or make that call dynamic after a type check?
- Split modifying part features and assembly features so we have a method for each one
- Wrap it in a try-catch-finally block so we always call ModifyDefinition at the end