删除已命名的当前UCS坐标系的vlisp方法
本帖最后由 namezg 于 2012-11-6 20:42 编辑删除已命名的当前UCS坐标系lisp方法:
(setq currUCSName (getvar "ucsname"))
(if (/= currUCSName "")
(command "ucs" "na" "d" currUCSName);(command "ucs" "d" currUCSName)
)
我想知道vlisp如何实现此功能。
;对当前UCS进行命名视为未命名。
(defun CurrentUCS (/ doc tmp)
(if (null ucsname# ) (setq ucsname# "Unnamed_UCS_"))
(progn (setq ucsname (getstring (strcat "\n输入ucs名称前缀< " ucsname# " >")))
(if (= "" ucsname) (setq ucsname ucsname#)(setq ucsname# ucsname ))
)
(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(setq org (getvar "UCSORG"))
(setq Xpt (trans (list 1 0 0) 1 0))
(setq Ypt (trans (list 0 1 0) 1 0))
(setq u (list (- (car Xpt) (car ORg)) (- (cadr Xpt) (cadr ORg)) (- (caddr Xpt) (caddr ORg))))
(setq v (list (- (car Ypt) (car ORg)) (- (cadr Ypt) (cadr ORg)) (- (caddr Ypt) (caddr ORg))))
(setq z (v^v u v));; calculate z vector
(setq Yptp (mapcar '+ org (v^v z u)))
(vla-put-ActiveUCS doc
(vla-add (vla-get-usercoordinatesystems doc)
(vlax-3D-point org)
(vlax-3D-point Xpt)
(vlax-3D-point yptp)
(strcat ucsname(menucmd "M=$(edtime,$(getvar,date),YY-MO-DD HH:MM)"))
)
)
)
;; 两个矢量的叉积,参数两个矢量,返回值一个矢量.
(defun v^v (v1 v2)
(list (- (* (cadr v1) (caddr v2)) (* (caddr v1) (cadr v2)))
(- (* (caddr v1) (car v2)) (* (car v1) (caddr v2)))
(- (* (car v1) (cadr v2)) (* (cadr v1) (car v2)))
)
) 感谢大佬分享~ 自己顶一下 在usercoordinatesystems对象里
本帖最后由 namezg 于 2012-11-8 20:52 编辑
在usercoordinatesystems对象里我知道,可是怎么从在usercoordinatesystems里删除呢?
(defun DelUCS (Ucsname)
(vl-load-com)
(if (= (getvar "UCSNAME") UcsName)
(command "_.UCS" "_W")
)
(vlax-for Ucs (vla-get-UserCoordinateSystems
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (= (vla-get-name Ucs) UcsName)
(vla-delete Ucs)
)
)
) 这样当前坐标系会被删除,而不是改为未命名,我要求的是改为未命名。 (defun DelUCS (Ucsname)
(vl-load-com)
(if (= (getvar "UCSNAME") UcsName)
(command "_.UCS" "_W")
)
(vlax-for Ucs (vla-get-UserCoordinateSystems
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (= (vla-get-name Ucs) UcsName)
(vla-delete Ucs)
)
)
(command "_.UCS" "_P")
) 谢谢,不过还不是纯vlisp方法
和我下面的一样
(vl-load-com)
(setq AcadObject(vlax-get-acad-object))
(setq AcadDocument(vla-get-ActiveDocument AcadObject))
(setq UcsSel (vla-get-UserCoordinateSystems AcadDocument))
(setq ucsname "new_ucsname")
(if (not (vl-catch-all-error-p (setq UCSobj (vl-catch-all-apply 'vla-Item (list UcsSel ucsname)))));如果指定UCS坐标系在UCS坐标系统中
(if (= (vla-get-Name UCSobj) (vlax-invoke AcadDocument 'GetVariable "ucsname"));如果指定UCS坐标系是当前UCS坐标系
(progn
(command "ucs" "w")
(vla-Delete UCSobj)
(command "ucs" "p")
)
(vla-Delete UCSobj)
)
) 就是不知道(command "ucs" "w") (command "ucs" "p")用vlisp如何表达,看来是办不到的。 Lee Mac has this ....
(defun UCSWorld (/ doc tmp)
(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(vla-put-ActiveUCS doc
(vla-add (vla-get-usercoordinatesystems doc)
(vlax-3D-point '(0. 0. 0.))
(vlax-3D-point '(1. 0. 0.))
(vlax-3D-point '(0. 1. 0.)) "TempWord_UCS")))
页:
[1]
2