-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofiler.lsp
More file actions
304 lines (254 loc) · 9.21 KB
/
Copy pathprofiler.lsp
File metadata and controls
304 lines (254 loc) · 9.21 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
(defun makeText (textValue textX textY rotate)
(entmake ( list (cons 0 "text") (cons 7 "Standard") (cons 10 (list textX textY 0.0)) (cons 40 2.5) (cons 50 rotate) (cons 1 textValue)))
)
(defun endOfEnd(slopeList)
(setq resultLen (length slopeList))
(setq resultCounter 0)
(repeat resultLen
(setq checklast (+ resultCounter 1))
(setq heigh1V (cadr (nth resultCounter slopeList)))
(setq heigh2V (nth 2 (nth resultCounter slopeList)))
(setq x1Coord (nth 3 (nth resultCounter slopeList)))
(setq y1Coord (nth 4 (nth resultCounter slopeList)))
(setq distV (last (nth resultCounter slopeList)))
(setq x2Coord (+ (/ distV 5) x1Coord))
(setq baseY y1Coord) ; base height point for all result
(setq VERTICAL_OFFSET 20)
(setq SLOPE_HEIGHT 10)
(setq WORD_OFFSET 2)
(setq SCALE 5)
(setq SCALE_DISTANCE (/ distV SCALE))
(setq HEIGHT_VALUE_OFFSET (+ (+ VERTICAL_OFFSET SLOPE_HEIGHT) WORD_OFFSET))
(setq slopeValue (car (nth resultCounter slopeList)))
(setq slopeValueAbs (abs slopeValue))
; vertiacal line coordinates =======
(setq verticalLineX x1Coord)
(setq verticalLineYStart (+ baseY VERTICAL_OFFSET))
(setq verticalLineYEnd (+ verticalLineYStart SLOPE_HEIGHT))
(setq lastVerticalLineX (+ x1Coord SCALE_DISTANCE))
(entmake ( list (cons 0 "line") (cons 10 (list verticalLineX verticalLineYStart 0.0)) (cons 11 (list verticalLineX verticalLineYEnd 0.0))))
(if (= resultLen checklast)
(entmake ( list (cons 0 "line") (cons 10 (list lastVerticalLineX verticalLineYStart 0.0)) (cons 11 (list lastVerticalLineX verticalLineYEnd 0.0))))
)
; ==========
; ========== height value ==============
(setq heightValue1 (rtos heigh1V 2 2))
(setq heightValue2 (rtos heigh2V 2 3))
(setq heightValue1X x1Coord)
(setq heightValue2X (+ x1Coord SCALE_DISTANCE))
(setq heightValueY ( + baseY HEIGHT_VALUE_OFFSET))
(makeText heightValue1 heightValue1X heightValueY 1.5708)
(if (= resultLen checklast)
(makeText heightValue2 heightValue2X heightValueY 1.5708)
)
; ==============
; ======= slope value =========
(setq TOP_BOTTOM_OFFSET 6 )
(setq slopeValueX nil)
(setq slopeValueY (+ (+ baseY VERTICAL_OFFSET) TOP_BOTTOM_OFFSET))
(if (> heigh1V heigh2V)
(setq slopeValueX (- (+ x1Coord SCALE_DISTANCE) 6))
(setq slopeValueX (+ x1Coord WORD_OFFSET))
)
(if (= heigh1V heigh2V)
(setq slopeValueX ( - (+ x1Coord (/ SCALE_DISTANCE 2)) 1))
)
(makeText (rtos slopeValueAbs 2 2) slopeValueX slopeValueY 0)
; ================================
; ====== distance value ==========
(setq distanceValue distV)
(setq distX nil)
(setq distY (+ (+ baseY VERTICAL_OFFSET) WORD_OFFSET))
(if (> heigh1V heigh2V)
(setq distX (+ x1Coord WORD_OFFSET))
(setq distX (- (+ x1Coord SCALE_DISTANCE) 8))
)
(if (= heigh1V heigh2V)
(setq distX (- (+ x1Coord (/ SCALE_DISTANCE 2)) 3))
)
(makeText (rtos distanceValue 2 0) distX distY 0)
;=================================
; ========= slope line ==========
(setq startSlopeLineX x1Coord)
(setq endSlopeLineX (+ x1Coord SCALE_DISTANCE))
(setq startSlopeLineY nil)
(setq endSlopeLineY nil)
(if (> heigh1V heigh2V)
(progn
(setq startSlopeLineY (+ (+ baseY VERTICAL_OFFSET) SLOPE_HEIGHT))
(setq endSlopeLineY (+ baseY VERTICAL_OFFSET))
)
(progn
(setq startSlopeLineY (+ baseY VERTICAL_OFFSET))
(setq endSlopeLineY (+ (+ baseY VERTICAL_OFFSET) SLOPE_HEIGHT))
)
)
(if (= heigh1V heigh2V)
(progn
(setq startSlopeLineY (+ (+ baseY VERTICAL_OFFSET) (/ SLOPE_HEIGHT 2)))
(setq endSlopeLineY startSlopeLineY)
)
)
(entmake ( list (cons 0 "line") (cons 10 (list startSlopeLineX startSlopeLineY 0.0)) (cons 11 (list endSlopeLineX endSlopeLineY 0.0))))
; ==============================
(drawHelperHeight distV heigh1V slopeValue x1Coord (+ baseY HEIGHT_VALUE_OFFSET))
(setq resultCounter (+ resultCounter 1))
)
)
(defun recursia (slopeList yourLimit)
(setq finalRes slopeList)
(setq exitFromFun 0)
(setq count 0)
(setq secondCount 1)
(setq myLenght (length slopeList))
(setq ctrlP1 nil)
(setq ctrlP2 nil)
(if (/= myLenght 1)
(progn
(repeat myLenght
(setq slope1 (car (nth count slopeList)))
(setq slope2 (car (nth secondCount slopeList)))
(setq dis1Control (last (nth count slopeList)))
(setq dis2Control (last (nth secondCount slopeList)))
(if (< dis1Control 199)
(if slope2
(progn
(setq height1StartControl (cadr (nth count slopeList)))
(setq height2SEndControl (nth 2 (nth secondCount slopeList)))
(setq middleHeightControl (cadr (nth secondCount slopeList)))
(setq totalDistanceControl (+ dis1Control dis2Control))
(setq difList (list ))
(setq newSlopeControl (atof (rtos (* (/ (- height2SEndControl height1StartControl) totalDistanceControl ) 1000) 2 1)))
(setq controlHeight (atof (rtos (+ ( / (* newSlopeControl dis1Control) 1000) height1StartControl) 2 2)))
(if (> totalDistanceControl 201)
(progn
(setq stepsControl (fix (- (/ totalDistanceControl 100) 1)))
(setq startLenControl 100)
(setq newHeightVControl middleHeightControl)
(setq oldHeightVControl middleHeightControl)
(repeat stepsControl
(setq cmControl (/ newSlopeControl 10))
(setq oldcmControl (/ slope1 10))
(setq newHeightVControl (- cmControl newHeightVControl))
(setq oldHeightVControl (- oldcmControl oldHeightVControl))
(setq startLenControl (+ startLenControl 100))
(setq difList (append difList (list (abs(- newHeightVControl oldHeightVControl)))))
)
)
(progn
(setq difList (append difList (list (abs(- middleHeightControl controlHeight)))))
)
)
(setq maxDif (apply 'max difList))
(if (<= maxDif yourLimit)
(progn
(setq exitFromFun 1)
(setq ctrlP1 count)
(setq ctrlP2 secondCount)
)
)
(setq count (+ count 1))
(setq secondCount (+ secondCount 1))
)
)
)
)
(if (= exitFromFun 1)
(progn
(setq exitFromFun 0)
(setq height1Start (atof (rtos (cadr (nth ctrlP1 slopeList)) 2 2)))
(setq height2SEnd (atof (rtos (nth 2 (nth ctrlP2 slopeList)) 2 2)))
(setq x1 (nth 3 (nth ctrlP1 slopeList)))
(setq y1 (nth 4 (nth ctrlP1 slopeList)))
(setq dis1 (last (nth ctrlP1 slopeList)))
(setq dis2 (last (nth ctrlP2 slopeList)))
(setq totalDistance (+ dis1 dis2))
(setq newSlope (atof (rtos (* (/ (- height2SEnd height1Start) totalDistance ) 1000) 2 1)))
(setq newSlopeElement (list newSlope height1Start height2SEnd x1 y1 totalDistance))
(setq newSlopeList (list ))
(setq finalCount 0)
(repeat myLenght
(if (/= finalCount ctrlP2)
(progn
(if (= finalCount ctrlP1)
(progn
(setq newSlopeList (append newSlopeList (list newSlopeElement)))
)
(progn
(setq newSlopeList (append newSlopeList (list (nth finalCount slopeList))))
)
)
)
)
(setq finalCount (+ finalCount 1))
)
;;; (endOfEnd newSlopeList)
;;; (alert "NEW STEP")
(setq finalRes (recursia newSlopeList yourLimit))
)
(progn
finalRes
)))
(progn finalRes)))
(defun drawHelperHeight (len height slopeNew x y)
(if (> len 199)
(progn
(setq steps (fix (- (/ len 100) 1)))
(setq newHeightV height)
(setq startLen 100)
(repeat steps
(setq cm (/ slopeNew 10))
(setq newHeightV (+ cm newHeightV))
(setq newX (+ x (/ startLen 5)))
(makeText (rtos newHeightV 2 2) newX y 1.5708)
(setq startLen (+ startLen 100))
)
)
)
)
(defun compare-first (a b)
(< (car a) (car b))
)
(defun c:profiler ()
(setq result (list ))
(setq points (ssget (list(cons 0 "MTEXT"))))
(setq filteredList (list ))
(setq filterCount 0)
(setq count 0)
(setq secondCount 1)
(setq finalConter 0)
(repeat (sslength points)
(setq pointFilter(ssname points filterCount))
(setq pointFilterData (entget pointFilter))
(setq xFilter (car(cdr (assoc 10 pointFilterData))))
(setq heightValueFilter (cdr (assoc 1 pointFilterData)))
(setq filteredList (append filteredList (list (list xFilter pointFilter))))
(setq filterCount (+ filterCount 1))
)
(setq resultFilteredList (vl-sort filteredList 'compare-first))
(repeat (length resultFilteredList)
(setq firstPointName (cadr (nth count resultFilteredList)))
(setq secondPointName (cadr (nth secondCount resultFilteredList)))
(if secondPointName
(progn
(setq firstPointData (entget firstPointName))
(setq secondPointData (entget secondPointName))
(setq height1 (cdr (assoc 1 firstPointData)))
(setq height2 (cdr (assoc 1 secondPointData)))
(setq x1 (car(cdr (assoc 10 firstPointData))))
(setq y1 (cadr(cdr (assoc 10 firstPointData))))
(setq x2 (car(cdr (assoc 10 secondPointData))))
(setq pDis (* 5 (abs (- x1 x2))))
(setq num1 (atof height1))
(setq num2 (atof height2))
(setq slope (* (/ (- num2 num1) pDis) 1000))
(setq count (+ count 1))
(setq secondCount (+ secondCount 1))
(setq result (append result (list (list slope num1 num2 x1 y1 pDis))))
)
)
)
(setq yourLimit (/ (atof (itoa (getint "\n Press limit (cm):"))) 100))
(setq myFinalResult (recursia result yourLimit))
(endOfEnd myFinalResult)
)