Fill in values for User Name, Part Number, Description or Material automatically and dynamically.

Fill in values for User Name, Part Number, Description or Material automatically and dynamically.
Emil Rindell

Emil Rindell

Jonas Bryntesson

Jonas Bryntesson

Henrik Andersson

Henrik Andersson

2022-11-21

5 min read
Emil Rindell

Emil Rindell

Jonas Bryntesson

Jonas Bryntesson

Henrik Andersson

Henrik Andersson

2022-11-21

5 min read

Code Generator allows you to automatically generate and assign names, numbers and/or descriptions according to variables related to the model. This means that if, for example, you retrieve the length of a beam, the thickness of a plate, the length of a 3D curve and want to use these values as User Name, Part Number or Description, all this and much more can be done with this tool.

How to use the Code Generator

Start by going to the ICM Tools directory, scroll down until you find Code Generator.

Drag and drop the function on the party you want to configure.

Code Generator IRONCAD

In the top left corner, there are four icons to load and save a configuration (1), save set rules (2), set current rules as default (3) and delete any predefined settings (4).

Place the cursor in the field(User Name, Part Number, Description or Material) where you want to display a new variable. The variable must be placed within "greater than" and "less than" characters, like this:

Code Generator IRONCAD ICM Tools

There are two tabs on the bottom half of the tool window:

CustomData is used to create and manage values under the party CustomData (own unique party properties).

Variables defines the variables to be used for a CustomData, User Name, Part Number, Description or Material.

CustomData and Variables

CustomData tab

Defines the values handled as CustomData for the party and how to generate them.

Name - Name to be assigned to CustomData.

Expression - Rule to define the value to be assigned to CustomData.

Value - Value generated by the rule and placed in CustomData.

custom data IRONCAD

Variable tab

Variable - The unique name to be assigned to the variable. Use an abbreviation, e.g. WKG to read weight in kilograms (Weight KiloGram).

Get from - A long list of options where to get the value from.

Name - The name/device name of the data to be loaded.

  • The length, width and height of the sizebox are given by default as L, W and H.
  • For a parameter value, enter the name of that parameter.
  • For weight, enter the unit kg, g, lb, oz

Dec - The number of decimal places.

Len. - length of the field (-1 undefined). 3 gives three digits, even if the value has more digits.

Fill Chr - "fill character" if Len.> 1 and value is missing. "0" as fill gives "002" for value "02".

Value - Result of the function. Always displayed in the rightmost column.

Get from Code Generator

Variable type Get this value Alternative name
CustomData Value The value from Custom Data The name of the CustomData contained in the part
User Name Name of the part
Sizebox Height of Element Total height of the part
Sizebox Length of Element Total length of the part SM_Unfold returns the L dimension of the bent plate
Sizebox Width of Element The overall width of the part SM_Unfold returns the W dimension of the bent plate
Thickness of SheetMetal Plate thickness
Weight of Element part weight Type of unit kg, g, lb, oz
Weight of Element in Water Weight of the part in water Type of unit kg, g, lb, oz
Parameter Value Name of parameter The name of the parameter found on the part
Volume of Element Part volume
Shell Feature Thickness of the "shelled" part
Thickness of IPROSteel Thickness of beams having this characteristic
Code of SheetMetal Plate code value
Part Number Part number
Description Title
Sweep Path or Extrusion Section Length Length of the guide curve in one sweep (2D or 3D)
3D Curve Length The length of a 3D curve
Document Properties Community value The name of the properties contained in the file
Element Surface Surface area of all surfaces on the part
Global Position X X-value of the absolute position
Global Position Y Y-value of the absolute position
Global Position Z Z-value of the absolute position
Longest Value of Sizebox The longest value (among L W H) in Sizebox
Number of Items Number of linked parts (both internal and external)

Examples of how the Code Generator can be used

Plate dimensions and material code

Below is an example of how we can display sheet metal dimensions in the history tree and under the sheet metal part properties, which allows us to make it appear in the BOM. If the size of the plate is changed, the corresponding values in the properties are updated directly.

1) Pull out and drop the Code Generator on a plate.

2) Choose to open an existing configuration file (*.cod).

3) Select the file Sheet_LxWxT.cod

4) Click on Open.

Now the sheet dimensions and material code are automatically retrieved and can be displayed anywhere, e.g. the name in the tree or the 2D drawing BOM etc.

A look at Part Properties shows that current values have been loaded.

Total length of the guide curve from a sweep shape

Here is a simple example of the total length of a guide curve from a Sweep Shape.

First, we pull out and release the Code Generator from the ICM Tools catalog on our part.

1) Variable - As a variable we write SWL, please keep it short and simple. SWL is short for Sweep Length.

2) Get From - Select from where to read the value. In this case Sweep Path or Extrusion Section Length

3) Specifies where to display the SWL variable. Don't forget "greater than" and "less than". Here, for simplicity, it is placed at User Name.

4) Implement.

Nu ser vi att längden från partens Sweep Shape visas som en del av partens namn i historieträdet. Hade vi valt att lägga <SWL> även under Part Number och/eller Description så hade detta värde även visats i en BOM.

Sweep length BOM

Code Generator is available in the add-on program IronCAD Mechanical which is included when you have an active support contract.

Do you not have an agreement? Please contact us at info@solidmakarna.se or 08-556 - 185 40.

>