Storing data (parameters, bodies, selection) in SOLIDWORKS macro feature
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
[ParameterSelection]
public IFace2 FaceSelectionParameter { get; set; }
// edit body - base body which macro feature is modifying
[ParameterEditBody]
public IBody2 InputBody { get; set; }
// macro feature dimension. Value of the dimension will be sync with the proeprty
[ParameterDimension(swDimensionType_e.swLinearDimension)]
public double LinearDimension { get; set; }
}
[ComVisible(true)]
public class MyMacroFeature : MacroFeatureEx<MacroFeatureParams>
{
}