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

Students Click Here

[APDL] a simple macro

[APDL] a simple macro

[APDL] a simple macro

(OP)
Hi,
I want to define a simple macro to extract the number of line between two given kp numbers,e.g.
kp1=2
kp2=5

if exist: the number of line between KP#1 and KP#5 is 7 (for example)
 if does not exist: There is no line between KP#1 and KP#5 is 7

Is there anyone that can give me some clue on this?
TIA
Replies continue below

Recommended for you

RE: [APDL] a simple macro

Hi,

! Find the below macro
/prep7
Allsel,all
ksel,r,kp,,2
lslk,r
ksel,a,kp,,5
ksel,u,kp,,2
lslk,r
lplot
finish




 

RE: [APDL] a simple macro

(OP)
but how can I make it parametric? like every time the user can give different numbers for KPs? In other words, we can use *ask command to get the KP numbers first and then the macro checks whether we have any line between these two KPs or not, if so it gives the line number if not it gives the message "there is no line between KP #kp1 and KP #kp2

even I think it is better we the macro first checks KP numbers too, what if the user enters wrong KP number which they don't even exist?

RE: [APDL] a simple macro

Hi,

Copy the below contents, paste it in a text pad and save it.

Then from File->read input-> from the above mentioned saved text file

You can add the *ask commands as required by you....

! Copy from Here
/prep7
k,1,
k,2,100
k,3,,50
k,4,,100
k,5,100,50
k,6,100,100
l,1,2
l,1,3
l,2,5
l,3,4
l,3,5
l,5,6
l,4,6

Allsel,all
ksel,r,kp,,3
lslk,r
ksel,a,kp,,5
ksel,u,kp,,3
lslk,r
lplot
*get,l_count,line,,count

*if,l_count,gt,1,then
*msg,ui
Multiple lines selected
*elseif,l_count,eq,1,then
*msg,ui
Only one line selected
*else
*msg,ui
No line selected
*endif
 

RE: [APDL] a simple macro

(OP)
I created that, the only problem is that I cannot print the number of line (lnum), I don't know where my mistake is:

/prep7
*ask,kp1
*ask,kp2

ksel,s,kp,,kp1
ksel,a,kp,,kp2
lslk,s,1
*get,l_count,line,,count

*if,l_count,gt,1,then
*msg,ui,kp1,kp2
Multiple lines are between KP #%I and KP #%i

*elseif,l_count,eq,1,then
*get,lnum,line,0,num,max
*msg,ui,kp1,kp2,lnum
The only line between KP #%I and KP #%i is line # %lnum

*else
*msg,ui,kp1,kp2
There is no line between KP #%i and KP #%i
*endif

 

RE: [APDL] a simple macro

All of the above is too difficult.


ksel,s,,,kp1
ksel,a,,,kp2
lslk,s,1
lll=lsnext(0)


lll will be the number of the line, or 0 if there is none.

RE: [APDL] a simple macro

(OP)
thanks elogesh and structur71, here is the final version:


/prep7
*ask,kp1
*ask,kp2
chk1=ksel(kp1)
chk2=ksel(kp2)

*if,chk1,eq,0,or,chk2,eq,0,then
  *msg,ui
  One or both of entered key points do not exist.
*else
  ksel,s,kp,,kp1
  ksel,a,kp,,kp2
  lslk,s,1
  lnum=lsnext(0)
  *if,lnum,eq,0,then
    *msg,ui,kp1,kp2
    There is no line between KP #%i and KP #%i
  *else
    *msg,ui,kp1,kp2,lnum
    The line between KP #%I and KP #%i is line #%i
  *endif
*endif




 

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! Already a Member? Login



News


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