kapat 发表于 2022-7-6 06:16:59

好吧,这真让我受不了。(简单

你好这整件事几乎都是我自己写的。我知道可能有50种方法可以用更少的代码编写它。我在以自己的速度学习,用我能阅读的方式写作。因此,下面的代码基本上适用于将管道连接到平面的包装器模板。
 
唯一的问题是:当你为OD输入“6”时。“6.00001”作品和5.99999作品以及我输入的每一个其他数字作品。12和3很好。
 
我只是想知道为什么。其他一切都很好。
 
任何帮助都是多学一点的好方法。谢谢大家!
 
;;PIPE2FLAT
;; draws layout of wrapper template
;; with inside AND outside diameter.
;; Onlys Askes for OD, and refers to standard pipe schedules for the rest.
;; D = Diameter
;; A = Angel
;; R = Radians
;; doesn't work with an OD of 6. I have no idea why. It works with 6.0000001 or 5.9999999. So, don't ask me.

(defun dtr (a)
;; i told you not to delete this.
(* pi (/ a 180.00))
;; stop it.
)

(defun c:PIPE2FLAT ()

(setq D1 (getreal "Enter OD of Pipe, Please"))
(setq A1 (getreal "Enter Angle"))
(setq D1H (/ D1 2))
(setq R1 (dtr A1))

(setq SINR (sin R1))
(setq COSR (cos R1))
(setq TAN1 (/ SINR COSR))
(setq H1 (+ (* TAN1 D1) 3))

(setq PT1 (list 0 0))
(setq PT2 (list D1 0))
(setq PT3 (list D1H 0))
(setq PT4 (list D1 3))
(setq PT5 (list 0 H1))
(setq PT6 (list 0 3))

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT1)
       (cons 11 PT2)
   )
)
(setq L1 (entlast))                        ; base line

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT6)
       (cons 11 PT4)
   )
)
(setq L2 (entlast))                        ; 2nd base line

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT2)
       (cons 11 PT4)
   )
)
(setq L3 (entlast))                        ; shorter vertical

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT1)
       (cons 11 PT5)
   )
)
(setq L4 (entlast))                        ; longer vertical

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT4)
       (cons 11 PT5)
   )
)
(setq L5 (entlast))                        ; angel

(entmake                                ; layout arc
   (list (cons 0 "Arc")
(cons 8 "_Draft_NoProcess")
(cons 10 PT3)
(cons 40 D1H)
(cons 50 (dtr 180))
(cons 51 0)
   )
)
(setq ARC1 (entlast))

;; this section gets 6 even degrees on that arc you made

(setq PT7 (polar PT3 (dtr (* (/ 180 6) 1)) D1H))
(setq PT7a (list (car PT7) 3))
(setq PT8 (polar PT3 (dtr (* (/ 180 6) 2)) D1H))
(setq PT8a (list (car PT8) 3))
(setq PT9 (polar PT3 (dtr (* (/ 180 6) 3)) D1H))
;; apex
(setq PT9a (list (car PT9) 3))
(setq PT10 (polar PT3 (dtr (* (/ 180 6) 4)) D1H))
(setq PT10a (list (car PT10) 3))
(setq PT11 (polar PT3 (dtr (* (/ 180 6) 5)) D1H))
(setq PT11a (list (car PT11) 3))

;; takes those points and transfers them striaght up
(setq PT7b (inters PT4 PT5 PT7 PT7a nil))
(setq PT8b (inters PT4 PT5 PT8 PT8a nil))
(setq PT9b (inters PT4 PT5 PT9 PT9a nil))
(setq PT10b (inters PT4 PT5 PT10 PT10a nil))
(setq PT11b (inters PT4 PT5 PT11 PT11a nil))

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT7a)
       (cons 11 PT7b)
   )
)

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT8a)
       (cons 11 PT8b)
   )
)

(entmake (list (cons 0 "line")
       ;; center of triangle
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT9a)
       (cons 11 PT9b)
   )
)

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT10a)
       (cons 11 PT10b)
   )
)

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT11a)
       (cons 11 PT11b)
   )
)

(setq NEWANGLE (- (angle PT4 PT5) 1.570796))

(setq PT9c (polar PT9b NEWANGLE D1H))
(setq PT4c (polar PT4 NEWANGLE D1H))

(entmake (list (cons 0 "line")
       ;; 90 from triangle
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT4)
       (cons 11 PT4c)
   )
)

(setq PT5c (polar PT5 NEWANGLE D1H))
;; shorter side 90 from triangle

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT5)
       (cons 11 PT5c)
   )
)

(setq R1 (distance PT5 PT4))
(setq R2 (/ D1 R1))

(command "ellipse" PT5c PT4c PT9b "")   ;;makes correct ellipse

;;this part makes wrapper template

(setq PT12 (list (+ D1 1) 3))
(setq PT12b (list (+ D1 1) 0))
(Setq PT13 (polar PT12 0 (* D1 pi)))
(Setq PT13b (polar PT12b 0 (* D1 pi)))

;;this part just makes the square of the 3 in XS on the bottom of the template

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT12)
       (cons 11 PT12b)
       (cons 62 1)
   )
)


(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT13)
       (cons 11 PT13b)
       (cons 62 1)
   )
)


(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT13b)
       (cons 11 PT12b)
       (cons 62 1)
   )
)


(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 PT12)
       (cons 11 PT13)
       (cons 62 1)
   )
)

;;now i'm gonig to divide up that stretchout and make the upper curvy part

(setq D1P (* D1 pi))

(Setq SP1b (polar PT12b 0 (* (/ D1P 12) 1)))
(Setq SP2b (polar PT12b 0 (* (/ D1P 12) 2)))
(Setq SP3b (polar PT12b 0 (* (/ D1P 12) 3)))
(Setq SP4b (polar PT12b 0 (* (/ D1P 12) 4)))
(Setq SP5b (polar PT12b 0 (* (/ D1P 12) 5)))
(Setq SP6b (polar PT12b 0 (* (/ D1P 12) 6)))
(Setq SP7b (polar PT12b 0 (* (/ D1P 12) 7)))
(Setq SP8b (polar PT12b 0 (* (/ D1P 12) ))
(Setq SP9b (polar PT12b 0 (* (/ D1P 12) 9)))
(Setq SP10b (polar PT12b 0 (* (/ D1P 12) 10)))
(Setq SP11b (polar PT12b 0 (* (/ D1P 12) 11)))

(Setq SP1 (polar PT12 0 (* (/ D1P 12) 1)))
(Setq SP2 (polar PT12 0 (* (/ D1P 12) 2)))
(Setq SP3 (polar PT12 0 (* (/ D1P 12) 3)))
(Setq SP4 (polar PT12 0 (* (/ D1P 12) 4)))
(Setq SP5 (polar PT12 0 (* (/ D1P 12) 5)))
(Setq SP6 (polar PT12 0 (* (/ D1P 12) 6)))
(Setq SP7 (polar PT12 0 (* (/ D1P 12) 7)))
(Setq SP8 (polar PT12 0 (* (/ D1P 12) ))
(Setq SP9 (polar PT12 0 (* (/ D1P 12) 9)))
(Setq SP10 (polar PT12 0 (* (/ D1P 12) 10)))
(Setq SP11 (polar PT12 0 (* (/ D1P 12) 11)))

;;this part gets the lines from the triangle, and transfers them over.

(setq PT5b (polar PT5 0 1))
(setq PT7b2 (polar PT7b 0 1))
(setq PT8b2 (polar PT8b 0 1))
(setq PT9b2 (polar PT9b 0 1))
(setq PT10b2 (polar PT10b 0 1))
(setq PT11b2 (polar PT11b 0 1))

(setq x1 (inters SP1 SP1b PT7b PT7b2 nil))
(setq x11 (inters SP11 SP11b PT7b PT7b2 nil))
(setq x2 (inters SP2 SP2b PT8b PT8b2 nil))
(setq x10 (inters SP10 SP10b PT8b PT8b2 nil))
(setq x3 (inters SP3 SP3b PT9b PT9b2 nil))
(setq x9 (inters SP9 SP9b PT9b PT9b2 nil))
(setq x4 (inters SP4 SP4b PT10b PT10b2 nil))
(setq x8 (inters SP8 SP8b PT10b PT10b2 nil))
(setq x5 (inters SP5 SP5b PT11b PT11b2 nil))
(setq x7 (inters SP7 SP7b PT11b PT11b2 nil))
(setq x6 (inters SP6 SP6b PT5 PT5b nil))

(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x1)
       (cons 11 SP1b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x2)
       (cons 11 sp2b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x3)
       (cons 11 sp3b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x4)
       (cons 11 sp4b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x5)
       (cons 11 sp5b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x6)
       (cons 11 sp6b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x7)
       (cons 11 sp7b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x8)
       (cons 11 sp8b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x9)
       (cons 11 sp9b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x10)
       (cons 11 sp10b)
   )
)
(entmake (list (cons 0 "line")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbLine")
       (cons 8 "_Draft_NoProcess")
       (cons 10 x11)
       (cons 11 sp11b)
   )
)


(command "pline" PT12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 PT13 "")

)

BlackBox 发表于 2022-7-6 06:21:29

尝试在第一个用户提示处设置断点,并单步执行代码,直到代码中断(也称为调试)。。。如果你不熟悉,李在这方面有很好的指导;我会链接到它,但我知道他一直在做一些更新,所以我会听从他提供的。
 
干杯

Lee Mac 发表于 2022-7-6 06:25:18

 
非常感谢BlackBox的推荐
更新的教程可以在这里找到,关于教程的任何评论或问题都可以在这里提交。

BlackBox 发表于 2022-7-6 06:27:52

 
任何时候,我的朋友。。。这个建议是当之无愧的,因为这一点,以及你的其他许多产品。
 
干杯

kapat 发表于 2022-7-6 06:31:33

谢谢大家。我知道如何调试的唯一方法是打开“动画”并观看它,直到它停止。
 
听起来很有趣,对吗?

Commandobill 发表于 2022-7-6 06:34:22

我不会欺骗并告诉你,但我会暗示这是一个关于pt9b的问题。。。我要给你的是一段简洁的代码,它将帮助你避免“Lee Mac”在最后所说的“命令行逃避”。
 

;;PIPE2FLAT
;; draws layout of wrapper template
;; with inside AND outside diameter.
;; Onlys Askes for OD, and refers to standard pipe schedules for the rest.
;; D = Diameter
;; A = Angel
;; R = Radians
;; doesn't work with an OD of 6. I have no idea why. It works with 6.0000001 or 5.9999999. So, don't ask me.
(defun dtr (a)
;; i told you not to delete this.
(* pi (/ a 180.00))
;; stop it.
)
(defun c:PIPE2FLAT ()
(setq D1 (getreal "Enter OD of Pipe, Please"))
(setq A1 (getreal "Enter Angle"))
(setq D1H (/ D1 2))
(setq R1 (dtr A1))
(setq SINR (sin R1))
(setq COSR (cos R1))
(setq TAN1 (/ SINR COSR))
(setq H1 (+ (* TAN1 D1) 3))
(setq PT1 (list 0 0))
(setq PT2 (list D1 0))
(setq PT3 (list D1H 0))
(setq PT4 (list D1 3))
(setq PT5 (list 0 H1))
(setq PT6 (list 0 3))
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT1)
(cons 11 PT2)
   )
)
(setq L1 (entlast))   ; base line
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT6)
(cons 11 PT4)
   )
)
(setq L2 (entlast))   ; 2nd base line
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT2)
(cons 11 PT4)
   )
)
(setq L3 (entlast))   ; shorter vertical
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT1)
(cons 11 PT5)
   )
)
(setq L4 (entlast))   ; longer vertical
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT4)
(cons 11 PT5)
   )
)
(setq L5 (entlast))   ; angel
(entmake    ; layout arc
   (list (cons 0 "Arc")
(cons 8 "_Draft_NoProcess")
(cons 10 PT3)
(cons 40 D1H)
(cons 50 (dtr 180))
(cons 51 0)
   )
)
(setq ARC1 (entlast))
;; this section gets 6 even degrees on that arc you made
(setq PT7 (polar PT3 (dtr (* (/ 180 6) 1)) D1H))
(setq PT7a (list (car PT7) 3))
(setq PT8 (polar PT3 (dtr (* (/ 180 6) 2)) D1H))
(setq PT8a (list (car PT8) 3))
(setq PT9 (polar PT3 (dtr (* (/ 180 6) 3)) D1H))
;; apex
(setq PT9a (list (car PT9) 3))
(setq PT10 (polar PT3 (dtr (* (/ 180 6) 4)) D1H))
(setq PT10a (list (car PT10) 3))
(setq PT11 (polar PT3 (dtr (* (/ 180 6) 5)) D1H))
(setq PT11a (list (car PT11) 3))
;; takes those points and transfers them striaght up
(setq PT7b (inters PT4 PT5 PT7 PT7a nil))
(setq PT8b (inters PT4 PT5 PT8 PT8a nil))
(setq PT9b (inters PT4 PT5 PT9 PT9a nil))
(setq PT10b (inters PT4 PT5 PT10 PT10a nil))
(setq PT11b (inters PT4 PT5 PT11 PT11a nil))
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT7a)
(cons 11 PT7b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT8a)
(cons 11 PT8b)
   )
)
(entmake (list (cons 0 "line")
;; center of triangle
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT9a)
(cons 11 PT9b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT10a)
(cons 11 PT10b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT11a)
(cons 11 PT11b)
   )
)
(setq NEWANGLE (- (angle PT4 PT5) 1.570796))
(setq PT9c (polar PT9b NEWANGLE D1H))
(setq PT4c (polar PT4 NEWANGLE D1H))

(entmake (list (cons 0 "line")
;; 90 from triangle
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT4)
(cons 11 PT4c)
   )
)
(setq PT5c (polar PT5 NEWANGLE D1H))
;; shorter side 90 from triangle
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT5)
(cons 11 PT5c)
   )
)
(setq R1 (distance PT5 PT4))
(setq R2 (/ D1 R1))
(command "ellipse" PT5c PT4c PT9b "")   ;;makes correct ellipse
;;this part makes wrapper template
(setq PT12 (list (+ D1 1) 3))
(setq PT12b (list (+ D1 1) 0))
(Setq PT13 (polar PT12 0 (* D1 pi)))
(Setq PT13b (polar PT12b 0 (* D1 pi)))
;;this part just makes the square of the 3 in XS on the bottom of the template
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT12)
(cons 11 PT12b)
(cons 62 1)
   )
)

(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT13)
(cons 11 PT13b)
(cons 62 1)
   )
)

(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT13b)
(cons 11 PT12b)
(cons 62 1)
   )
)

(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 PT12)
(cons 11 PT13)
(cons 62 1)
   )
)
;;now i'm gonig to divide up that stretchout and make the upper curvy part
(setq D1P (* D1 pi))
(Setq SP1b (polar PT12b 0 (* (/ D1P 12) 1)))
(Setq SP2b (polar PT12b 0 (* (/ D1P 12) 2)))
(Setq SP3b (polar PT12b 0 (* (/ D1P 12) 3)))
(Setq SP4b (polar PT12b 0 (* (/ D1P 12) 4)))
(Setq SP5b (polar PT12b 0 (* (/ D1P 12) 5)))
(Setq SP6b (polar PT12b 0 (* (/ D1P 12) 6)))
(Setq SP7b (polar PT12b 0 (* (/ D1P 12) 7)))
(Setq SP8b (polar PT12b 0 (* (/ D1P 12) ))
(Setq SP9b (polar PT12b 0 (* (/ D1P 12) 9)))
(Setq SP10b (polar PT12b 0 (* (/ D1P 12) 10)))
(Setq SP11b (polar PT12b 0 (* (/ D1P 12) 11)))
(Setq SP1 (polar PT12 0 (* (/ D1P 12) 1)))
(Setq SP2 (polar PT12 0 (* (/ D1P 12) 2)))
(Setq SP3 (polar PT12 0 (* (/ D1P 12) 3)))
(Setq SP4 (polar PT12 0 (* (/ D1P 12) 4)))
(Setq SP5 (polar PT12 0 (* (/ D1P 12) 5)))
(Setq SP6 (polar PT12 0 (* (/ D1P 12) 6)))
(Setq SP7 (polar PT12 0 (* (/ D1P 12) 7)))
(Setq SP8 (polar PT12 0 (* (/ D1P 12) ))
(Setq SP9 (polar PT12 0 (* (/ D1P 12) 9)))
(Setq SP10 (polar PT12 0 (* (/ D1P 12) 10)))
(Setq SP11 (polar PT12 0 (* (/ D1P 12) 11)))
;;this part gets the lines from the triangle, and transfers them over.
(setq PT5b (polar PT5 0 1))
(setq PT7b2 (polar PT7b 0 1))
(setq PT8b2 (polar PT8b 0 1))
(setq PT9b2 (polar PT9b 0 1))
(setq PT10b2 (polar PT10b 0 1))
(setq PT11b2 (polar PT11b 0 1))
(setq x1 (inters SP1 SP1b PT7b PT7b2 nil))
(setq x11 (inters SP11 SP11b PT7b PT7b2 nil))
(setq x2 (inters SP2 SP2b PT8b PT8b2 nil))
(setq x10 (inters SP10 SP10b PT8b PT8b2 nil))
(setq x3 (inters SP3 SP3b PT9b PT9b2 nil))
(setq x9 (inters SP9 SP9b PT9b PT9b2 nil))
(setq x4 (inters SP4 SP4b PT10b PT10b2 nil))
(setq x8 (inters SP8 SP8b PT10b PT10b2 nil))
(setq x5 (inters SP5 SP5b PT11b PT11b2 nil))
(setq x7 (inters SP7 SP7b PT11b PT11b2 nil))
(setq x6 (inters SP6 SP6b PT5 PT5b nil))
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x1)
(cons 11 SP1b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x2)
(cons 11 sp2b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x3)
(cons 11 sp3b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x4)
(cons 11 sp4b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x5)
(cons 11 sp5b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x6)
(cons 11 sp6b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x7)
(cons 11 sp7b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x8)
(cons 11 sp8b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x9)
(cons 11 sp9b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x10)
(cons 11 sp10b)
   )
)
(entmake (list (cons 0 "line")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 8 "_Draft_NoProcess")
(cons 10 x11)
(cons 11 sp11b)
   )
)

(plmaker (list PT12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 PT13))
)
(defun plmaker (bolst / )
(entmake
   (append
   '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (40 . 0.0) (41 . 0) (43 . 0))
   (list (cons 90 (length bolst)) (cons 43 (getvar "plinewid")) (cons 8(getvar "clayer")))
   (mapcar '(lambda (p) (cons 10 p)) bolst)
   '((70 . 1))
   ))
)

kapat 发表于 2022-7-6 06:36:20

谢谢我在使用entmake版本的多段线/样条曲线时遇到了一些实际问题。另外,我想这样做一个椭圆,因为我更喜欢entmake的自由度,我只是想不出如何从椭圆的中心得到我的端点。我算出了比率和中心位。
 
无论我重新阅读了多少次帮助文件,我仍然不完全理解“lambda”和“mapcar”。

Commandobill 发表于 2022-7-6 06:39:19

 
mapcar和lambda在一开始也让我有一段时间。不过李·麦克在他们身上有一个很好的帖子
 
http://www.lee-mac.com/mapcarlambda.html

Tharwat 发表于 2022-7-6 06:45:01

只是一个建议,为行entmake编写一个子函数,并从中删除两个100 DXF,因为它们不需要。

jdiala 发表于 2022-7-6 06:46:25

(defun entmake:line ( a b )
(entmakex
   (list
   (cons 0 "LINE")
   (cons 8 "_Draft_NoProcess")
   (cons 10 a)
   (cons 11 b)
   )
)
)
 
页: [1] 2
查看完整版本: 好吧,这真让我受不了。(简单