Duplicate Document Appearance
Will duplicate the given appearance in the DriveWorks 3D Document displayed in the given 3D Preview control.
The appearance being duplicated must exist in the DriveWorks 3D Document displayed in the given 3D Preview control.
The task will duplicate an appearance with the name specified in the task.
This task avoids the need to overload the scene with every required appearance.
This task works on a 3D Document displayed in a 3D Preview Control.
In order to save changes made by this task the Save 3D Document task is required to be used.
We recommend applying the Save 3D Document task at the end of a Specification.
This task does not work on 3D Previews running in File mode or Autopilot mode.
Properties
| Property Name | Description |
|---|
| Preview Control Name | Name of the 3D Preview control. |
| Source Appearance Name | The name of the appearance to duplicate. |
| Target Appearance Name | The name of the destination appearance. |
| Overwrite | TRUE to replace an existing appearance (if one exists). |
Examples
| Property Name | Example Rule | Meaning |
|---|
| Preview Control Name | 3DPreviewControl | Will duplicate the decal from the DriveWorks 3D document displayed in the 3D Preview control named 3DPreviewControl. |
| Source Appearance Name | Plastic | Will duplicate the existing appearance named Plastic. |
| Target Appearance Name | PlasticNew | Will name the duplicated appearance PlasticNew. |
| Overwrite | True | Will replace an existing appearance named PlasticNew, if one exists.
If set to False and an existing appearance exists the source appearance will not be duplicated. |
Control Appearance Properties in the Duplicated Appearance
Appearance properties (Color, Texture, etc.) can be controlled by applying dynamic rules in the Appearance being duplicated.
The address of the property can be obtained using the function MyName.
When an appearance is duplicated only the new name is updated in the address.
For example the address of the Diffuse Color property will be:
3DDocumentName\Appearances\AppearanceName\Diffuse\Color
Where:
- 3DDocumentName is the name given to the DriveWorks 3D Document being displayed in a 3D Preview control and in which the task is being run. This value does not change.
- \Appearances is the address of the folder where all appearances are added. This value does not change.
- \Appearance Name is the name given to the appearance. This value changes to the result of the Target Appearance Name in the task.
- \Diffuse\Color is the address of the appearance property being driven. This value will only change when a different property is being driven.
The address can be used to search a table to obtain the required property value.
To simplify the table the last three parts of the address can be obtained by using the function MyName(-3).
Example to control the diffuse color of a duplicated appearance
- Create an appearance, that will be duplicated, in the 3D Document.
- Right click the Appearances folder and select Add Appearance.
- Enter the name Red for the appearance name (this name must exist in the table created in step B).
- Highlight the Red appearance and in the Information Panel set the Diffuse Color Red value to 255, Green to 0 and Blue to 0.
- Create a table containing an Address, Color and Color Hex Value columns.
- In the Define Tables task, click Add.
- Select Simple Table and enter the name Colors.
- Select all values from the table below, right click Copy, select cell A1 in the table editor and Paste.
| Address | Color | Color Hex Value |
|---|
| Red\Diffuse\Color | Red | #FF0000 |
| Blue\Diffuse\Color | Blue | #0000FF |
| Yellow\Diffuse\Color | Yellow | #FFFF00 |
| Black\Diffuse\Color | Black | #000000 |
| Green\Diffuse\Color | Green | #008000 |
- Click OK in the table editor.
- Apply a rule to the Diffuse Color parameter of the appearance created in the 3D Document.
- Return to the 3D Document and select (check the box) the Red appearance to display the parameters in the Parameter Panel.
- Double click the Diffuse Color parameter to open the Rule Builder.
- Build the following rule:
VLookup(MyName(-3),DwLookupColors,3)
This will lookup the last three parts of the appearance address, in the Colors table and return the result from the third column (the Hex value).
When the appearance is duplicated the rule will update to return the hex value for the name of the duplicated appearance.
- Create a user form to display the 3D Document and choose a color to be duplicated.
- Go to Form Design, and add the following controls:
- 3D Preview Box name this PreviewAppearance
- Combo Box name this Color
- Select the 3D Preview Box and in the property Preview Document Name select the 3D Document the appearance was added to (in step A above).
- Create a macro to run the Duplicate Document Appearance task.
- Go to Specification Macros and click Add.
- Enter the name DuplicateAppearance, click OK.
- From the toolbox double click the 3D task Duplicate Document Appearance to add it to the macro.
- Connect the Start node to the task.
- In the Preview Control Name property select the PreviewAppearance control (created in step D above).
- In the Source Appearance Name property enter Red
This is the source appearance added in step A above.
- In the Target Appearance Name property, make it dynamic and build a rule to link it to the Color Combo Box (added in step D above).
- Run the macro on the On Change event of the control that chooses the color.
- Go back to Form Design and select the Combo Box, locate the On Change Event property and select the DuplicateAppearance macro (added in step 2)
- Select the Items property and build a rule that lists all the colors (column 2) from the Colors table (added in step B above).
ListAll(DwLookupColors,2)
- See the task working.
- Start a new specification from Specification Explorer (macros can only run in a specification)
- Change the color from the Combo Box added to the user form.
- Click Test Mode from the command bar of Specification Explorer.
- Click the 3D Previews tab and select the Active 3D preview control from the list.
Note the color selected in the specification has now been duplicated in the Appearances folder of the 3D Document.
Using the Task in a Specification Macro
This task has different types of Outputs. For more information about Outputs see Specification Macros Task Node.
Outputs are only available within Specification Macros.
Status Outputs
This task supports Status Outputs.
These can be used to perform different actions depending on what the status outcome of the task is. For more information see Status Outputs.
The status output navigation is as follows:
Success
Success with Warnings
- N/A - Should never be fulfilled
Failed
- Unable to find a 3D Preview Control with the name <control name>.
- Unable to delete the appearance, the Preview Control must be previewing a 3D Document.
- Unable to find the source appearance with the name <appearance name>.
- The target appearance name <appearance name> is invalid. A valid name should be provided for the new appearance.
- An appearance with the name <appearance name> already exists. Appearance names must be unique.