Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Automatic naming of components

Status
Not open for further replies.

slumdogengineer

Mechanical
Jan 23, 2009
35
Hi all,

I am wondering if anyone knows how to automatically named components in a *do loop?

For example, say you have a number of areas, and each area is meshed with shells. What I want to do is, inside a *do loop, automatically select the nodes from each area, then name it "areanodes1" for area 1, "areanodes2" for area 2 and so on. The code would look something like this:

*do,areanumber,1,20 !Cycle through 20 areas
asel,,,,areanumber !Select area
nsla !Select nodes from area
cm,areanodes#1#,node !Make component from nodes
*enddo

You can see that what I want to do, is subsitute the loop number in the name of the component (where I have put the # signs), so that I end up with areanodes1, areanodes2 etc.

Does anyone know how to do this, or indeed if it is possible?

Many thanks,
Will
 
Replies continue below

Recommended for you

I don't have Ansys open at the moment to test it, but I think the command would be (using the variable name in your example):

cm,areanodes%areanumbner%,node !Make component from nodes
 
Thanks, but I just tried that and it doesn't work. From what I can glean, enclosing a parameter name in % signs prevents the substitution of the parameter, so you would end up with the variable name there instead of the number. In any case, in the example you showed, when I run the file it defines each component as 'areanodes%areanumber%', ie no substitution occurs at all. It seems then that the % signs are only recognised if they occur at the start of the command field, otherwise they are interpreted as part of the command name.

Anyway, I have found a work-around, which is to define a character array with all the component names in it (time-consuming unfortunately), then take the component names from it in the do loop by referencing the appropriate index of the array. Not a very elegant solution, so if anyone has any better idea please let me know!!

Cheers,
will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor