怎样把创建的图形变成块定义?生产衣杆
根据论坛内的代码,自己琢磨的,程序可以用,但是会提示未知命令!!而且生产的是三个矩形,没有成块?求大佬给优化一下;-----------------衣杆生成------------------------------------
(defun c:yg(/pt ent ent5 minpt maxptos p1 p2 p3)
(setq os (getvar "OSMODE"))
(setvar "cmdecho" 0)
(setq pt (getpoint "\n请选择矩形框内一点:"))
(command "-boundary" "a" "i" "n" "" "o" "r" "" pt "")
(setq ent (entlast))
(vla-GetBoundingBox
(vlax-ename->vla-object ent)
'minpt
'maxpt
)
(setq minpt (vlax-safearray->list minpt)
maxpt (vlax-safearray->list maxpt)
)
(entdel ent)
(setq
P1 (list (car minpt) (cadr minpt))
P2 (list (car minpt) (cadr maxpt))
P3 (list (car maxpt) (cadr maxpt))
Y1 (list (car P2) (-(cadr P2) 60 ))
Y2 (list (+(car P2) 20)(-(cadr P2) 120))
Y3 (list (car P3) (-(cadr P3) 60 ))
Y4 (list (-(car P3) 20)(-(cadr P3) 120))
Y5 (list (+(car P2) 20)(-(cadr P2) 75))
Y6 (list (-(car P3) 20)(-(cadr P3) 105))
)
(setvar "OSMODE" 0)
(command "_RECTANGLE" "NON" Y1 "NON" Y2"")
(command "_RECTANGLE" "NON" Y3 "NON" Y4"")
(command "_RECTANGLE" "NON" Y5 "NON" Y6"")
(setvar "OSMODE" os)
(princ)
)
(command "rectang" y1 y2)
(command "rectang" y3 y4)
(command "rectang" y5 y6) 可以用动态块的吧 davide888 发表于 2023-10-30 08:50
可以用动态块的吧
动态块还得调整位置吧
xyp1964 发表于 2023-10-31 09:43
(command "rectang" y1 y2)
(command "rectang" y3 y4)
(command "rectang" y5 y6)
谢谢版主回复,未知命令的提示解决了,但是还是三个单独的矩形,想要把他们变成块怎么解决啊?成组的代码还不会使用 hd654 发表于 2023-10-31 12:14
谢谢版主回复,未知命令的提示解决了,但是还是三个单独的矩形,想要把他们变成块怎么解决啊?成组的代码 ...
(setq ss(ssadd))
(command "rectang" y1 y2)
(ssadd(entlast) ss)
(command "rectang" y3 y4)
(ssadd(entlast) ss)
(command "rectang" y5 y6)
(ssadd(entlast) ss)
(setq bk (rtos (getvar 'cdate)2 8))
(command"-block" bk p1 ss "")
(command"-insert" bk p1 1 1 0) xyp1964 发表于 2023-11-1 20:53
(setq ss(ssadd))
(command "rectang" y1 y2)
(ssadd(entlast) ss)
学习了,谢谢版主!
页:
[1]