Hello,
hope somoen can help with this topic which looks like simple but is making me crazy...
I'm trying to write a TCL script to create, from a set of three nodes (which should be selected by the user, let's call them Node_1, Node_2, Node_3):
- 1 PLOTEL from Node_1 to Node_2
- 1 PLOTEL from Node_1 to Node_3
- 1 PLOTEL from Node_1 to a new one (Node_4) which should be created by the macro itself, on a (ideal) line passing through Node_1 and orthogonal to the plane defined by Node_1 + Node_2 + Node_3
I'm quite new to tcl, so I started from having a look around on the web and some trial and error by looking at the command.cmf file.
Here is what I am at:
#set nodeList [hm_getmark nodes 1]
*createlistpanel nodes 1 'Select the ordered nodes'
set nodeList [hm_getlist nodes 1]
set Node_1 [lindex $nodeList 0]
set Node_2 [lindex $nodeList 1]
set Node_3 [lindex $nodeList 2]
*createspotweld $Node_1 $Node_2 0 0 0 0 0 2 '';
*createspotweld $Node_1 $Node_3 0 0 0 0 0 2 '';
So far I've created the first two PLOTEL belonging to the Node_1 + Node_2 + Node_3 plane.
Now I should try to understand which is the normal direction. I tried to look at the command.cmf script for similar functions (i.e., when translating nodes and selecting three nodes to define the direction) but to my surprise I discovered that Hypermesh someway computes the components of the normal and uses them.
It is not such a big effort, it is a matter of computing a vectorial product and its components.
Let a1, a2, a3 be the components of the first vector (From Node_1 to Node_2) and b1, b2, b3 the components of the second one (from Node_2 to Node_3)
The components of the normal vector will be:
x_n=a2b3-a3b2
y_n=a1b3-a3b1
z_n=a1b2-a2b1
Once I have the components above I should create the new Node_4 by translating Node_1 along the normal vector.
Could you please help me with the rest of the program?
Thanks in advance
Alex