Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting named selections in a loop

Status
Not open for further replies.

tsram90

Mechanical
Jun 6, 2010
3
0
0
IN
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?


 
Replies continue below

Recommended for you

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

OP said:
i cannot use number as named selections

True. Please see help document on [tt]CM[/tt].


OP said:
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:
*do,ct,1,3
   cmsel,s,bod%ct%
   % ~do something to component here~
*enddo


Best regards,
Jason
 
Status
Not open for further replies.
Back
Top