cab or anyone else who might know,
I got the example you provided to work and was testing it against another one i already had for viewports. the part i like about the viewports is that after the viewport is created it switches the layer back to the prvious. Is there a way I can combine these to offer that functionality?
(defun subCommandLayer (objReactor lstCommand)
; Examples of Command vs Layer
; List of corrusponding commands layers color linetype plottable
(if (not lstCommandLayersX)
(setq lstCommandLayersX (list (list "DIMLINEAR" "I_ANNO-DIMS" 14 "continuous" :vlax-true)
(list "QLEADER" "I_ANNO-NOTE" 11 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
)
(foreach lstLayerProperties lstCommandLayersX
(if (= (strcase (car lstCommand)) (strcase (car lstLayerProperties)))
(progn
(subMakeLayer (nth 1 lstLayerProperties)
(nth 2 lstLayerProperties)
(nth 3 lstLayerProperties)
(nth 4 lstLayerProperties))
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object))
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr lstLayerProperties)))))))
(princ)
)
; Make layers using activeX
(defun subMakeLayer (strLayerName ; String Layer name
intColor ; Integer Layer Color
strLineType ; String Linetype Name
blnPlottable ; VL boolean plottable layer
/
colLayers ; Layers Collection
colLineTypes ; Linetype Collection
objActiveDocument ; ActiveDocument Object
objLayer ; New Layer Object
)
(vl-load-com)
(setq objActiveDocument (vla-get-activedocument
(vlax-get-acad-object))
colLayers (vla-get-layers objActiveDocument)
)
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list colLayers strLayerName))
)
(setq objLayer (vla-item colLayers strLayerName))
(if (not (tblobjname "ltype" strLineType))
(progn
(setq colLineTypes (vla-get-linetypes objActiveDocument))
(vla-load colLineTypes strLineType (findfile "acad.lin"))
(vlax-release-object colLineTypes)
)
)
(vla-put-color objLayer intColor)
(vla-put-linetype objLayer strLineType)
(vla-put-plottable objLayer blnPlottable)
)
(if (not rxnCommandLayer)
(setq rxnCommandLayer (vlr-editor-reactor nil '((:vlr-commandwillstart . subCommandLayer)))))
(princ)
;;;Used for viewports
;; by default turn the ability ON
(if (or (eq (getenv "RunPlaceViewLayer") nil)
(eq (getenv "RunPlaceViewLayer") ""))
(setenv "RunPlaceViewLayer" "1"))
(defun reactor-editor (reactor params)
(if (eq (getenv "RunPlaceViewLayer") "1")
(progn
(if (not
(wcmatch
(getvar "cmdnames")
"UNDO,U,REDO,OOPS,STYLE,COPYCLIP,COPYBASE,CUTCLIP"))
(progn
(if (and
(wcmatch (strcase (car params)) "MVIEW")
posible_viewport_ename
posible_viewport_enames)
(progn
;; the Z-VIEWPORT layer must exist
(vla-put-layer (vlax-ename->vla-object posible_viewport_ename) "Z-VIEWPORT")
;; convert the variable "posible_viewport_ename"
;; into vla-object and set it to an existing standard layer
;; after that turn the vla-object to nil
(setq posible_viewport_ename nil)
(setq posible_viewport_enames nil)))))
(setq posible_viewport_ename nil)
(setq posible_viewport_enames nil))))
(defun acdb-objectappended (reactor params)
(if
(and
(eq (getenv "RunPlaceViewLayer") "1")
(not
(wcmatch
(getvar "cmdnames")
"UNDO,U,REDO,OOPS,STYLE,COPYCLIP,COPYBASE,CUTCLIP,NEW,QNEW,OPEN,*LAYOUT*,MOVE,COPY,*STRETCH*")))
(cond
((and
(wcmatch (getvar "cmdnames") "MVIEW")
params
(entget (cadr params))
(eq (cdadr (entget (cadr params))) "VIEWPORT")
(not
(vl-position (cadr params) posible_viewport_enames)))
(setq posible_viewport_ename (cadr params))
(setq posible_viewport_enames
(cons (cadr params) posible_viewport_enames))))))
(if (not dwiz_editor_reactor)
(setq dwiz_editor_reactor
(vlr-set-notification
(vlr-editor-reactor
"editor"
'((:vlr-commandended . reactor-editor)
(:vlr-commandcancelled . reactor-editor)))
'active-document-only)))
(if (not dwiz_acdb_reactor)
(setq dwiz_acdb_reactor
(vlr-set-notification
(vlr-acdb-reactor
"acdb"
'((:vlr-objectappended . acdb-objectappended)))
'active-document-only)))
(princ)