-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathKPRL.mac
108 lines (96 loc) · 2.74 KB
/
KPRL.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
!KPRL.mac
!B.GUEST: [email protected]
!DESCRIPTION: This macro projects a keypoint onto a
! straight line.
!PRECONDITIONS:
! USING ANSYS V.11
! ARG1 = Keypoint to be projected.
! ELSE Prompted to select keypoint
! ARG2 = Lines for keypoints to be projected to
! ELSE prompted to select lines
! ARG3 = Keypont number of point created
!POSTCONDITIONS: Keypoint is created on line projected
! from selected key point
!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
_save
/PREP7
!------------------SAVE CURRENT SETUP
CM,temp_LINE,LINE
CM,temp_KP,KP
!------------------SELECT KEYPOINTS
*IF,ARG1,EQ,0,THEN
*MSG,UI
SELECT KEYPOINTS
KSEL,R,P !SELECT KEYPOINTS
*GET,NumKP,KP,0,COUNT !Get Number of KPs
KP1= $ *VGET,kp1,KP,,KLIST !V11.0 Get selected Keypoints
CMSEL,S,temp_KP
*ELSE
KP1= $ *DIM,kp1,ARRAY,1
kp1(1)=ARG1
NumKP=1
*ENDIF
!------------------SELECT LINEs
*IF,ARG2,EQ,0,THEN
*MSG,UI
SELECT LINES
LSEL,R,P
*GET,NumLine,Line,0,COUNT !Get Numbetr of lines
line1 = $ *vget,line1,line,,LLIST,
CMSEL,S,temp_LINE
*ELSE
line1 = $ *dim,line1,array,1
line1(1)=arg2
numLine=1
*ENDIF
!Get Keypoints at ends of lines
KP2 = $ *dim,KP2,array,numLine
KP3 = $ *dim,KP3,array,numLine
*do,i,1,numLine,
*GET,KP2(i),LINE,Line1(i),KP,1 !GET KP AT ONE END
*GET,KP3(i),LINE,Line1(i),KP,2 !GET KP AT OTHER END
*enddo
*IF,ARG3,EQ,0,THEN !----------------------OUT KP
kpOut = ' '
*ELSE
kpOut = ARG3
*ENDIF
*do,lineIdx,1,numLine
*DO,ink,1,NumKP
!------------------GET LOCATIONS OF KP
*GET,aX,KP,KP1(ink),LOC,X !KP1 location
*GET,aY,KP,KP1(ink),LOC,Y
*GET,aZ,KP,KP1(ink),LOC,Z
*GET,bX,KP,KP2(lineIdx),LOC,X !KP2 location
*GET,bY,KP,KP2(lineIdx),LOC,Y
*GET,bZ,KP,KP2(lineIdx),LOC,Z
*GET,cX,KP,KP3(lineIdx),LOC,X !KP3 location
*GET,cY,KP,KP3(lineIdx),LOC,Y
*GET,cZ,KP,KP3(lineIdx),LOC,Z
!-------------------CALCULATE R
ab=ax*bx+ay*by+az*bz !a.b
ac=ax*cx+ay*cy+az*cz !a.c
bb=bx*bx+by*by+bz*bz !b.b
bc=bx*cx+by*cy+bz*cz !b.c
cc_=cx*cx+cy*cy+cz*cz !c.c
r=(-ab+bc+ac-cc_)/(-bb+2*bc-cc_)
!calculate location of new KP
xx=cx+r*(bx-cx)
xy=cy+r*(by-cy)
xz=cz+r*(bz-cz)
KSEL,NONE
K,kpOut,xx,xy,xz !CREATE NEW KP
*GET,NewKP,KP,,NUM,MAX !GET NEW KP NUMBER
CMSEL,S,temp_KP !RESET DISPLAY
KSEL,A,,,NewKP !ADD NEW KP TO SELECTED SET
CM,temp_KP,KP !REFORM KP
*ENDDO
*enddo
!=======================CLEAN UP=========================
!--DELETE TEMPORARY COMPONENTS
line1 = $
CMDELE,temp_LINE
CMDELE,temp_KP
!======THE--END========THE--END========THE--END=========
!ITS THE END OF THE MACRO AS WE KNOW IT, AND I FEEL FINE