[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
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
RE: [APDL] a simple macro
! 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
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
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
/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
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
/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