Storing data (parameters, bodies, selection) in SOLIDWORKS macro feature

Edit ArticleEdit Article

Macro feature can store additional metadata and entities. The data includes

  • Parameters
  • Selections
  • Edit bodies
  • Dimensions

Required data can be defined within the macro feature data model. Special parameters (such as selections, edit bodies or dimensions) should be decorated with appropriate attributes, all other properties will be considered as parameters.

Data model is used both as input and output of macro feature. Parameters can be accessed via GetParameters method and also passed to OnRebuild handler. Parameters can be modified by calling the SetParameters method.

public class MacroFeatureParams
    // text metadata
    public string TextParameter { get; set; }
    // boolean metadata
    public bool ToggleParameter { get; set; }

    // any dependency selection
    public IFace2 FaceSelectionParameter { get; set; }

    // edit body - base body which macro feature is modifying
    public IBody2 InputBody { get; set; }

    // macro feature dimension. Value of the dimension will be sync with the proeprty
    public double LinearDimension { get; set; }

public class MyMacroFeature : MacroFeatureEx<MacroFeatureParams>

Product of Xarial Product of Xarial