This handler called when feature is being rebuilt (either when regenerate is invoked or when the parent elements have been changed).

Use MacroFeatureRebuildResult class to generate the required output.

Feature can generate the following output

  • None
    return MacroFeatureRebuildResult.FromStatus(true);
    
  • Rebuild Error
    return MacroFeatureRebuildResult.FromStatus(false, "Failed to regenerate this feature");
    
  • Solid or surface body
    return MacroFeatureRebuildResult.FromBody(tempBody); //return body without automatically assigning ids
    
  • Array of solid or surface bodies
    return MacroFeatureRebuildResult.FromBodies(tempBodies, featData, true); //return pattern of bodies and automatically assign entity ids
    

Use IModeler interface if feature needs to create new bodies. Only temp bodies can be returned from the regeneration method.

protected override MacroFeatureRebuildResult OnRebuild(ISldWorks app, IModelDoc2 model, IFeature feature, MyParameters parameters)
{
    var body = GenerateBodyFromParameters(parameters);
    return MacroFeatureRebuildResult.FromBody(body, feature.GetDefinition() as IMacroFeatureData);
}

Use extension methods available in the IModelerExtension class.