Collapse Getting StartedGetting Started
Expand Types of SolidWorks API ApplicationsTypes of SolidWorks API Applications
Expand SolidWorks API Object Model and Class HierarchySolidWorks API Object Model and Class Hierarchy
Collapse Programming with the SolidWorks APIProgramming with the SolidWorks API
Expand Add-insAdd-ins
API Dependent on SolidWorks Being Visible
Attributes Imported from ACIS SAT Files
Block Definitions and Block Instances
Bodies in Body Folders
Bounding Box and Note Text
COM vs. Dispatch
CommandManager and CommandGroups
Components, Configurations, and Suppression States
Compound Note
ComVisibleAttribute in VSTA macros
Controls, Visual Basic 6.0, and Windows XP
Expand Double Arrays and Integer PairsDouble Arrays and Integer Pairs
Drawing Views and Model Entities
Early and Late Binding
Expand EventsEvents
Features of Components
Helper Functions
Hole Wizard Features and Objects
IDispatch Object Arrays as Input in .NET
Implementation Guidelines
Import and Export File Options
In-process Methods
Instantiate ActiveX Controls as Tabs
Interface Pointers
Keystrokes and Accelerator Keys
Library Features and Objects
Lightweight Components
Line Attributes for View::GetPolyLinesAndCurves
Line Weights
Long vs. Integer
Collapse Macro FeaturesMacro Features
Collapse Creating Macro FeaturesCreating Macro Features
VBA Macro Files
Exposed COM DLL or Executable and Macro Features
Collapse Macro Feature FunctionsMacro Feature Functions
Edit Definition Function
Rebuild Function
Security Function
IMacroFeatureData Interface
Expand Inserting, Editing, and Removing Macro FeaturesInserting, Editing, and Removing Macro Features
Expand Programming with Macro FeaturesProgramming with Macro Features
Macro Features and Strong Name Versioning
Mass Properties
Expand Multibody PartsMultibody Parts
Option Explicit Statement
Partition Rollback and API Handles
Persistent Reference IDs
Presentation Transforms
Expand PropertyManager PagesPropertyManager Pages
.NET Interop Assemblies
Quick Tips and Bubble ToolTips
Return Values
Expand SafeArraysSafeArrays
Selection Criteria
Selection Lists
Selections that Define Features
Setup Project to Distribute SolidWorks Add-in
Smart Pointers
SolidWorks Objects
Sorting Tables
STL Container Classes and Smart Pointers
Suspend Automatic Rebuilds
swdisp.cpp and swdisp.h Files
System Options and Document Properties
Tessellation and Edges
Tracking IDs
Expand Type LibrariesType Libraries
VBA and SolidWorks x64
Unmanaged C+ and C++/CLI Code Differences
Examples and Projects
Expand SolidWorks API HelpSolidWorks API Help
Expand FeatureWorks API HelpFeatureWorks API Help
Expand SolidWorks Document Manager API HelpSolidWorks Document Manager API Help
Expand eDrawings API HelpeDrawings API Help
Expand SolidWorks Routing API HelpSolidWorks Routing API Help
Expand SolidWorks Simulation API HelpSolidWorks Simulation API Help
Expand SolidWorks Utilities API HelpSolidWorks Utilities API Help
Expand SolidWorks Workgroup PDM API HelpSolidWorks Workgroup PDM API Help
Hide Table of Contents

Rebuild Function

The rebuild function for a macro feature performs the real work. No new features can be introduced and no user interaction can occur during a rebuild of a model containing a macro feature.

There are three types of rebuild functions:





Interacts with the model, but does not modify existing geometry or create new geometry

  • Obtains the IMacroFeatureData object from the input IFeature object

  • Obtains the selections and parameters from the IMacroFeatureData object

  • Processes the inputs according to the design of the feature

  • Validates data based on the model

  • Updates external databases

Return values can be:

  • True, which indicates success

  • False, which indicates failure with no additional information

  • String, which is displayed in an error message to the user


Modifies one, and only one, input body

NOTE: The numbering scheme should be consistent and reproducible.

Return values can be:

  • True, which indicates success

  • False, which indicates failure and no additional information is provided

  • String, which is displayed in an error message to the user


Creates one output body

NOTE:  The numbering scheme should be consistent and reproducible.

The return values can be:

  • IBody2, the newly created body

  • False, which indicates failure and provides no additional information

  • String, which is displayed in an error message to the user

The rebuild function is called by SolidWorks whenever the macro feature is regenerated. The parametric information needed to regenerate the feature should be stored in the feature’s parameter and selection lists. These lists are created when the feature is inserted into the model and are available for reading and editing from the feature’s IMacroFeatureData interface. For example, the data stored in the parameters and selection lists can be used to perform low-level Boolean body operations to affect geometric features.

Because IBody2 objects created using the API do not always automatically assign IDs to their faces and edges, you should always check that there are no entity IDs that need to be assigned. Otherwise, any Boolean body operations involving that Body2 object will cause regeneration to fail. Use IMacroFeatureData::GetEntitiesNeedUserId  to check for the IDs. If the faces and edges arrays returned are both empty, then no user IDs are required. Otherwise, use IMacroFeatureData::SetFaceUserId and IMacroFeatureData::SetEdgeUserId to set the IDs of those entities.

The macro feature’s rebuild function is responsible for ensuring that the same IDs are always placed on the same entities each time the regeneration function is called. The order in which the entities are returned cannot be used. Instead, there should be some algorithm used that relies on the geometry of the body to determine entity IDs. Of course, features with no impact on the geometry of the model can also be created.

The following example illustrates a VBA-based rebuild function. When called, it returns TRUE to indicate to SolidWorks that it was successful.

Function swmRegen(app As Variant, part As Variant, feature As Variant) As Variant

msgbox "Regeneration function called."   




swmRegen = True

End Function

NOTE: When regenerating a macro feature, IDimension::ReferencePoints gets and sets the reference points of a display dimension (IDisplayDimension object).  In all other cases, this property gets and sets the reference points of a dimension (IDimension object).

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Rebuild Function
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2012 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.