solidworks-api icon indicating copy to clipboard operation
solidworks-api copied to clipboard

Can we wrap AccessSelections/ModifyDefinition?

Open brinkdinges opened this issue 3 years ago • 0 comments

The current method for changing feature definitions can be made more user-friendly. These are the current steps:

  1. Get the xFeatureData object from IFeature.GetDefinition
  2. Call AccessSelections on the FeatureData object. Pass the part object + null or assembly + component.
  3. Call any method or set any property that requires user selection
  4. 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

brinkdinges avatar Jan 02 '23 12:01 brinkdinges