使用多边形创建wi
嘿伙计们,我正在编写一个代码,但我在获取分配给变量的DXF代码以及将变量用于多边形命令方面遇到了问题。
基本上,我尝试做的是创建一个多边形,它“跟踪”一个圆,这将帮助我使用wipeout命令。
(defun c:test (/ obj)
(setq obj (entsel"\nSelect Circle to Wipeout: "))
(setq rad (assoc 40 obj))
(setq cen (assoc 10 obj))
(command
"_.polygon" 50 cen "C" rad
)
)
我遇到了这个错误:
错误:错误的关联列表:(7ffffb05b50>(3241.76 1416.18 0.0))
感谢您的帮助 也许是这样的
(defun c:test (/ obj rad cen)
(setq obj (entget (car (entsel "\nSelect Circle to Wipeout: "))))
(setq rad (cdr (assoc 40 obj)))
(setq cen (cdr (assoc 10 obj)))
(command "_.polygon" 50 cen "_C" rad)
(princ)
)
HTH公司
亨里克 这个程序可能会有所帮助。
嗨,Henrique,
非常感谢!这就是我要找的!
我现在正在为程序添加一些错误检查,当我试图在AutoCAD中测试它时,我遇到了另一个错误。
(defun c:test (/ obj rad cen wipeout)
;;this lisp will create a wipeout for a circle when selected by the user
(if (setq obj (entget (car(entsel"\nSelect Circle to Wipeout: "))))
(if (/= circle (cdr (assoc 0 obj)))
(setq rad (cdr (assoc 40 obj)));;get radius from selection and set to "rad"
(setq cen (cdr (assoc 10 obj)));;get center point from selection and set to "cen"
(command
"_.polygon" 50 cen "_C" rad
)
(setq poly (entlast));;set last entity to variable "poly"
(command
"_.wipeout" "_p" poly "_Y"
)
(setq wipeout (entlast));;set last entity to variable "wipeout"
(command
"_.draworder" wipeout "" "_b";;put wipeout behind object
)
(princ)
(ALERT "YOU DIDN'T SELECT A CIRCLE")
);;END 2ND IF
(ALERT "YOU DIDN'T SELECT AN OBJECT")
);;END 1ST IF
)
我遇到了太多的参数错误
也许有人可以给我一些关于如何运行错误检查的见解。我最讨厌的一点是,当if运行nil值时,它仍然继续执行命令。我试着让它跳到结尾,或者重复到开头。
李:我一定会调查那个节目的。
谢谢 不客气!
尝试
(defun c:test (/ CEN ESEL OBJ POLY RAD WIPEOUT)
;;this lisp will create a wipeout for a circle when selected by the user
(if (setq esel (entsel "\nSelect Circle to Wipeout: "));; get entity name and picked point
(progn
(if (and (setq obj (entget (car esel)));; get entity data
(= "CIRCLE" (cdr (assoc 0 obj)));; test for "CIRCLE"
);; and
(progn
(setq rad (cdr (assoc 40 obj)));;get radius from selection and set to "rad"
(setq cen (cdr (assoc 10 obj)));;get center point from selection and set to "cen"
(command "_.polygon" 50 cen "_C" rad)
(setq poly (entlast));;set last entity to variable "poly"
(command "_.wipeout" "_p" poly "_Y")
(setq wipeout (entlast));;set last entity to variable "wipeout"
(command "_.draworder" wipeout "" "_b");;put wipeout behind object
);; progn
(ALERT "YOU DIDN'T SELECT A CIRCLE")
);;END 2ND IF
);; progn
(ALERT "YOU DIDN'T SELECT AN OBJECT")
);;END 1ST IF
(princ)
);; test
HTH公司
亨里克 谢谢这奏效了。
再次感谢你,亨里克。
不客气,chiimayred
很高兴我能帮忙
亨里克
页:
[1]