Insert Script Execution Example

The following example explains how to generate a design variant with script. This function is currently not fully available.

The starting point for the variant is two flanges from two sheet parts. One flange is to be added to each so that the two flanges touch in a surface and can be bolted. The two flanges are added so that they lie in the angle bisector between the two initial flanges.

Step 1: Construction

(see Example of a Design Variant in Sheet Metal Processing)

 

Step 2: Parameterise 1st Part

The parameters of the design variant need to be defined as variables for the design variant base body:

Activate the base sheet and choose the Formula for processed part function. Enter the part_of_edge(edge1) formula or part_of_edge(edge2) for the 2nd base sheet.

 

Step 3: Insert new Script execution feature step

It is possible to insert into the feature list a Visual Basic Script (VBS) in which you have access to the variables of the calculated part, can calculate values using the resources of Basic and a COM interface to HiCAD and can assign variables. You can then use these variables in the formulas of subsequent features.

The script is inserted before the feature in whose context menu you are located.

Script Description

In VBS, objects made available by a COM server need to be created with 'CreateObject'.

'MakeCurrentVars' provides access to the variables of the part that has just been calculated.

'MakeVariantVars': A design variant creates a design variant feature in all parts of the drawing that are being processed or created. These features work on a common data record to which, for example, the parameter variables of the variant, and only these parameter variables, belong. The variant variables allow you to note information for calculating other parts when calculating one part.

The scripts in the two parts differ only at this point.

Here, edge objects are generated for the two parameter edges of the variant and assigned variable values.

 

 

 

Determining the top flange facet belonging to the edge in the current part

An object of type 'Sheet' represents a flange with a marked facet which is produced on the edge specified during construction of the object.

Determining the top flange facet belonging to the edge in the other part:

If the other part has already been calculated, the edge to which the flange is added in the other part is no longer available. You then take the top facet of the other flange from the variant variables, where it was saved when the script of the other part was executed.

 

 

You can now calculate the angle between the facets

 

The shortening is calculated from sheet thickness and bend radius and the angle between the sheets. Note that VBS works with angles in radians.

 

Calculation of the data for the screw assembly:

The calculation must be performed before adding, as the edge whose length is needed will otherwise no longer be available.

 

Setting the variables in HiCAD.

You can simply copy the script for the second part and swap the two strings "1" and "2" at the beginning.

You can edit the script of a script feature by double-clicking the feature.

Please keep in mind, at this point, the Advice on Part Variables and Log Variables

 

Step 4: Fitting the Variant

Once the variants have been fitted, the two sheet parts each have a design variant feature.

Design Variants

© Copyright 1994-2018, ISD Software und Systeme GmbH
Version 2302 - HiCAD Feature Technology
Date: 14/09/2018

> Feedback on this topic