维维安,
很难从你的代码中看出你想要创建什么,但我会尽我所能帮助你。
我会避免使用对齐和擦除,只在正确的位置创建必要的内容。
我已经写了一个快速的“shell”,你可以围绕它来构建你的程序-这应该给你一个良好的基础,是没有错误的。
我已经为您提供了一些子函数,这些子函数可以简化poyline的创建:
- (defun c:lsd (/ *error* [b][color=Blue]Make_Layer[/color][/b] [color=Red][b]Make_Polyline[/b][/color]
- vl ov ss nos plen)
- (defun *error* (msg)
- (and ov (mapcar 'setvar vl ov))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
-
- [b][color=Blue] (defun Make_Layer (lay col)
- (or (tblsearch "LAYER" lay)
- (command "_.-layer" "_M" lay "_C" col lay "")))[/color][/b]
-
- [color=Red][b] (defun Make_Polyline (pts cls)
- (entmakex (append (list (cons 0 "LWPOLYLINE")
- (cons 100 "AcDbEntity")
- (cons 100 "AcDbPolyline")
- (cons 90 (length pts))
- (cons 70 cls))
- (mapcar (function (lambda (x) (cons 10 x))) pts))))[/b][/color]
-
- (setq vl '("CLAYER" "CMDECHO" "OSMODE")
- ov (mapcar 'getvar vl))
- (if (and (setq ss (ssget "_:S" '((0 . "LINE"))))
- (setq nos (getint "\nEnter Number of Slots: "))
- (setq plen (getdist "\nEnter Length of Plenum: ")))
- (progn
- (mapcar 'Make_Layer '("GRILLE" "DUCTING") '(30 6))
- (mapcar 'setvar (cdr vl) '(0 0 0))
-
- [color=SeaGreen][b];< Draw Stuff Here>[/b][/color]
- ) ; End Progn
- ) ; End IF
- (mapcar 'setvar vl ov)
- (princ))
请注意蓝色和红色显示的两个子函数。
使用Make_layer sub,您可以为其提供层名称和颜色,它将为您创建层,如上图所示。
使用Make_Polyline sub,可以为其提供点列表和位代码,以确定是要闭合多边形还是开放多边形(1或0)。
例如:
将返回通过1,2,0 3,10,0和5,6,0创建的闭合多段线的实体名称。
我希望这有帮助,
李 |