基于角度de旋转块
你好我必须围绕插入点旋转几百个块,通过从电子表格导入的块中定义的属性值。
我试着用一个带有旋转集的动态块来实现这一点,但似乎不能将默认旋转角度设置为一个字段,并将其链接回属性?
这可以使用LISP例程实现吗?
干杯 这段代码很有效,只需要改变接收角度,从用户输入到块内的属性。
(defun c:test ( / ss ang ) (vl-load-com)
(if (and (setq ss(ssget "_:L" '((0 . "INSERT"))))
(setq ang (getangle "\nSpecify Rotation Angle: "))
)
(
(lambda ( i / e o )
(while (setq e (ssname ss (setq i (1+ i))))
(vla-put-rotation (setq o (vlax-ename->vla-object e))
(+ (vla-get-rotation o) ang)
)
)
)
-1
)
)
(princ)
) 该属性块中有多少属性值?
如果不止一个,哪一个与角度值有关?
价值的单位是什么?度/弧度? 您好,Tharwat,块中大约有9个属性,与角度相关的属性称为“旋转”,单位为度。 尝试以下操作:
(defun c:blkrot ( / i r s )
(if (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1))))
(repeat (setq i (sslength s))
(if
(and
(setq r (LM:getattributevalue (setq b (ssname s (setq i (1- i)))) "ROTATION"))
(setq r (angtof r))
)
(vla-put-rotation (vlax-ename->vla-object b) r)
)
)
)
(princ)
)
;; Get Attribute Value-Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; blk - Block (Insert) Entity Name
;; tag - Attribute TagString
;; Returns: Attribute value, else nil if tag is not found.
(defun LM:getattributevalue ( blk tag / enx )
(if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
(if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
(cdr (assoc 1 enx))
(LM:getattributevalue blk tag)
)
)
)
(vl-load-com) (princ)
LM:从属性函数集中获取AttributeValue。 试试这个未经测试的代码,然后告诉我。
Untested wrong codes
谢谢李Mac你的代码工作得很好!明天上班我可以放松一下
Tharwat你的代码几乎在那里旋转属性,但不是整个块。干杯
谢谢大家 不客气,休眠
页:
[1]