INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Selecting named selections in a loop

Selecting named selections in a loop

(OP)
I am trying a case of element death and Birth using EKILL and EALIVE in workbench
I have selected and using Named Selection named by 10 bodies at 1,2,3,4...
I have set the number of timesteps at 10
I want to use the following command to do the EKILL and EALIVE

! Commands inserted into this file will be executed just prior to the ANSYS SOLVE command.
! These commands may supersede command settings set by Workbench.

! Active UNIT system in Workbench when this object was created: Metric (m, kg, N, s, V, A)
! NOTE: Any data that requires units (such as mass) is assumed to be in the consistent solver unit system.
! See Solving Units in the help system for more information.

!Get current time step
*GET,ldstep,ACTIVE,,SOLU,NCMLS

!Time step as integer value (eg. 0.000000 to 0)
current_loadstep = NINT(ldstep)

!Store the timestep as a string/character
str1 = chrval(current_loadstep)

!at inital time step apply EKILL
*if,str1,EQ,'0',THEN

!allbody is a named selection consisting all the bodies
cmsel,s,allbody
EKILL, ALL
cmsel,all
allsel,all

!rest of the time steps select the named selection 1,2,3 etc.. and apply EALIVE
*else

cmsel,s,str1
EALIVE, ALL
cmsel,all
allsel,all

*endif


But I am getting error that

*GET LDSTEP FROM ACTI ITEM=SOLU NCML VALUE= 1.00000000

PARAMETER CURRENT_LOADSTEP = 1.000000000

PARAMETER STR1 = 1

*IF str1 ( = 1 ) EQ
0 ( = 0 ) THEN

*ELSE

SELECT COMPONENT 1

*** ERROR *** CP = 29.641 TIME= 15:32:34
Component 1 is not defined.


Is the problem associated with my named selections? (ie i cannot use number as named selections) Or is my selection command cmsel wrong?
if it is with named selections, how can I select my geometry one by one inside a loop?


RE: Selecting named selections in a loop

You could try out your script in Classic to confirm your script works before running it in Mechanical. That would help your troubleshooting efforts.

Quote (OP)

i cannot use number as named selections

True. Please see help document on CM.


Quote (OP)

how can I select my geometry one by one inside a loop?

Perhaps look into Substitution of Numeric Parametric Values to loop through the name selection of bodies that all start with an alphabet followed by looped number. For example, your bodies are named bod1, bod2, bod3 etc, you can select them via this code:

CODE --> APDL

*do,ct,1,3
   cmsel,s,bod%ct%
   % ~do something to component here~
*enddo 


Best regards,
Jason

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close