Originally Posted by
jpcadconsulting347236
That's .NET yes? A little out of my league I'm afraid.
It can be (I also code .NET plug-ins), but actually I was describing the Visual LISP (ActiveX) approach.
Quick demonstration... Please take from it what you like:
Code:
(vl-load-com)
(defun c:FOO (/ *error* clayer acDoc layerName oLayer)
(defun *error* (msg)
;; restore the stored layer, even in the event of an error
(and clayer (setvar 'clayer clayer))
;; end undo mark
(if acDoc (vla-endundomark acDoc))
;; handle any error messages
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
;; store the current layer
(setq clayer (getvar 'clayer))
;; start undo mark
(vla-startundomark
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
)
;; get or create layer
(setq oLayer (vla-add (vla-get-layers acDoc) (setq layerName "_FOO")))
;; set standard layer properties
(vla-put-color oLayer 110)
(vla-put-description oLayer "_FOO Description ")
(vla-put-linetype oLayer "bylayer")
(vla-put-lineweight oLayer aclnwt050)
;;<-- set other properties here
;; set the layer current
(setvar 'clayer layerName)
;; demonstrate
(alert
(strcat "\nYou'll notice that \""
layerName
"\" layer has been set current (look over there). "
)
)
;; clean exit
(*error* nil)
)