仅选择属性块
你好使用lisp选择正方形内的所有对象,并高亮显示它们以填充快捷特性。
但这个Lisp程序选择了全部。我希望它只选择模型空间中的属性块。
我知道它与(66.1)和(ssget“_x”'((0。“insert”))有关。
我只是不知道该怎么说,也不知道该怎么说。
(defun c:SWCC (/ _pac add ss i e temp it o a b pts tempC i3 ec)
;; Select Within/Crossing Curve
(vl-load-com)
(defun _pac (e / l v d lst)
(setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
(while (< (setq d (+ d v)) l)
(setq lst (cons (trans (vlax-curve-getPointAtDist e d) 0 1) lst))
)
)
(initget 0 "Crossing Within")
(setq *SWCC:Opt*
(cond ((getkword (strcat "\nSpecify selection method witin curve <"
(cond (*SWCC:Opt*)
((setq *SWCC:Opt* "Crossing"))
)
">: "
)
)
)
(*SWCC:Opt*)
)
)
(princ "\nSelect closed curves to select object(s) within: ")
(if (setq add (ssadd)
ss(ssget '((-4 . "<OR")
(0 . "CIRCLE,ELLIPSE")
(-4 . "<AND")
(0 . "*POLYLINE")
(-4 . "&=")
(70 . 1)
(-4 . "AND>")
(-4 . "OR>")
)
)
)
(progn (repeat (setq i (sslength ss))
(if (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i)))))))
(repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
)
(if (eq *SWCC:Opt* "Crossing")
(progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'a 'b)
(setq pts (mapcar 'vlax-safearray->list (list a b)))
(if (setq tempC (ssget "_C"
(list (caar pts) (cadar pts) 0.)
(list (caadr pts) (cadadr pts) 0.)
)
)
(repeat (setq i3 (sslength tempC))
(if (vlax-invoke
o
'Intersectwith
(vlax-ename->vla-object (setq ec (ssname tempC (setq i3 (1- i3)))))
acExtendNone
)
(ssadd ec add)
)
)
)
)
)
)
(sssetfirst nil add)
(ssget "_I")
)
)
(princ)
)
提前谢谢你。 ssget的一个选项是使用410代码,这只强制使用模型空间。您的代码ss(ssget’((cons 410“Model”)(-4) (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i))))) '((0 . "INSERT") (66 . 1)))) 六月份你的帖子编辑得很有趣。
谢谢你完全删除我的名字。
http://www.cadtutor.net/forum/showthread.php?97379-选择多段线内或相交的块 对不起,艾伦,这不是我的本意。但我试图用Ncopy调整lisp,从外部参照中复制一个矩形,并将其用于脚本的选择。
我确实删除了你的名字,让我更清楚一点。我对lisp一无所知,尽量保持清楚。所以我在cadtutor上做了一些剪贴。
再次抱歉。
PmxCAD 比加尔和斯特凡BMR,
谢谢你抽出时间。
我不知道如何将其应用于lisp。
我对lisp一无所知。你能帮助我吗?
PmxCAD
上面的代码和我在网上发布的代码唯一的不同之处是,我在上面写下了我的名字和日期,却省略了一行注释。
你为清楚起见而声称省略,听起来像博洛尼亚。
如果试图在选定的嵌套多段线内创建属性块的选择,可以平移嵌套多段线的点(从gile中查找WCS转换子程序),或创建多段线,提取点,然后删除多段线。
如。
(defun c:CreateNestedLWPolyline (/ e new)
(if (and
(setq e (nentselp "\nSelect nested LWPolyline: "))
(eq (length e) 4)
(eq (cdr (assoc 0 (entget (car e)))) "LWPOLYLINE")
(setq new (entmakex (entget (car e))))
)
(vla-transformby (vlax-ename->vla-object new) (vlax-tmatrix (caddr e)))
)
(princ)
)
(vl-load-com)
(princ) 这就是我目前使用的。从外部参照复制多段线/矩形,选择多段线/矩形,交叉。。。。。。
但它也选择除块和多段线/矩形之外的其他对象。一定只有街区。
(command "_.ncopy" "\\" "" "_non" '(0 0) "_non" '(0 0))
((/ _pac add ss i e temp it o a b pts tempC i3 ec)
;; Select Within/Crossing Curve
(vl-load-com)
(defun _pac (e / l v d lst)
(setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
(while (< (setq d (+ d v)) l)
(setq lst (cons (trans (vlax-curve-getPointAtDist e d) 0 1) lst))
)
)
(initget 0 "Crossing Within")
(setq *SWCC:Opt*
(cond ((getkword (strcat "\nSpecify selection method witin curve <"
(cond (*SWCC:Opt*)
((setq *SWCC:Opt* "Crossing"))
)
">: "
)
)
)
(*SWCC:Opt*)
)
)
(princ "\nSelect closed curves to select object(s) within: ")
(if (setq add (ssadd)
ss(ssget '((-4 . "<OR")
(0 . "CIRCLE,ELLIPSE")
(-4 . "<AND")
(0 . "*POLYLINE")
(-4 . "&=")
(70 . 1)
(-4 . "AND>")
(-4 . "OR>")
)
)
)
(progn (repeat (setq i (sslength ss))
(if (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i)))))))
(repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
)
(if (eq *SWCC:Opt* "Crossing")
(progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'a 'b)
(setq pts (mapcar 'vlax-safearray->list (list a b)))
(if (setq tempC (ssget "_C"
(list (caar pts) (cadar pts) 0.)
(list (caadr pts) (cadadr pts) 0.)
)
)
(repeat (setq i3 (sslength tempC))
(if (vlax-invoke
o
'Intersectwith
(vlax-ename->vla-object (setq ec (ssname tempC (setq i3 (1- i3)))))
acExtendNone
)
(ssadd ec add)
)
)
)
)
)
)
(sssetfirst nil add)
(ssget "_I")
)
)
(princ)
) pmxcad我认为最好的建议和注意183个帖子是,现在是时候让你做一点研究,学习如何写一个Lisp程序,像上面的其他人一样,我张贴了一个准确的答案,你的问题,它可以直接剪切和粘贴。最好是在谷歌上搜索“Help SSGET”或使用Autocad帮助,他们的帮助是解释可以添加的所有过滤器。看看李·麦克。他还有一个很好的SSGET教程
example
(setq ss (ssget "X" '((cons 0 "insert")(cons 8 "Duct")(cons 410 "Model")(cons 41 1))))
下面是在pline中获取文本的另一个示例。它可以很容易地更改为允许选择块提示“插入”
; By Alan H may 2013
(vl-load-com)
(defun getcoords (ent)
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ent)
"Coordinates"
)
)
)
)
(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth I co-ords)(nth (+ I 1) co-ords) ))
(setq coordsxy (cons xy coordsxy))
(setq I (+ I 2))
) ; end repeat
) ; end defun
; program starts here
; choose output file change acdatemp to what you want
(setq fname (strcat "c:/alan/" (getstring "\nEnter file name ")))
(setq fout (open fname "w"))
(setq plobjs (ssget (list (cons 0 "lwpolyline"))))
(setq numb1 (sslength plobjs))
(setq x numb1)
(repeat numb1
(setq obj (ssname plobjs (setq x (- x 1))))
(setq co-ords (getcoords obj))
(co-ords2xy)
; write pline co-ords here
(setq numb3 (length co-ords))
(setq z numb3)
(setq ansco-ords "")
(repeat numb3
(setq ansco-ords (strcat ansco-ords (rtos (nth (setq z (- z 1)) co-ords) 2 3 ) " " ))
)
(setq ans (strcat "Pline " ansco-ords))
(write-line ans fout)
(setq ansco-ords "")
(setq ss (ssget "WP" coordsxy (list (cons 0 "Text,Mtext")))) ; selection set of text within polygon
(if (= ss nil)
(princ "\nnothing inside")
(progn
(setq coordsxy nil) ; reset for next time
(setq numb2 (sslength ss))
(setq y numb2)
(repeat numb2
(setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring"))
(princ anstext) ; change to write text to file
(write-line (strcat "text " anstext) fout)
(princ "\n")
) ; end repeat2
(setq ss nil) ; reset for next poly
)
)
) ; end repeat1
(close fout)
(princ)
页:
[1]