🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Using .tcl to automate assigning nodes/elements to sets without directly specifying IDs

User: "Autumn"
Altair Community Member
Updated by Autumn

Hello,

I am looking to create a .tcl script that simplifies importing geometry, meshing the geometry, and creating node/element sets. I already have a basic model template, but I will be creating quite a number of HM files with different geometries, so hopefully running the .tcl script can cut down on time spent manually importing, meshing, and creating node/element sets for BCs using that HM template.

I have made use of the command1.tcl file located in the Documents folder which records all of the commands in HM to help build my own .tcl script. However, I have run into the following issues:

1. The command for assigning elements to an output block:

*setvalue outputblocks id=4 ids={elems 9313-30840}
*startnotehistorystate {Updated "ids" of Outputblocks}
*endnotehistorystate {Updated "ids" of Outputblocks}

uses the IDs of elements directly. Since I will have different geometries with different meshes (leading to a different number of elements), I don't want the .tcl script to refer to anything fixed like this, which would require me to modify it for every new geometry (defeating the purpose of having my .tcl script).

Is there a way to avoid directly calling out the element IDs, say by using the command "displayed" or something else (I have already tried "...ids={elems "displayed"}..." with no luck)?

2. I want to assign nodes to certain sets based on where they fall on the geometry. This is quite easy to do manually for the geometry I have by selecting nodes "on plane" (e.g. y-axis and base point (0,0,0)), but the resulting line of code in command1.tcl:

*setvalue sets id=6 ids={nodes 14003 14122 14195 14283 14509-14511 14526-14527 14697 14712-14714 15017-15044 15750-15752 15782-15783 15987-16209}

does not show any of those specifications on how to select the nodes instead, listing them directly (which will not be transferable from one geometry to another for me, since the meshes will all differ slightly, with different node numbers for those nodes that I want in that specific set).

As with #1, is there a way to avoid directly calling out the node IDs instead, passing a command to assign the node IDs on a defined plane to the set?

Thus, is there a way to write the commands in the .tcl script which does not directly list element/node IDs so as to automate the importing, meshing, and set creation for many different geometries?

I have attached my .tcl script if required.

Thank you in advance for your suggestions and help.

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Ben Buchanan"
    Altair Employee
    Accepted Answer
    Updated by Ben Buchanan

    The command you are looking for is hm_createmark.  There are all kinds of options for selecting entities with this option including by displayed.

    The help file for hm_createmark is below but to short circuit what you are looking for here is an example.

    hm_createmark elements 1 "advanced" "displayed"

    set lst_elem_id [hm_getmark elements 1]

    In HW the mark is a "container" for selecting entities and there are 2 for each entity type 1 and 2.  So the first command is adding all the displayed elements to mark 1 and the second command retrieves the element ids in mark 1 and sets them to a variable named lst_elem_id.

    https://2021.help.altair.com/2021.2/hwdesktop/hwd/topics/reference/hm/hm_createmark.htm?zoom_highlight=hm_createmark