TCL scripts for importing nodes and elements from csv files

JZ_21971
JZ_21971 New Altair Community Member
edited April 2021 in Community Q&A

Hi guys! I am a new Hyperworks user and have some basic questions. Now I have 3 csv files and I want to import/read them and build a FEM model based on them. Here is an example.

node.csv stores the node coordinates. 

0,0,0        

1,0,0         

2,0,0         

3,0,0         

0,1,0         

1,1,0        

2,1,0         

0,2,0        

1,2,0     

0,3,0      

quad.csv stores the node numbers for quadrilateral elements.

1,2,6,5

2,3,7,6

8,5,6,9

tri.csv stores the node numbers for triangular elements.

3,4,7

10,8,9

9,6,7

The attached image shows the model built in Ansys including 3 quad elements and 3 tri elements. I believe it can be done by simple TCL scripts in Hyperworks but I totally got lost when I read the coding tutorial. Can anyone help me with this? Thanks in advance. 

image

Best Answer

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2021 Answer ✓

    Some ideas to make a script:

    • Read node.csv & create nodes with the command "*createnode"
    • Read quad.csv & tri.csv and create elements with the command "*createelement"

    Here's my "Proof of concept": put 3 CSV files + script in the same directory & run macro. See attached zip file.

     

Answers

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2021

    A simple script (in any language) to read CSV files and output to HMASCII format is doable. You can import HMASCII into Hypermesh later.

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2021

    Here's my program to test under Windows console: (in attachment)

    Import "output.hmascii" into Hypermesh:

    image

     

     

  • JZ_21971
    JZ_21971 New Altair Community Member
    edited April 2021

    Here's my program to test under Windows console: (in attachment)

    Import "output.hmascii" into Hypermesh:

    image

     

     

    Thanks for your prompt response! Unfortunately I'm using the student version Hyperworks. It won't allow me to import *.HMASCII files. Your program can be helpful for those doing a similar job with full license.

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2021 Answer ✓

    Some ideas to make a script:

    • Read node.csv & create nodes with the command "*createnode"
    • Read quad.csv & tri.csv and create elements with the command "*createelement"

    Here's my "Proof of concept": put 3 CSV files + script in the same directory & run macro. See attached zip file.

     

  • JZ_21971
    JZ_21971 New Altair Community Member
    edited April 2021

    Some ideas to make a script:

    • Read node.csv & create nodes with the command "*createnode"
    • Read quad.csv & tri.csv and create elements with the command "*createelement"

    Here's my "Proof of concept": put 3 CSV files + script in the same directory & run macro. See attached zip file.

     

    Thank you! I successfully made a TCL script with *createnode and *createelement.