Home Search

DriveWorks Pro 24
Duplicate Document Appearance

Send Feedback

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 NameDescription
Preview Control NameName of the 3D Preview control.
Source Appearance NameThe name of the appearance to duplicate.
Target Appearance NameThe name of the destination appearance.
OverwriteTRUE to replace an existing appearance (if one exists).

Examples

Property NameExample RuleMeaning
Preview Control Name3DPreviewControlWill duplicate the decal from the DriveWorks 3D document displayed in the 3D Preview control named 3DPreviewControl.
Source Appearance NamePlasticWill duplicate the existing appearance named Plastic.
Target Appearance NamePlasticNewWill name the duplicated appearance PlasticNew.
OverwriteTrueWill 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

  1. Create an appearance, that will be duplicated, in the 3D Document.
    1. Right click the Appearances folder and select Add Appearance.
    2. Enter the name Red for the appearance name (this name must exist in the table created in step B).
    3. Highlight the Red appearance and in the Information Panel set the Diffuse Color Red value to 255, Green to 0 and Blue to 0.
  2. Create a table containing an Address, Color and Color Hex Value columns.
    1. In the Define Tables task, click Add.
    2. Select Simple Table and enter the name Colors.
    3. Select all values from the table below, right click Copy, select cell A1 in the table editor and Paste.
      AddressColorColor Hex Value
      Red\Diffuse\ColorRed#FF0000
      Blue\Diffuse\ColorBlue#0000FF
      Yellow\Diffuse\ColorYellow#FFFF00
      Black\Diffuse\ColorBlack#000000
      Green\Diffuse\ColorGreen#008000
    4. Click OK in the table editor.
  3. Apply a rule to the Diffuse Color parameter of the appearance created in the 3D Document.
    1. Return to the 3D Document and select (check the box) the Red appearance to display the parameters in the Parameter Panel.
    2. Double click the Diffuse Color parameter to open the Rule Builder.
    3. 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.

  4. Create a user form to display the 3D Document and choose a color to be duplicated.
    1. Go to Form Design, and add the following controls:
      • 3D Preview Box name this PreviewAppearance
      • Combo Box name this Color
    2. 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).
  5. Create a macro to run the Duplicate Document Appearance task.
    1. Go to Specification Macros and click Add.
    2. Enter the name DuplicateAppearance, click OK.
    3. From the toolbox double click the 3D task Duplicate Document Appearance to add it to the macro.
    4. Connect the Start node to the task.
    5. In the Preview Control Name property select the PreviewAppearance control (created in step D above).
    6. In the Source Appearance Name property enter Red

      This is the source appearance added in step A above.

    7. 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).
  6. Run the macro on the On Change event of the control that chooses the color.
    1. 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)
    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)

  7. See the task working.
    1. Start a new specification from Specification Explorer (macros can only run in a specification)
    2. Change the color from the Combo Box added to the user form.
    3. Click Test Mode from the command bar of Specification Explorer.
    4. 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

  • Task ran successfully.

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.