TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: roy_043 on December 16, 2010, 07:43:28 AM
-
This is related to:
http://www.theswamp.org/index.php?topic=36170.0
http://www.theswamp.org/index.php?topic=2005.0
Inspiration came from:
http://www.visuallisp-tutorial.mapcar.net/schnellzugriff.html
This is part of a tutorial in German. Look for the function vlax*get-property.
;;; ======================================================================
;;; Lib function: kg:vl:Get (LibVer20101216)
;;; Purpose: Generic visual lisp get-function.
;;; Arguments: lst - list of objects and/or properties
;;; Root element first. If the first element in the
;;; list is nil then the application object is used
;;; as the root.
;;; Return value: Result of vlax-get.
;;; Dependencies: None
;;; Remarks: http://www.theswamp.org/index.php?topic=2005.0
;;; http://www.visuallisp-tutorial.mapcar.net/schnellzugriff.html
;;; Examples: (kg:vl:Get '(nil)) => #<VLA-OBJECT IAcadApplication 020aa128>
;;; (kg:vl:Get '(nil activedocument activelayer color)) => 7
;;; ======================================================================
(defun kg:vl:Get (lst / tmpLst)
(setq tmpLst
(cons
(cond
((car lst))
((vlax-get-acad-object))
)
tmpLst
)
)
(mapcar
'(lambda (a)
(setq tmpLst
(cons
(vlax-get ; alternative: vlax-get-property
(car tmpLst)
a
)
tmpLst
)
)
)
(cdr lst)
)
(mapcar
'(lambda (a)
(and
(not (vlax-object-released-p a))
(vlax-release-object a)
)
)
(cdr tmpLst)
)
; (gc)
(car tmpLst)
)
-
Very original idea Roy! I like it :-)
-
Very original idea Roy! I like it :-)
All Credits for originality should go to Axel Strube-Zettler (author of the German tutorial (http://www.visuallisp-tutorial.mapcar.net/schnellzugriff.html)).