怎么判断对象是引线?
本帖最后由 Nico 于 2024-1-19 22:31 编辑怎么判断对象是引线?
引线+多行文字组成了引线,
怎么判断这个多行文字是与引线捆绑的?
哪位大神帮写个代码,我想把甩有标注对象 (含引线)转到dim 图层上
(defun c:gtz1 ();得到块内对象,第一层级;要
(vl-load-com)
(princ "\n速度有点慢慢请稍等")
(if (setq ss (ssget (list '(0 . "INSERT"))))
(repeat (setq sslen (sslength ss))
(setq ename (ssname ss (setq sslen (1- sslen))))
(setq enlast1 (tblobjname "block" (cdr (assoc 2 (entget ename)))))
(setq tz_dim "dim")
(setq tz_txt "A文字")
(while (setq enlast1 (entnext enlast1))
;改单行文字到文字层
(if (or (= nema1 "AcDbMText") (= nema1 "AcDbText") );
(progn
(if (= nema1 "AcDbText")
(princ "\n单行文字")
;;; (princ (Vlax-Get (Vlax-Ename->Vla-Object enlast1) 'TextString));为什么会错'TextString
)
(Vlax-Put-Property (Vlax-Ename->Vla-Object enlast1) 'Layer tz_txt);放到指定图层
;;; (command "REGEN") ;重画一下
)
)
;改对象到标注层
(setq nema1 (Vlax-Get (Vlax-Ename->Vla-Object enlast1) 'ObjectName ))
(if (or (= nema1 "AcDbRotatedDimension") (= nema1 "AcDbAlignedDimension") (= nema1 "AcDbRadialDimension"));
(progn
(Vlax-Put-Property (Vlax-Ename->Vla-Object enlast1) 'Layer tz_dim);放到指定图层
)
)
;;;(princ (car (entget enlast1)))
;;;(princ "\n")
)
)
)
(command "REGEN") ;重画一下
(princ)
)
哪里写的不对,单行文字有时也不转换,
;;;关联的前提下,根据引线找注释对象
;;;一个引线只关联一个注释对象
(defun C:TT1 (/ LDR ANN)
(if (and (setq LDR (entsel "\n选择引线: "))
(or (setq ANN (vla-get-Annotation (vlax-ename->vla-object (car LDR))))
(progn (princ "\n未发现注释对象: ") nil)
)
)
(sssetfirst nil (ssadd (vlax-vla-object->ename ANN) (ssadd)))
)
)
;;;关联的前提下,根据注释对象找引线
;;;一个注释对象可能关联多个引线
(defun C:TT2 (/ ANN ENX SS)
(if (setq ANN (entsel "\n选择注释对象: "))
(progn
(setq ENX (entget (car ANN))
ENX (member (assoc 330 ENX) ENX)
SS(ssadd)
)
(while (= (car (setq LDR (car ENX))) 330)
(if (= (cdr (assoc 0 (entget (setq LDR (cdr LDR))))) "LEADER")
(ssadd LDR SS)
)
(setq ENX (cdr ENX))
)
(if (zerop (sslength SS))
(princ "\n注释对象没有相关联的引线!")
(sssetfirst nil SS)
)
)
)
) caoyin 发表于 2024-1-19 22:58
;;;关联的前提下,根据引线找注释对象
;;;一个引线只关联一个注释对象
(defun C:TT1 (/ LDR ANN)
感谢感谢:handshake
页:
[1]