;;----------------=={ Add Objects to Block }==----------------;;
;; ;;
;; Adds all objects in the provided SelectionSet to the ;;
;; definition of the specified block. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
(defun LM:AddObjectstoBlock ( doc block ss / lst mat )
(setq lst (LM:ss->vla ss)
mat (LM:Ref->Def block)
mat (vlax-tmatrix (append (mapcar 'append (car mat) (mapcar 'list (cadr mat))) '((0. 0. 0. 1.))))
)
(foreach obj lst (vla-transformby obj mat))
(vla-CopyObjects doc (LM:SafearrayVariant vlax-vbobject lst)
(vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget block))))
)
(foreach obj lst (vla-delete obj))
(vla-regen doc acAllViewports)
This is the first time I have seen this type of syntax being used in AutoLISP.
I am trying to get some explanation of what "LM:"
actually means.
The use of "Ref->"
is also a question for me. "Ref"
does not seem to be defined so it seems it must be part of the system somehow although I could not pull out any documentation describing such use of "Ref->"
.
Why is the local variable ss
being accessed with "LM:ss->"
?
Thank you.
This type of syntax is not construction of AutoLISP/Visual LISP. it's Lee Mac's standard. I understand it in this way:
"LM:" actually means shortcut of "Lee Mac" ;)
(LM:ss->vla ss) shound switch datatype from selection set to list of vla-objects where selection set is something simmilar to list of selected elements, but defined as type entity, not vla-object. Maybe get by (ssget) or (ssgetfirst)
(LM:Ref->Def block) get block definition based on it's reference. where "LM:Ref->Def" is only full name of function. "Ref" is not any kind of variable, it's part of function name.
"LM:ss->" not means that we use ss defined as parameter of function, but "LM:ss->vla" is name of function.