Jump to content
Divyanshu Bhardwaj

How to get circumferential grids by selecting a node using TCL

Recommended Posts

Hi,

I have a meshed cylinder (2d) on which i want to give an option to select a node to user. Once the node is selected, and clicked on proceed button it should display all the circumferential grids having a user defined number to the grids. Let's say i select a grid having ID as 122. Now, i want to display all the circumferential grid starting from 123 on the same station location where user has picked the node. I want to do it using TCL/ TK.

Thanks

Share this post


Link to post
Share on other sites

You said a cylinder so the nodes will be planar

You can select them by createmark "on plane"

You have to detect cylinder axis vector, with base node is selected one, will define a plane, as args of createmark

Share this post


Link to post
Share on other sites
1 hour ago, tinh said:

You said a cylinder so the nodes will be planar

You can select them by createmark "on plane"

You have to detect cylinder axis vector, with base node is selected one, will define a plane, as args of createmark

I think there is a bit of confusion here. Refer the image, as can be seen i have a node selected using "*createentitypanel node". Now, as the black circles shows circumferential node locations on the same axial station. I want to get their IDs as stated in the problem. Or just if i can get any info for all the nodes on that circumference. 

selected node.PNG

Share this post


Link to post
Share on other sites
7 minutes ago, tinh said:

Yeh. I do talk that

You can get ids by createmark "on plane"

Can you fetch axis vector of the cylinder?

I'm not sure about it. I'll need to try that. But how would you suggest the approaches if i can fetch the axis vector or if i can not fetch the axis vector?

Share this post


Link to post
Share on other sites

use hm_getsurfacenormal nodes $your_selected_nodeid

the node must be associated to surface.

if the node is not associated, use hm_getsurfacenormalatcoordinate

to find intersection points between normal vector and surf, use *nodecreateatplaneintersection

and to find mid node of 2 intersected nodes, use *createnodesbetweennodes

to find nodes closest to the mid node, use hm_getclosestnode

 

I think it is better to get it by *createmark "on plane"

like this:

*createmarkpanel nodes 1 "Pick a node on cylinder:"
set Node1 [hm_getmark nodes 1]
if {[hm_entityinfo exist nodes $Node1]} {
  set SurfId [hm_getentityvalue nodes $Node1 surfaceid 0]
  if {[hm_entityinfo exist surfs $SurfId]} {
    *createmark lines 1 "by surface" $SurfId
    foreach LineId [hm_getmark lines 1] {
        if {[hm_getlinetype]==2} {
          lassign [hm_getlinetgstartpoint $LineId] Vx Vy Vz
          eval *createmark nodes 1 {"on plane"} [expr [hm_nodevalue $Node1]] $Vx $Vy $Vz $Tolerance 1 1
          *createmark nodes 2 displayed
          *markintersection nodes 1 nodes 2
          if {[hm_marklength nodes 1]} {
            *numbersmark nodes 1 1
          }
          *clearmarkall 1; *clearmarkall 2; break
        }
    }
  }
}

 

mahes likes this

Share this post


Link to post
Share on other sites
On 9/19/2017 at 0:18 PM, tinh said:

use hm_getsurfacenormal nodes $your_selected_nodeid

the node must be associated to surface.

if the node is not associated, use hm_getsurfacenormalatcoordinate

to find intersection points between normal vector and surf, use *nodecreateatplaneintersection

and to find mid node of 2 intersected nodes, use *createnodesbetweennodes

to find nodes closest to the mid node, use hm_getclosestnode

 

I think it is better to get it by *createmark "on plane"

like this:


*createmarkpanel nodes 1 "Pick a node on cylinder:"
set Node1 [hm_getmark nodes 1]
if {[hm_entityinfo exist nodes $Node1]} {
  set SurfId [hm_getentityvalue nodes $Node1 surfaceid 0]
  if {[hm_entityinfo exist surfs $SurfId]} {
    *createmark lines 1 "by surface" $SurfId
    foreach LineId [hm_getmark lines 1] {
        if {[hm_getlinetype]==2} {
          lassign [hm_getlinetgstartpoint $LineId] Vx Vy Vz
          eval *createmark nodes 1 {"on plane"} [expr [hm_nodevalue $Node1]] $Vx $Vy $Vz $Tolerance 1 1
          *createmark nodes 2 displayed
          *markintersection nodes 1 nodes 2
          if {[hm_marklength nodes 1]} {
            *numbersmark nodes 1 1
          }
          *clearmarkall 1; *clearmarkall 2; break
        }
    }
  }
}

 

What if there are no surfaces and lines in the model. There are only elements and nodes. any suggestion?

Share this post


Link to post
Share on other sites

It is even easier,:rolleyes: from free edges, find elems "by adjacent" until selected elems contain $your_selected_node

Within each searching loop, save old nodes and subtract them at next search to get expected nodes 

Share this post


Link to post
Share on other sites
1 minute ago, tinh said:

It is even easier,:rolleyes: from free edges, find elems "by adjacent" until selected elems contain $your_selected_node

Within each searching loop, save old nodes and subtract them at next search to get expected nodes 

Can you please elaborate using code? i am unable to write the logic... 

Share this post


Link to post
Share on other sites

Like this

-select a node on comp

-find edges of comp

-turn off comp

-get edge elem list

-createmark 1 edge elem

-appendmark 1 by attached

-turn on comp

-loop:

    -createmark nodes by elem mark 1

    - check mark if contain selected node

           -markdifference nodes 1 nodes 2

           -return nodes in mark 1

     -else

           -createmark nodes 2 by elems in mark 1

            -append mark elems 1 by adjacent

-endloop

 

Is that enough logic?

 

 

Share this post


Link to post
Share on other sites
44 minutes ago, tinh said:

Like this

-select a node on comp

-find edges of comp

-turn off comp

-get edge elem list

-createmark 1 edge elem

-appendmark 1 by attached

-turn on comp

-loop:

    -createmark nodes by elem mark 1

    - check mark if contain selected node

           -markdifference nodes 1 nodes 2

           -return nodes in mark 1

     -else

           -createmark nodes 2 by elems in mark 1

            -append mark elems 1 by adjacent

-endloop

 

Is that enough logic?

 

 

What if the selected node is not on free edge? what if it's somewhere in the middle?

Share this post


Link to post
Share on other sites
17 hours ago, tinh said:

If it is in middle, the loop will find it

Hi Tinh,

Thanks for your help. I'll need a little different thing now as per change in requirement.

1. Before iterating i need to find, whether the node is created using Cartesian coordinates or cylindrical! 

a. If it's a cylindrical system, then i should follow the above approach and then define coincident grids.

b. else if it's Cartesian i need to define RBE elements.

 

Share this post


Link to post
Share on other sites
13 minutes ago, tinh said:

I don't understand.

See if i query for a selected node, i get the coordinates x,y,z. But i want to check if these nodes were created using cylindrical coordinate system (r,theta,Z)[local CSYS] or Cartesian (x,y,z) [global WCS]. and then if it is the second one, then do the above steps, means to select all circumferential grids.

Share this post


Link to post
Share on other sites
On 9/29/2017 at 2:54 PM, tinh said:

So you ought to ask "how to check input system type of a node"

You had node id, then:

set UseCartesian [expr ![hm_getentityvalue nodes $NodeId inputsystem.type 0]]

 

Yes exactly. Thanks for your help.

Share this post


Link to post
Share on other sites

Hi Tinh,

 

For the above discussion, if i want to get all the nodes in circumference where user will select a single node (having local r,t,z) values, how can i write the logic?

I tried this way,

1. Select a node, get r,t,z values.

2. Write a loop varying t value from 0 to 360, keeping r and z same and use *getclosestnode and pass these 3 values to get the node lying on these passed coordinates.

Problems: 1.  hm_getclosestnode doesn't give me the exact node for which the coordinates were passed. (Not sure which closest node it finds)

2. I don't have idea which API should i use to get all those circumferential grids.

 

Can you please help me resolving my issue, i am new to customization. It'll also be helpful if we need to write any other logic.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...