How to get circumferential grids by selecting a node using TCL

2»

Answers

  • tinh
    tinh Altair Community Member
    edited October 2017

    The reason is... you changed assumption :wacko:/emoticons/default_wacko.png' title=':wacko:' />

    I just give assumptions as mesh is a cylinder (you have multiple cylinders with different diameter), and mesh is quad only, equally (you give a mesh that not equally quad)

  • tinh
    tinh Altair Community Member
    edited October 2017

    If you posted above photos from starting, I would know that you have a variable tube mesh

    this proc will work with variable tube mesh (any quad-only tube mesh pattern generated by line drag)

    But it may not work if the tube has free edge or is shared nodes with other component!

    it must have 2 loops and isolated from other components!

     

     proc ::p_SelectCircumferentialNodes {{PreselectedNodeId {}}} { 	if {![hm_entityinfo exist nodes $PreselectedNodeId]} { 		*createmarkpanel nodes 1 'Pick a node on cylinder:' 		if {[hm_marklength nodes 1]!=1} return 		set PreselectedNodeId [hm_getmark nodes 1] 	} 	*createmark elems 1 'by node' $PreselectedNodeId 	*appendmark elems 1 'by attached' 	if {[catch {*findloops elems 1 0}]} { 		return -code error 'not valid cylinder' 	} 	if {![hm_entityinfo exist comps ^loops -byname]} { 		return -code error 'not valid cylinder' 	} 	hm_blockredraw 1; *entityhighlighting 0; hm_blockmessages 1 	*nameview 1 'p_SelectCircumferentialNodes' 	*saveviewmask '1' 0 	*displaynone 	*displaycollector comps on ^loops 1 1 	set LoopElems [hm_elemlist id ^loops] 	*createmark elems 1 [lindex $LoopElems 0] 	*appendmark elems 1 'by attached' 	set Loop1 [hm_getmark elems 1] 	*findmark elems 1 1 1 nodes 0 2 	if {[hm_checkmark nodes 2 $PreselectedNodeId]} { 		set Result [hm_getmark nodes 2] 	} else { 		*createmark nodes 1 'by comp name' ^loops 		*markdifference nodes 1 nodes 2 		if {[hm_checkmark nodes 1 $PreselectedNodeId]} { 			set Result [hm_getmark nodes 1] 		} else { 			*restoreviewmask '1' 0 			eval *createmark elems 1 $Loop1 			eval *createmark nodes 1 {'by elem'} $Loop1 			while 1 { 				*appendmark elems 1 'by adjacent' 				eval *createmark nodes 2 {'by elem'} [hm_getmark elems 1] 				if {[hm_checkmark nodes 2 $PreselectedNodeId]} { 					*markdifference nodes 2 nodes 1 					set Result [hm_getmark nodes 2] 					break 				} else { 					eval *appendmark nodes 1 [hm_getmark nodes 2] 				} 			} 		} 	} 	*clearmarkall 1;*clearmarkall 2 	*restoreviewmask '1' 0 	hm_blockredraw 0; *entityhighlighting 1; hm_blockmessages 0 	eval *createmark nodes 1 $Result 	hm_highlightmark nodes 1 h 	set Result }

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2017

    If you posted above photos from starting, I would know that you have a variable tube mesh

    this proc will work with variable tube mesh (any quad-only tube mesh pattern generated by line drag)

    But it may not work if the tube has free edge or is shared nodes with other component!

    it must have 2 loops and isolated from other components!

     

      proc ::p_SelectCircumferentialNodes {{PreselectedNodeId {}}} { 	if {![hm_entityinfo exist nodes $PreselectedNodeId]} { 		*createmarkpanel nodes 1 'Pick a node on cylinder:' 		if {[hm_marklength nodes 1]!=1} return 		set PreselectedNodeId [hm_getmark nodes 1] 	} 	*createmark elems 1 'by node' $PreselectedNodeId 	*appendmark elems 1 'by attached' 	if {[catch {*findloops elems 1 0}]} { 		return -code error 'not valid cylinder' 	} 	if {![hm_entityinfo exist comps ^loops -byname]} { 		return -code error 'not valid cylinder' 	} 	hm_blockredraw 1; *entityhighlighting 0; hm_blockmessages 1 	*nameview 1 'p_SelectCircumferentialNodes' 	*saveviewmask '1' 0 	*displaynone 	*displaycollector comps on ^loops 1 1 	set LoopElems [hm_elemlist id ^loops] 	*createmark elems 1 [lindex $LoopElems 0] 	*appendmark elems 1 'by attached' 	set Loop1 [hm_getmark elems 1] 	*findmark elems 1 1 1 nodes 0 2 	if {[hm_checkmark nodes 2 $PreselectedNodeId]} { 		set Result [hm_getmark nodes 2] 	} else { 		*createmark nodes 1 'by comp name' ^loops 		*markdifference nodes 1 nodes 2 		if {[hm_checkmark nodes 1 $PreselectedNodeId]} { 			set Result [hm_getmark nodes 1] 		} else { 			*restoreviewmask '1' 0 			eval *createmark elems 1 $Loop1 			eval *createmark nodes 1 {'by elem'} $Loop1 			while 1 { 				*appendmark elems 1 'by adjacent' 				eval *createmark nodes 2 {'by elem'} [hm_getmark elems 1] 				if {[hm_checkmark nodes 2 $PreselectedNodeId]} { 					*markdifference nodes 2 nodes 1 					set Result [hm_getmark nodes 2] 					break 				} else { 					eval *appendmark nodes 1 [hm_getmark nodes 2] 				} 			} 		} 	} 	*clearmarkall 1;*clearmarkall 2 	*restoreviewmask '1' 0 	hm_blockredraw 0; *entityhighlighting 1; hm_blockmessages 0 	eval *createmark nodes 1 $Result 	hm_highlightmark nodes 1 h 	set Result }

     

    Hey Tinh, 

     

    Thanks for your valuable response. It works perfectly for even different components. :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />

     

    I have one thing to ask, how can i modify this code for including axial as well as radial tolerance.

     

     

  • tinh
    tinh Altair Community Member
    edited October 2017

    Forget tolerances. Above proc work with any axial or radial tolerance

     

     

    But it may be slower than the fisrt proc

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2017

    Forget tolerances. Above proc work with any axial or radial tolerance

     

     

    But it may be slower than the fisrt proc

    yeah but actually i have to put two options for user just in case there are two set of rings on the same axial location (Example a flange on the edge)

    if user selected option 1, it should give me both the rings

    or if 2, then only single.

    Apart from that, if we have some elements perpendicular to the cylinder elements, based on radial tol. i want to control the selection.

     

     

  • tinh
    tinh Altair Community Member
    edited October 2017

    Do it your self based on my proc

    Dont ask everything

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2017

    Do it your self based on my proc

    Dont ask everything

    I'm trying myself wanted to get a suggestion. Thanks for your help.