TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Mark on May 25, 2004, 09:30:49 AM
-
Just something to look at.
(defun get-utilobj ()
(vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))
)
)
;;; returns a vla-object or nil
(defun obj-select (/ obj pt)
(if
(not (vl-catch-all-error-p
(vl-catch-all-apply
'vlax-invoke-method
(list (get-utilobj) 'GetEntity 'obj 'pt)
)
)
)
obj
)
)
;;; returns the id number(integer) of the current modelspace object
(defun get-mspace-id ()
(vla-get-objectid
(vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))
)
)
)
;;; returns the id number(integer) of the current paperspace object
(defun get-pspace-id ()
(vla-get-objectid
(vla-get-paperspace
(vla-get-activedocument
(vlax-get-acad-object))
)
)
)
;;; returns what 'space' (string) the supplied object resides
(defun what-space-t (obj)
(if (= (type obj) 'VLA-OBJECT)
(cond ((= (vla-get-ownerid obj) (get-mspace-id))
"model"
)
((= (vla-get-ownerid obj) (get-pspace-id))
"paper"
)
)
)
)
(defun c:main1 (/ obj)
(if (setq obj (obj-select))
(alert (strcat "the object is in " (what-space-t obj) "space"))
)
)
;;; returns the paperspace object
(defun get-pspace ()
(vla-get-paperspace
(vla-get-activedocument
(vlax-get-acad-object))
)
)
;;; returns the modelspace object
(defun get-mspace ()
(vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))
)
)
;;; returns the object (model/paperspace) the supplied object
;;; resides in
(defun what-space-o (obj)
(if (= (type obj) 'VLA-OBJECT)
(cond ((= (vla-get-ownerid obj) (vla-get-objectid (get-mspace)))
(get-mspace)
)
((= (vla-get-ownerid obj) (vla-get-objectid (get-pspace)))
(get-pspace)
)
)
)
)
(defun c:main2 (/ obj)
(if (setq obj (obj-select))
(vlax-dump-object (what-space-o obj))
)
(textscr)
(princ)
)