Jump to content
Chong

About *createmark

Recommended Posts

Dear All,

I have a question about *createmark. I think this question may be fundamental but since I am new to tcl/tk scripting language, I really need some help with this.

Assume I have chosen a set of nodes by using tcl command as follows:

*createmark nodes 1 "on plane" 0.5 0 0 1 0 0 .0001 1 1

# choose all nodes in that plane

For example in hypermesh it came out with *createmark nodes 1 1-40 121 134

Is there a way that I can select the first and second nodes (1 and 2) inside this mark that I just created and store them into a new mark? I know we can select by choosing them by hand but what I need is a macro that can handle multiple different models so I need to select them using this order.

Share this post


Link to post
Share on other sites

Hi All,

I have to select a surface, but I can't use the surface ID. is there a way to select a surface that is X mm far from a specific point?

Where can I found a manual or a reference guide for the tcl language?

 

Thanks,

Enrico

Share this post


Link to post
Share on other sites
On 4/5/2019 at 11:27 PM, Enrico said:

Hi All,

I have to select a surface, but I can't use the surface ID. is there a way to select a surface that is X mm far from a specific point?

Where can I found a manual or a reference guide for the tcl language?

 

Thanks,

Enrico

Consider the plane X mm from your point and mark the surfaces on that plane.

Share this post


Link to post
Share on other sites

Hi Forum,

 

I am trying to select elements based on their element normal.

I have a user selected element and I want to select the elements with same normal as the one which user has selected.

Is there any option to do that in HM??

 

Thanks

Akash 

Share this post


Link to post
Share on other sites

Here's my script (tested only with SHELL elements) to select elements based on normal of one element. The tolerance will be applied at angle comparing.

# Tested only with SHELL elements
# Reference element
*createmarkpanel  elems 1 "Select Elem"
set elist [hm_getmark elems 1]
hm_markclear elems 1
set eid_ref [lindex $elist 0]
set nx0 [hm_getvalue elems id=$eid_ref dataname=normalx]
set ny0 [hm_getvalue elems id=$eid_ref dataname=normaly]
set nz0 [hm_getvalue elems id=$eid_ref dataname=normalz]
set v0 [list $nx0 $ny0 $nz0]

# Tolerance for normal comparing, in deg
set tolerance 17.0;

# Select all displayed elements
hm_createmark elems 1 "advanced" "displayed"
set elist [hm_getmark elems 1]
hm_markclear elems 1

#------------------------------------------------------------------------
set selectedElems [list]
foreach eid $elist {
	set nx [hm_getvalue elems id=$eid dataname=normalx]
	set ny [hm_getvalue elems id=$eid dataname=normaly]
	set nz [hm_getvalue elems id=$eid dataname=normalz]
	set v1 [list $nx $ny $nz]
	set angle [::hwat::math::AngleBetweenVectors  $v1 $v0]
	if { $angle <= $tolerance } {
		lappend selectedElems $eid
	}
}

eval *createmark elems 2 "$selectedElems";
set elist [hm_getmark elems 2]
puts "Selected E: $elist"

 

Share this post


Link to post
Share on other sites

If 'foreach' loops through element list taking long time, we can make a template code like this

# 1. Get sample element:
*createmarkpanel elems 1 "Pick an element:"
set eid [lindex [hm_getmark elems 1] 0]
if {[llength $eid]} {
	# 2. Get sample normal:
	set nx [hm_getvalue elems id=$eid dataname=normalx]
	set ny [hm_getvalue elems id=$eid dataname=normaly]
	set nz [hm_getvalue elems id=$eid dataname=normalz]
	# 3. Prepare a template code:
	set tplCode {
		*elements(103,,,)
		*format()
			*uservariableset(#nx,normalx)
			*uservariableset(#ny,normaly)
			*uservariableset(#nz,normalz)
			*uservariableset(#angle,[57.295779513082195*@acos(#nx*$nx + #ny*$ny + #nz*$nz)])
			*if([#angle <= $tolerance])
				*markfailed()
			*endif()
		*output()
		*elements(104,,,)
		*format()
			*uservariableset(#nx,normalx)
			*uservariableset(#ny,normaly)
			*uservariableset(#nz,normalz)
			*uservariableset(#angle,[57.295779513082195*@acos(#nx*$nx + #ny*$ny + #nz*$nz)])
			*if([#angle <= $tolerance])
				*markfailed()
			*endif()
		*output()
	}
	# 4. Run the template code:
	set tolerance 5; #degrees
	set tplCode [string map [list \$nx $nx \$ny $ny \$nz $nz \$tolerance $tolerance] $tplCode]
	set fpt [open mark_elems_by_normal.tpl w]
	puts $fpt $tplCode
	close $fpt
        hm_answernext yes
	*usercheck mark_elems_by_normal.tpl mark_elems_by_normal.out 0 ;# only displayed elems
	#*usercheck mark_elems_by_normal.tpl mark_elems_by_normal.out 1 ;# include non-displayed elems
	hm_highlightmark elems 2 h
	set elist [hm_getmark elems 2]
	puts "[hm_marklength elems 2] elems have normal ~ ($nx,$ny,$nz) within +/-$tolerance degrees"
}

 

Q.Nguyen-Dai likes this

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...