×
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!
  • Students Click Here

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

Students Click Here

Jobs

Automatic naming of components

Automatic naming of components

Automatic naming of components

(OP)
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

RE: Automatic naming of components

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

RE: Automatic naming of components

(OP)
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

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