Features Manager Tree automation using SOLIDWORKS API

Edit ArticleEdit Article

Automating features creation via API
Automating features creation via API

SOLIDWORKS API enables creation of features and automation of Feature Manager Tree via IFeatureManager interface which can be accessed via IModelDoc2::FeatureManager property.

Each individual feature can be created with different method. Please refer the SOLIDWORKS API help documentation for the list of methods. Alternatively you can record the macro while creating the feature to capture the required method.

It is also possible to extend the scope of standard SOLIDWORKS features by implementing custom macro feature. This will have the same look and feel as any standard feature and will allow to

  • Modify or add body
  • Add dependency features and regenerate the geometry as needed
  • Add dimensions
  • Store custom parameters

Feature is presented by IFeature SOLIDWORKS API interface. Feature has 2 extension objects:

  • Specific feature accessible via IFeature::GetSpecificFeature2 represents the collection of specific methods and properties for this feature (for example ISketch is a specific feature for 2D and 3D sketches).
  • Feature definition accessible via IFeature::GetDefinition represents the feature parameters (i.e. the ones controlled by the user via Property Manager Page). Modified feature parameters must be applied via IFeature::ModifyDefinition method.

Refer Identify Feature example for a helper method allowing to find the interface for feature definition and specific type.


Product of Xarial Product of Xarial