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!

using loop to assign sections to line 1

Status
Not open for further replies.

ph47reey

Structural
May 26, 2015
7
0
0
DE
Hello fellow ansys-enthusiasts :)


I need help about loop (*do function).

let say I have a set of lines sorted in ascending number (example: line 101, 102, 107, 108, 112, 117 and so on) and I want to assign the lines with sections (sectype and secdata already defined beforehand), which also sorted in ascending number (example secnum 201, 202, 203 and so on)

how do I write the loop command in APDL? I already got it how to select lines and do the loop but I don't get it yet with the section assigning:

*get,LCOUNT,lines,,count

LINENEXT=lsnext(0)

*do,ICOUNT,1,LCOUNT
LINENEXT=lsnext(LINENEXT)
! ???-->this line should contain command to assign sections incrementally? How could I do that?
lmesh,LINENEXT
*enddo

I thank you very much for tips and helps!
 
 http://files.engineering.com/getfile.aspx?folder=c4988f8d-0e5d-4328-bec2-8429016290bd&file=lines.JPG
Replies continue below

Recommended for you

use this command for section assignment.
LATT, MAT, REAL, TYPE, --, KB, KE, SECNUM

probably you should do
*get,LCOUNT,lines,,count
LINENEXT=0
*do,ICOUNT,1,LCOUNT
linenext=lsnext(linenext)
lsel, s, line, , linenext
LATT, MAT, REAL, TYPE, --, KB, KE, SECNUM
!lesize
lmesh,LINENEXT
*enddo
 
hey Stanum, thanks for your reply!

I've tried it, it worked with the section-assigning using LATT command. however all the selected lines are meshed with only one sectionnumber. Whereas my goal is to actually assign an ascending order of sectionnumber to an ascending order of linenumbers.

so without the loop, the command lines would be manually executed like this:

secnum,201
lmesh,211

secnum,202
lmesh,212

secnum,203
lmesh,213

secnum,204
lmesh,214

and so on and so on...

I think one way to solve it is to parametrize the sectionnumbers, so that a parameter containing incrementing sectionnumber would be inside the loop. how could I do that? is there any way I could select the next higher sectionnumber? (like it does with 'lsnext'?)


*get,LCOUNT,lines,,count
LINENEXT=0
*do,ICOUNT,1,LCOUNT
LINENEXT=lsnext(LINENEXT)
!lsel,s,line,,linenext --> this command can be omitted, because I've already selected the lines to be assigned with section beforehand.
LATT,1,,5,,,,201
!mat=1,real=not needed,type=5,,kb?,ke?,secnum=201
!lesize
lmesh,LINENEXT
*enddo

much thanks for your help again!
 
 http://files.engineering.com/getfile.aspx?folder=ff9c99c4-f3b3-4bf5-b185-ca775f85b247&file=lines2.JPG
If the numbers go as you say then: just
Sec_num=lsnext-10
And use this parameter
You can also try this:
Create an array
With line numbers in first column and section numbers in second row.
Then just use array(parameters as an input for commands inside a *do loop.

Are you sure that lsnext selects line also since in the help it is only stated that it returns the next highest number in the selected set?

Kb and ke serve as a starting and ending key points for section assignment, together with the orientation key point you assign when creating section.

If your sections go in as sending order but their numbers do not necessary match the numbers of lines then
Sec_num=200+Icount

This requires that the line with the lowest number corresponds to the lowest cross section number defined and there are no gaps in crossections numbering.

But I really suppose that creating an array beforehand is more reliable options, it is probably a little bit more computationally intense and time consuming but unless you are working with something like 100k crossections it won't be a noticeable decline in productivity.
 
thank you again Stanum for your reply :)

regarding the lsnext command, as far I know and tried myself, lsnext(n)-command also selects the line with next higher number than 'n' within currently selected lines. which lines are being currently selected can be manually checked with llist and/or visually with lplot command.

Having the "lsel,s,line,,linenext"-command after the "linenext=lsnext(linenext)"-command causes the list of selected active lines to contain only one line, which is the "linenext". when the loop starts over, it causes error because the list now contains only one line and it is already meshed (I actually got error message when I tried to execute your code, stating that the line is already meshed)

I see, well fortunately there are no gaps within my sectionnumbers, only within the linenumbers. Should it be that there are gaps within the numbering of crosssections, the only solution is to create array? Or do you happen to have another idea?

I do not know how to create array yet, I'll look up to it soon. Thank you again!
 
yes you are right. I forgot alls command before the *enddo statement.

Should it be that there are gaps within the numbering of crosssections, the only solution is to create array? Or do you happen to have another idea?
Probably not but it depends on many factors that are present in your model.
Numbers are very unreliable in general, since if you would like to use your code in a different model you can not be sure that the numbering goes they way you want it to.

Arrays are created by the *dim command

*dim, array_name, Array, L_count, 2!!! array = array type (array, table etc); L_count - column length= amount of rows (for your case amount af lines); 2 - amount of columns (for your case 2= 1(line numbers)+1(crossesction coresponding to them)
Then you have to fill it with values. The way you can do this is usually a *do loop oк something similar, but it totally depends on the way you receive and input the data.
 
Status
Not open for further replies.
Back
Top