Home Search

DriveWorks Solo 22
How To: Replace a Component With a Static or Driven Replacement Model

Send Feedback


DriveWorks has the ability to replace parts of an assembly with other parts or assemblies. These "replacement models" take two forms - static parts and assemblies, i.e. parts and assemblies which don't need driving, or driven parts and assemblies.

This topic covers both static and driven replacement models.

How it Works

After the file name rule of a model is calculated by DriveWorks , 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 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.

For this to work, both the original model, and any replacement models must have been created from the same model so that the unique identifiers given to the model and the geometry used in the mates are exactly the same.

It is considered a best practice to mate to reference geometry wherever possible to make replacing models easier.

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 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

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

Static replacement models are great for simple scenarios like handles, castors, and similar stock-components, however, DriveWorks also provides the ability to replace one model with another which is itself a driven model with its own rules.

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:

  • Add each possible replacement model to the Model Rules Screen as a component set by using the Add Component dialog
  • Add the main assembly to the Model Rules Screen (the main assembly must be the last in the tree)
  • Optionally, rename the component sets to give them easy-to-reference names.
  • Update the file name rule of the original model in the main assembly to refer to one of the possible replacements.
The move up/down buttons can be used to move the main assembly to the end of the component tree. This ensures that if any replacement models are required to be driven, they are driven before the main assembly.

An example of making use of replacement models is a door which can contain either a square or a round window. In each case, the window size is dependent on the size of the door, so static replacement models aren't enough.

In this case, the door is modeled with the square window in the door assembly, and the round window is captured separately.

The round window is added as a component set to the model rules screen, and its rules are built to drive its file name, and the size of the window.

The door (with the square window as a child) is added as a component set to the model rules screen. The door appears last in the component tree.

The rules for the square window are built to drive the size of the window, and its file name rule is changed from something like:


to something like:

=IF(RoundWindowOptionCheck=TRUE, "<Replace>Round Window", DWSpecificationId)

Which says that if the check box called RoundWindowOptionCheck is true, then instead of using the square window, DriveWorks should replace it with the component set called "Round Window", if it isn't, then a new square window is created instead.

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 replacement component set.