0 Members and 1 Guest are viewing this topic.
(defun c:test () (setq acadObj (vlax-get-acad-object) ;; acad Object ActivedocumentObj (vla-get-Activedocument acadObj) ;; the current dwg mSpace (vla-get-ModelSpace ActivedocumentObj) ;; the modelspace collection objUtilitytypes (vla-get-Utility ActivedocumentObj) ;; the utility collection objUCStypes (vla-get-UserCoordinateSystems Activedocumentobj) ;; the UCS collection objAppNames (vla-get-RegisteredApplications ActivedocumentObj) ;; the Application names for xdata collection 2pi (* 2 pi) orig (list 5 5 0) x-crd (list 10 10 0) y-crd (polar orig (+ (angle orig x-crd) (* 0.5 pi)) 10.0) ) (wg:ChangeUCS (vlax-3d-point orig) (vlax-3d-point x-crd) (vlax-3d-point y-crd) "TESTUCS" ));;;; Function to change the UCS to a selected entity;; USAGE:;; Arguments;; orig - origin of the new UCS;; X-crd - the X-axis of the new UCS;; Y-crd - the Y-axis of the new UCS;; UCSName - the UCS name;; (defun wg:ChangeUCS( orig X-crd Y-crd UCSName / localUCS ) (vla-put-origin (setq localUCS (vla-add objUCStypes Orig ;origin x-crd ;x-axis y-crd ;y-axis UCSName ; the UCS name )) Orig ) (vla-put-activeucs Activedocumentobj localUCS) ; (vla-put-activeucs Activedocumentobj acWorld) );wg:ChangeUCS
;;;; IAcadUCSs Collection(or g:ucss (setq g:ucss (vla-get-usercoordinatesystems (vla-get-activedocument (vlax-get-acad-object))) ))(vlax-dump-object g:ucss t)
Command: UCSCurrent ucs name: *WORLD*Enter an option [New/Move/orthoGraphic/Prev/Restore/Save/Del/Apply/?/World] <World>: REnter name of UCS to restore or [?]: ?Enter UCS name(s) to list <*>: *Current ucs name: *WORLD*Saved coordinate systems: No matching UCS names found.Enter name of UCS to restore or [?]:
;;;-------------------------------------------------------------;;;-------------------------------------------------------------;;(defun kb:UCS:NameWorld (MakeActive / localUCS) ;; ;; IAcadDocument Object ;; (or g:activedoc (setq g:activedoc (vla-get-activedocument (vlax-get-acad-object)))) ;; ;; IAcadUCSs Collection ;; (or g:ucss (setq g:ucss (vla-get-usercoordinatesystems (vla-get-activedocument (vlax-get-acad-object)) ) ) ) ;; (setq localUCS (vla-add g:ucss (vlax-3d-point '(0.0 0.0 0.0)) ;origin (vlax-3d-point '(1.0 0.0 0.0)) ;x-axis (vlax-3d-point '(0.0 1.0 0.0)) ;y-axis "_WorldUCS" ) ) (if MakeActive (vla-put-activeucs g:activedoc localUCS) ) localUCS)
(kb:UCS:NameWorld T)(vlax-dump-object g:ucss t)
(vlax-dump-object (vla-item g:ucss 0) t)
; IAcadUCS: A user-defined coordinate system that determines the orientation of the X, Y, and Z axes in 3D space; Property values:; Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>; Document (RO) = #<VLA-OBJECT IAcadDocument 058cff84>; Handle (RO) = "E5"; HasExtensionDictionary (RO) = 0; Name = "_WorldUCS"; ObjectID (RO) = 2130190184; ObjectName (RO) = "AcDbUCSTableRecord"; Origin = (0.0 0.0 0.0); OwnerID (RO) = 2130189368; XVector = (1.0 0.0 0.0); YVector = (0.0 1.0 0.0); Methods supported:; Delete (); GetExtensionDictionary (); GetUCSMatrix (); GetXData (3); SetXData (2)
;;;-------------------------------------------------------------;;;-------------------------------------------------------------;;(defun kb:UCS:NameCurrent (name / Origin localUCS) ;; ;; IAcadDocument Object ;; (or g:activedoc (setq g:activedoc (vla-get-activedocument (vlax-get-acad-object)))) ;; ;; IAcadUCSs Collection ;; (or g:ucss (setq g:ucss (vla-get-usercoordinatesystems (vla-get-activedocument (vlax-get-acad-object)) ) ) ) (setq Origin (getvar "ucsorg") localUCS (vla-add g:ucss (vlax-3d-point '(0.0 0.0 0.0)) ;origin (vlax-3d-point (getvar "ucsxdir")) ;x-axis (vlax-3d-point (getvar "ucsydir")) ;y-axis (if name name "_TempUCS") ) ) (vla-put-origin localUCS (vlax-3d-point Origin)) (vla-put-activeucs g:activedoc localUCS) localUCS)
;;;-------------------------------------------------------------;;;-------------------------------------------------------------;;(defun kb:UCS:BlackBox (NewUcsName Origin XAxis YAxis Activate / objUCS) ;; ;; by Kerry Brown 2005.Jun.11 ;; Create a Named UCS and Optionally Activate it. ;|Required globals : g:activedoc, g:ucssRequired dependancies : nilParameters :- NewUcsName :<string> Origin :<PointList (X Y Z)> XAxis :<VectorList (X Y Z)> YAxis :<VectorList (X Y Z)> Activate :<nil or NonNil> Set as ActiveUCSReturns : <VLA-OBJECT IAcadUCS ....> or nil.|;;;;;---------------- ;; ;; IAcadDocument Object ;; (or g:activedoc (setq g:activedoc (vla-get-activedocument (vlax-get-acad-object)))) ;; ;; IAcadUCSs Collection ;; (or g:ucss (setq g:ucss (vla-get-usercoordinatesystems (vla-get-activedocument (vlax-get-acad-object)) ) ) ) ;; (or NewUcsName (setq NewUcsName "TempUCS")) (or Origin (setq Origin (getvar "ucsorg"))) (or XAxis (setq XAxis (getvar "ucsxdir"))) (or YAxis (setq YAxis (getvar "ucsydir"))) ;; (setq objUCS (vla-add g:ucss (vlax-3d-point '(0.0 0.0 0.0)) ;origin (vlax-3d-point XAxis) ;x-axis (vlax-3d-point YAxis) ;y-axis NewUcsName ) ) (vla-put-origin objUCS (vlax-3d-point Origin)) ;; (if Activate (vla-put-activeucs g:activedoc objUCS) ) objUCS)
.. and this should satisfy most of your needs ...