Home Search

DriveWorks Pro 22
How To: Replace a Component With a Static or Driven Replacement Model (KB13103014)

Send Feedback


DriveWorks Pro has the ability to replace parts of an assembly with other parts or assemblies. These replacement models take two forms

  • Static parts and assemblies - parts and assemblies that don't change.
  • Driven parts and assemblies - parts and assemblies that do change.

This topic covers both static and driven replacement models.

How it Works

After the file name rule of a model is calculated by DriveWorks Pro, the result is checked to see if the model should be replaced with a different model. If the result of the rule indicates that the model should be replaced, then DriveWorks Pro asks SOLIDWORKS to make the replacement in a similar way to if you used the "Replace Components" menu item in SOLIDWORKS.

The benefit of this approach is that if you swap in a model with the same geometry that was used to mate in the original model, then SOLIDWORKS will silently reattach all of the mates to the new component.

Creating Replacement Models

Replacement models are required to have identical internal id's as the model they are replacing.

This is achieved by using a copy of the original model as a basis for creating the replacements from.

To avoid any mate reference errors avoid mating the model using faces.

Use reference geometry (planes, axis, etc.) to mate the original model.

When creating the replacement model do not delete any reference geometry used to mate the original component.

Static Replacement Models

There are two methods available for making use of static replacement models:

  1. Capture Method - Capture the models as replacement models to the model they can replace.
  2. <ReplaceFile>Method - Use the <ReplaceFile> command with the location and file name of an existing model.

Capture Method

Using this method means that DriveWorks knows where the model to be inserted is located, so the relative path parameter, of the model to be replaced, is bypassed. It also means that the file name parameter of the model to be replaced just needs to match the name of the model included as a replacement model.

To use static replacement models, in SOLIDWORKS, open the captured model that you want to replace with one or more other models. Switch to the  Replacement Models section of the DriveWorks Pro Capture Explorer, and browse for the models you want to be able to use as replacements.

Parts can only be replaced with other parts, and assemblies with other assemblies.

Note, that when the replacement models are added, the name column in the replacement models list shows the file name of the replacement model without its extension, we use this name to control which replacement model to use.

Now that DriveWorks Pro knows about the replacement model(s), the file name rule of the original part needs to be modified to choose which replacement model to use.

So, for example, given three possible types of handle:

  • Shaker Handle.sldprt
  • Knob Handle.sldprt
  • D Handle.sldprt

If the file rule was calculated as "Shaker Handle" then DriveWorks Pro would replace the original part in its parent assembly with the "Shaker Handle" part file.


The user form has a control, named HandleTypes, that lists the available handle types.

The available types are Shaker, Knob and D Type. The SOLIDWORKS replacement parts are named Shaker Handle, Knob Handle and D Handle respectively.

The following rule is built on the File Name parameter for the part that has these models captured as replacement files.

= IF(HandleTypesReturn="Shaker","Shaker Handle",IF(HandleTypesReturn="Knob","Knob Handle","D Handle"))

<ReplaceFile> Method

With the <ReplaceFile> method a component does not require to be captured.

This method is ideal when models that can replace an existing captured model are constantly being manually created. Files that are created manually do not require to be captured as replacement models each time one is created.

If thought is given to the location and name of the manually created models the rule may not need to change.

Parts can only be replaced with other parts, and assemblies with other assemblies.

In the Model Rules for the component to be replaced build a rule for the File Name parameter using the <ReplaceFile> command as follows:

"<ReplaceFile>C:\DriveWorksPro\Models\ReplacementFiles\Pull Handle.sldprt"

The full file path along with the name and file extension of the model should be included after the <ReplaceFile> command

When running a specification that uses this method in Test Mode, the replacement files will be marked as being an Alternative. This is not an indication that the file actually exists, care must be taken that the file that is replacing does exist when a specification is generated.

If the replacing file does not exist, or the rule does not correctly locate the file, the model generation report for the assembly that is a direct parent of where the replacing takes place will display One of the sub-assemblies in the file '<assembly name> could not be found - the class of the error message in the report will be a Generating Model\Rereferencing.

DriveWorks will swap the file with a reference to the replacing model and suppress the component. Once the replacing file is created the assembly can be opened and modified to display the replacing model.


The user form has a control, named HandleTypes, that lists the available handle types. Another control allows the user to select a color.

The available types are Shaker Handle, Knob Handle and D Type Handle. The SOLIDWORKS replacement parts are named identical to the options available,with the available colors appended to the file name, and are stored in C:\DriveWorks\Models\Handles.

For example the file Shaker Handle Blue.sldprt exists in that location

The following rule is built on the File Name parameter for the part that is to be replaced with these models.

="<ReplaceFile>C:\DriveWorks\Models\Handles\" & HandleTypesReturn & " " & ColorReturn & ".sldprt"

When a new handle type is created the new file needs to be stored in C:\DriveWorks\Models\Handles and the option updated to include the new handle type.

Driven Replacement Models

DriveWorks Pro also provides the ability to replace one model with another which is itself a driven model with its own rules.

A replacement model that is to be driven requires capturing in SOLIDWORKS just like the main model driven by your project.

The easiest way to use driven replacement models is to use a "<Replace>" rule which is the method described by this topic.

The steps involved in setting up Driven Replacement Models are:

  • Capture the driven replacement model or models, and the driving parameters, in SOLIDWORKS.
  • Add each possible driven replacement model to the Model Rules task as a component set by using the Add Component dialog.
  • Arrange the generation order.
  • Update the file name rule of the model to be replaced in the main assembly to refer to one of the possible replacements.

Capture the Model to be a Driven Replacement.

Capture the driven replacement model by adding it to the required group in the SOLIDWORKS Task Pane. See Captured Models for more information.

Next capture all of the driving parameters and any associated drawings. See the section Capture Parameters from the Model for more information.

Add the Model to the Model Rules.

Next add the captured driven replacement model to the Model Rules task. See the section To Add a Model to Drive for more information.

Arrange the Generation Order.

Generation order is determined by the order the models appear in the Model Rules list. Ensure the driven replacement models are higher in the Model Rules list than the Main Model they could replace.

To re-order the models:

  1. Highlight the model in the model rules list.
  2. Use the Move Up or Move Down commands from the command bar to move the model up or down the list.
  3. Top level items in this list will be generated in the order they appear, first in the list will be generated first.

    This ensures that any replacement models required to be driven are driven before the main part they will replace.

Update the File Name Rule for the Model to be Replaced.

The File Name rule is now required to consider if a driven replacement file is needed and, if so, the name of the component that will replace the main file.

Using the Model Rules list shown in the image below:

We can see that the component Cupboard RightDoor Shaker Style is the Main Model driven by the project.

Cupboard RightDoor Framed and Cupboard RightDoor are driven replacement models.

The image below is from the user form, this drives the choices for the door types.

This image allows us to match up the choices made on the user form with the components that could be replaced into the model.

  • Flat - Driven replacement required, use Cupboard RightDoor.
  • Shaker - No replacement required, use Main Model.
  • Glass - Driven Replacement required, use Cupboard RightDoor Framed.

So the File Name rule of the Main Model component (Cupboard RightDoor Shaker Style) will be:

=IF(DoorStyleReturn="Flat", "<Replace>Cupboard RightDoor", IF(DoorStyleReturn="Glass", "<Replace>Cupboard RightDoor Framed", DWSpecification))

This rule will:

  • Replace the models generated from the component set Cupboard RightDoor when Flat is selected from the DoorStyle control.
  • Replace the models generated from the component set Cupboard RightDoor Framed when Glass is selected from the DoorStyle control.
  • Use the Main Model components and name them based on the special variable DWSpecification when Shaker is selected from the DoorStyle control.

DriveWorks will know the result of the File Name rule for the driven replacement model and will automatically use that when required.

To make the "<Replace>" syntax even easier, the Rules Builder automatically detects when you are building a file name rule and a browser appears on the right hand side which allows you to just double click on the available components.

DriveWorks Quick Tips

DriveWorks Quick Tips: Replace Feature

Let’s say you have an assembly for a dresser that can have two different doors. You don’t really want to make two different DriveWorks projects for the same assembly, you would rather just have DriveWorks replace the door for you. Now if only there was a video explaining how it could be done…

DriveWorks Quick Tips are a series of 1 minute videos, available on YouTube, that explain specific functionality. View all Quick Tips

Knowledge Base Article Ref:KB13103014