forked from bguest/ansys-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KPRLL.mac
131 lines (118 loc) · 3.08 KB
/
KPRLL.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
!KPRLL.mac
!B.GUEST: bagvoo@gmail.com
!DESCRIPTION: This macro projects a keypoint onto a
! straight line and then creates a line between the two
! keypoints.
!PRECONDITIONS:
! MUST USE ANSYS V.11
! ARG1 = Keypoint to be projected.
! ELSE Prompted to select keypoint
! ARG2 = Line for keypoint to be projected to
! ELSE prompted to select line
!POSTCONDITIONS:
! NewKP = # of new keypoint created
! NewLine = # of new line created between keypoints
!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
!_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
NumKP=1
KP1= $ *DIM,kp1,ARRAY,1
kp1(1)=ARG1
*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
*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
newKP= $ K,,xx,xy,xz $ newKp= _return !CREATE NEW KP
CMSEL,S,temp_KP !RESET DISPLAY KPs
KSEL,A,,,NewKP !ADD NEW KPs TO SELECTED SET
CM,temp_KP,KP !REFORM KP
LSEL,NONE
lstr,kp1(ink),NewKP $ newLine = _return !Create line between two keypoints
CMSEL,S,temp_LINE !RESET DISPLAY LINES
LSEL,A,,,NewLine !Add new line to selected set
CM,temp_LINE,LINE
*ENDDO
*enddo
!=======================CLEAN UP=========================
!--DELETE TEMPORARY COMPONENTS
CMDELE,temp_LINE
CMDELE,temp_KP
!--DELETE PARAMETERS
*SET,kp1
*SET,kp2
*SET,kp3
*SET,ax
*SET,ay
*SET,az
*Set,bx
*SET,by
*SET,bz
*SET,cx
*SET,cy
*SET,cx
*SET,ab
*set,ac
*set,bb
*set,bc
*set,cc_
*set,xx
*set,xy
*set,xz
*set,line1
*set,line2
!======THE--END========THE--END========THE--END=========
!ITS THE END OF THE MACRO AS WE KNOW IT, AND I FEEL FINE