基于我的第一个例程,我刚刚删除了非块/文本/多行文字对象的旋转。然后,我在if中为text/mtexts/blocks添加了旋转。我没有拾取点,而是获取了它们的原始插入点。当它们围绕我根据自己的“插入点坐标”创建的轴旋转时,我删除了2个手动拾取点。现在,您只需从视图中选择所有项目。所有文本/多行文字和块将围绕x轴上对齐的轴进行3d旋转,并通过各自的插入点。经过几次快速修改,结果就达到了。
我还删除了我最后从未使用过的delta变量,也就是vlss变量。我添加了一个错误处理程序,在执行attsync之前,我实际上验证了一个块是否具有属性。没有乐趣留给你。享受
- (defun c:3rtx ( / *error* obj tmppoint)
- ;3D rotate texts mtexts and blocks aound an axis aligned
- ;on the x axis, passing by their individual insertion points.
- ;made by Jef! 2015-12-11.
- (defun *error* ( msg )
- (if (not (member msg '("Function cancelled" "quit / exit abort")))
- (princ (strcat "\nError: " msg))
- )
- (princ)
- )
- (princ "\nSelect objects to rotate")
- (if (ssget)
- (progn
- (vlax-for obj (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
- (if (or (eq (vla-get-objectname obj) "AcDbMText")
- (eq (vla-get-objectname obj) "AcDbText")
- (eq (vla-get-objectname obj) "AcDbBlockReference")
- )
- (progn
- (vla-Rotate3D obj (vlax-3d-point (setq tmppoint (vlax-get obj 'InsertionPoint))) (vlax-3d-point (mapcar '+ tmppoint '(1 0 0))) (/ pi 2))
- (if (and (eq (vla-get-objectname obj) "AcDbBlockReference")
- (= (vlax-get-property obj 'HasAttributes) :vlax-true)
- )
- (vl-cmdf "_.AttSync" "Name" (vla-get-name obj))
- )
- )
- )
- )
- )
- (princ "nothing selected")
- )
- (princ)
- )
附言:我希望你的目标是学习。。。Lisp程序是有趣和强大的。
干杯
杰夫! |