Working with the script of an object. Script Wizard
The first part of this article describes the process of creating a library object and connecting geometry to it. The created object has a basic script with basic functions, but so far it does not contain variables.
The script needs to be modified in accordance with the required functionality of the object. To simplify this task, let’s take the script of a similar library object.
As mentioned in the first part, the said article can be used as instructions for creating and managing parametric objects. The last part of the process is described here.
You need to download an object that will be used as the base object for this example by clicking on the Download the File for this article link at the beginning of the article.
You need to insert this object into the library first. To do this, in the Library, right-click on the Sample folder to open the context menu and select Import Object (Figure 1). An explorer opens, through which we browse to the downloaded file and click Open. The new object will be inserted.

In the Script menu of the ScriptMaster, select Get script from other object, in the Select object window that appears, open the Sample folder, and click on the Washer object (Figure 2).

The script for the new object will be updated (Figure 3).

The object that the script was copied from has a simpler geometry. Let’s bring this script in accordance with our object. Add parameters, and set new values.
To do this, select Script wizard in the Master menu and click Yes in the pop-up window that appears (Figure 4).

The General properties window opens. Adding and correcting information as shown in Figure 5. Click Next. In the Object Name field, enter the name of the object in the form in which it will be displayed in the library. The value in the Cover order (ZOrder) field controls the overlap of objects relative to each other in the assembly drawing.

In the Parameter Properties window, add the missing parameters and set their values. We modify the existing parameter values. For our example, let’s set the following values: b = 4; B = 6; D = 71.5; D1 = 0.75*D; d = 30; f = 1; l = 0
We make all parameters available for editing: select a parameter, click Changeable (available for editing) (Figure 6).

To add a parameter, enter a new name in the name field of an existing parameter and click the Add parameter button, and then enter the Initial value that will be assigned by default in the created parameter (Figure 7).

In the next step, we check the sequence of parameters. For the script to be executed correctly, the D parameter must be higher than D1, since the latter is set by the formula through the former. If necessary, use the arrow buttons to change the order of parameters (Figure 8).

At the next step, without changing anything, click Next (Figure 9).

Now we will add a description of the working planes – this will be necessary for superimposing dependencies between other components. Click the Add Plane button, set the OYZ orientation, and enable the Changeable (available for editing) option (Figure 10). Click Next.

We move forward through the next two steps without making any changes (Figure 11).

In the Checkboxes window, we check the variable Show object while inserting: this option must be enabled (Figure 12).

At the final step of the Script wizard, you can view the generated program script and, if necessary, return back to any of the previous steps to make changes.
Click OK and save the script (Figure 13).

Now you can check the operation of the new object. Save the changes made to the object and close the MechWizard. In the Standard part library, we find the created object (the Users folder). If it is not displayed, click Refresh on the toolbar. Click on the object and move the mouse pointer to the model space. Select the insertion point and direction. A window with parameters appears. In the Value field, you can change the value of any parameter. A view selection is available on the left side of the window. When you select a particular view, you can see its image in the preview window – this is very convenient when the object has many views.
Change the values of B to 4, and b to 2, and click OK. The washer geometry will change accordingly (Figure 14).

You can double-click on the object to return to the parameter editing mode, and then change the parameters again, but this is only useful if such changes are made very rarely. Given that the washer is one of the products that are constantly used in the machine-building design, and can have more than a dozen models, this option is not entirely acceptable. It is more appropriate to create additional models with new values, which will save you from unnecessary steps in the future.
This, as well as how to create and manage assembly dependencies, will be discussed in the next part.
Leave a Reply