return to current layer

return to current layer

Anonymous
Not applicable
683 Views
4 Replies
Message 1 of 5

return to current layer

Anonymous
Not applicable
The following is a routine that I have found very useful to use. There is
only one problem. I can't figure out how to come back to the layer that the
command was issued in. It stays in the text or dim. layer. Any suggestions
would be appreciated.

;VLR_COMMAND.lsp courtesy Peter Jamtgaard 2003

; Vlr Command is a function that will switch the active layer in a drawing.
; The reactor checks the command that is starting and if it recognizes it
; it will switch to a specified layer. If the layer doesn't exist it will
; create it with the color, linetype, and plottable setting provided.
; To load and run this program add the lines (load
"vlr_command")(c:vlr_command)
; to your acaddoc.lsp or another autoloading lisp routine.

(defun C:AVLR_COMMAND ()
(vl-load-com)
(vlr-editor-reactor nil '((:vlr-commandwillstart . COM1)))
)
(vla-get-Layer setq cl (getvar "nlayer"))
(defun COM1 (CALL CALLBACK / COMLAYLST)
; Examples of Command vs Layer
; List of corrusponding commands layers color linetype
plottable
(setq COMLAYLST (list (list "qdim" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimlinear" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimaligned" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimordinate" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimradius" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimdiameter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimangular" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimbaseline" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcontinue" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimqleader" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "tolerance" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcenter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dtext" "TEXT" 3 "continuous"
:vlax-true)
(list "mtext" "TEXT" 3 "continuous"
:vlax-true)
(list "text" "TEXT" 3 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
(foreach N COMLAYLST
(if (= (strcase (car CALLBACK)) (strcase (car N)))
(progn
(make_layers (cadr N)
(caddr N)
(cadddr N)
(car (cddddr N))
)
(setq n1 n)
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object)
)
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr N))
)
)
)
)
)
(prin1)
)
(setvar "nlayer" cl)
; Make layers using activeX

(defun MAKE_LAYERS (LAY_NAM COLOR LTYPE PLOTL / LAYOBJ LAYSOBJ LTYPESOBJ)
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
LAYSOBJ (vla-get-layers CDWGOBJ)
)
(if (not (tblobjname "layer" LAY_NAM))
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM))
)
)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (not (tblobjname "ltype" LTYPE))
(progn
(setq LTYPESOBJ (vla-get-linetypes CDWGOBJ))
(vla-load LTYPESOBJ LTYPE (findfile "acad.lin"))
(vlax-release-object LTYPESOBJ)
)
)
(vla-put-layeron LAYOBJ :vlax-true)
(if (/= (strcase (vla-get-name LAYOBJ)) (strcase (getvar "clayer")))
(vla-put-freeze LAYOBJ :vlax-false)
)
(vla-put-lock LAYOBJ :vlax-false)
(vla-put-color LAYOBJ COLOR)
(vla-put-linetype LAYOBJ LTYPE)
(vla-put-plottable LAYOBJ PLOTL)
)
(prin1)
0 Likes
684 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I think you want to post this in the autodesk.autocad.customization
newsgroup instead of this one. This group is about the .NET API of AutoCAD
and your question is about Visual Lisp.

Albert

"Daren Nerad" wrote in message
news:4854824@discussion.autodesk.com...
The following is a routine that I have found very useful to use. There is
only one problem. I can't figure out how to come back to the layer that the
command was issued in. It stays in the text or dim. layer. Any suggestions
would be appreciated.

;VLR_COMMAND.lsp courtesy Peter Jamtgaard 2003

; Vlr Command is a function that will switch the active layer in a drawing.
; The reactor checks the command that is starting and if it recognizes it
; it will switch to a specified layer. If the layer doesn't exist it will
; create it with the color, linetype, and plottable setting provided.
; To load and run this program add the lines (load
"vlr_command")(c:vlr_command)
; to your acaddoc.lsp or another autoloading lisp routine.

(defun C:AVLR_COMMAND ()
(vl-load-com)
(vlr-editor-reactor nil '((:vlr-commandwillstart . COM1)))
)
(vla-get-Layer setq cl (getvar "nlayer"))
(defun COM1 (CALL CALLBACK / COMLAYLST)
; Examples of Command vs Layer
; List of corrusponding commands layers color linetype
plottable
(setq COMLAYLST (list (list "qdim" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimlinear" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimaligned" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimordinate" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimradius" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimdiameter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimangular" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimbaseline" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcontinue" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimqleader" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "tolerance" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcenter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dtext" "TEXT" 3 "continuous"
:vlax-true)
(list "mtext" "TEXT" 3 "continuous"
:vlax-true)
(list "text" "TEXT" 3 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
(foreach N COMLAYLST
(if (= (strcase (car CALLBACK)) (strcase (car N)))
(progn
(make_layers (cadr N)
(caddr N)
(cadddr N)
(car (cddddr N))
)
(setq n1 n)
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object)
)
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr N))
)
)
)
)
)
(prin1)
)
(setvar "nlayer" cl)
; Make layers using activeX

(defun MAKE_LAYERS (LAY_NAM COLOR LTYPE PLOTL / LAYOBJ LAYSOBJ LTYPESOBJ)
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
LAYSOBJ (vla-get-layers CDWGOBJ)
)
(if (not (tblobjname "layer" LAY_NAM))
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM))
)
)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (not (tblobjname "ltype" LTYPE))
(progn
(setq LTYPESOBJ (vla-get-linetypes CDWGOBJ))
(vla-load LTYPESOBJ LTYPE (findfile "acad.lin"))
(vlax-release-object LTYPESOBJ)
)
)
(vla-put-layeron LAYOBJ :vlax-true)
(if (/= (strcase (vla-get-name LAYOBJ)) (strcase (getvar "clayer")))
(vla-put-freeze LAYOBJ :vlax-false)
)
(vla-put-lock LAYOBJ :vlax-false)
(vla-put-color LAYOBJ COLOR)
(vla-put-linetype LAYOBJ LTYPE)
(vla-put-plottable LAYOBJ PLOTL)
)
(prin1)
0 Likes
Message 3 of 5

Anonymous
Not applicable
I didn't....I posted the wrong one. This is what is current. Thanks for
the catch. Any suggestions on a fix?

Daren


;VLR_COMMAND.lsp courtesy Peter Jamtgaard 2003

; Vlr Command is a function that will switch the active layer in a drawing.
; The reactor checks the command that is starting and if it recognizes it
; it will switch to a specified layer. If the layer doesn't exist it will
; create it with the color, linetype, and plottable setting provided.
; To load and run this program add the lines (load
"vlr_command")(c:vlr_command)
; to your acaddoc.lsp or another autoloading lisp routine.

(defun C:VLR_COMMAND ()
(vl-load-com)
(vlr-editor-reactor nil '((:vlr-commandwillstart . COM1)))
)
(defun COM1 (CALL CALLBACK / COMLAYLST)
; Examples of Command vs Layer
; List of corrusponding commands layers color linetype plottable
(setq COMLAYLST (list (list "qdim" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimlinear" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimaligned" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimordinate" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimradius" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimdiameter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimangular" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimbaseline" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcontinue" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimqleader" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "tolerance" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcenter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dtext" "TEXT" 3 "continuous"
:vlax-true)
(list "mtext" "TEXT" 3 "continuous"
:vlax-true)
(list "text" "TEXT" 3 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
(foreach N COMLAYLST
(if (= (strcase (car CALLBACK)) (strcase (car N)))
(progn
(make_layers (cadr N)
(caddr N)
(cadddr N)
(car (cddddr N))
)
(setq n1 n)
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object)
)
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr N))
)
)
)
)
)
(prin1)
)

; Make layers using activeX

(defun MAKE_LAYERS (LAY_NAM COLOR LTYPE PLOTL / LAYOBJ LAYSOBJ LTYPESOBJ)
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
LAYSOBJ (vla-get-layers CDWGOBJ)
)
(if (not (tblobjname "layer" LAY_NAM))
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM))
)
)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (not (tblobjname "ltype" LTYPE))
(progn
(setq LTYPESOBJ (vla-get-linetypes CDWGOBJ))
(vla-load LTYPESOBJ LTYPE (findfile "acad.lin"))
(vlax-release-object LTYPESOBJ)
)
)
(vla-put-layeron LAYOBJ :vlax-true)
(if (/= (strcase (vla-get-name LAYOBJ)) (strcase (getvar "clayer")))
(vla-put-freeze LAYOBJ :vlax-false)
)
(vla-put-lock LAYOBJ :vlax-false)
(vla-put-color LAYOBJ COLOR)
(vla-put-linetype LAYOBJ LTYPE)
(vla-put-plottable LAYOBJ PLOTL)
)
(prin1)
0 Likes
Message 4 of 5

Anonymous
Not applicable
That's still lisp. You can reach Peter through the lisp forum at
www.AUGI.com.

--
----
Ed
----
"Daren Nerad" wrote in message
news:4854979@discussion.autodesk.com...
I didn't....I posted the wrong one. This is what is current. Thanks for
the catch. Any suggestions on a fix?

Daren


;VLR_COMMAND.lsp courtesy Peter Jamtgaard 2003

; Vlr Command is a function that will switch the active layer in a drawing.
; The reactor checks the command that is starting and if it recognizes it
; it will switch to a specified layer. If the layer doesn't exist it will
; create it with the color, linetype, and plottable setting provided.
; To load and run this program add the lines (load
"vlr_command")(c:vlr_command)
; to your acaddoc.lsp or another autoloading lisp routine.

(defun C:VLR_COMMAND ()
(vl-load-com)
(vlr-editor-reactor nil '((:vlr-commandwillstart . COM1)))
)
(defun COM1 (CALL CALLBACK / COMLAYLST)
; Examples of Command vs Layer
; List of corrusponding commands layers color linetype plottable
(setq COMLAYLST (list (list "qdim" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimlinear" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimaligned" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimordinate" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimradius" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimdiameter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimangular" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimbaseline" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcontinue" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimqleader" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "tolerance" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcenter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dtext" "TEXT" 3 "continuous"
:vlax-true)
(list "mtext" "TEXT" 3 "continuous"
:vlax-true)
(list "text" "TEXT" 3 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
(foreach N COMLAYLST
(if (= (strcase (car CALLBACK)) (strcase (car N)))
(progn
(make_layers (cadr N)
(caddr N)
(cadddr N)
(car (cddddr N))
)
(setq n1 n)
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object)
)
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr N))
)
)
)
)
)
(prin1)
)

; Make layers using activeX

(defun MAKE_LAYERS (LAY_NAM COLOR LTYPE PLOTL / LAYOBJ LAYSOBJ LTYPESOBJ)
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
LAYSOBJ (vla-get-layers CDWGOBJ)
)
(if (not (tblobjname "layer" LAY_NAM))
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM))
)
)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (not (tblobjname "ltype" LTYPE))
(progn
(setq LTYPESOBJ (vla-get-linetypes CDWGOBJ))
(vla-load LTYPESOBJ LTYPE (findfile "acad.lin"))
(vlax-release-object LTYPESOBJ)
)
)
(vla-put-layeron LAYOBJ :vlax-true)
(if (/= (strcase (vla-get-name LAYOBJ)) (strcase (getvar "clayer")))
(vla-put-freeze LAYOBJ :vlax-false)
)
(vla-put-lock LAYOBJ :vlax-false)
(vla-put-color LAYOBJ COLOR)
(vla-put-linetype LAYOBJ LTYPE)
(vla-put-plottable LAYOBJ PLOTL)
)
(prin1)
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thanks Ed

Will do.

"Ed Jobe" wrote in message
news:4855035@discussion.autodesk.com...
That's still lisp. You can reach Peter through the lisp forum at
www.AUGI.com.

--
----
Ed
----
"Daren Nerad" wrote in message
news:4854979@discussion.autodesk.com...
I didn't....I posted the wrong one. This is what is current. Thanks for
the catch. Any suggestions on a fix?

Daren


;VLR_COMMAND.lsp courtesy Peter Jamtgaard 2003

; Vlr Command is a function that will switch the active layer in a drawing.
; The reactor checks the command that is starting and if it recognizes it
; it will switch to a specified layer. If the layer doesn't exist it will
; create it with the color, linetype, and plottable setting provided.
; To load and run this program add the lines (load
"vlr_command")(c:vlr_command)
; to your acaddoc.lsp or another autoloading lisp routine.

(defun C:VLR_COMMAND ()
(vl-load-com)
(vlr-editor-reactor nil '((:vlr-commandwillstart . COM1)))
)
(defun COM1 (CALL CALLBACK / COMLAYLST)
; Examples of Command vs Layer
; List of corrusponding commands layers color linetype plottable
(setq COMLAYLST (list (list "qdim" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimlinear" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimaligned" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimordinate" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimradius" "DIMENSIONS" 2 "continuous"
:vlax-true)
(list "dimdiameter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimangular" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimbaseline" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcontinue" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimqleader" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "tolerance" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dimcenter" "DIMENSIONS" 2 "continuous" :vlax-true)
(list "dtext" "TEXT" 3 "continuous"
:vlax-true)
(list "mtext" "TEXT" 3 "continuous"
:vlax-true)
(list "text" "TEXT" 3 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
(foreach N COMLAYLST
(if (= (strcase (car CALLBACK)) (strcase (car N)))
(progn
(make_layers (cadr N)
(caddr N)
(cadddr N)
(car (cddddr N))
)
(setq n1 n)
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object)
)
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr N))
)
)
)
)
)
(prin1)
)

; Make layers using activeX

(defun MAKE_LAYERS (LAY_NAM COLOR LTYPE PLOTL / LAYOBJ LAYSOBJ LTYPESOBJ)
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
LAYSOBJ (vla-get-layers CDWGOBJ)
)
(if (not (tblobjname "layer" LAY_NAM))
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM))
)
)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (not (tblobjname "ltype" LTYPE))
(progn
(setq LTYPESOBJ (vla-get-linetypes CDWGOBJ))
(vla-load LTYPESOBJ LTYPE (findfile "acad.lin"))
(vlax-release-object LTYPESOBJ)
)
)
(vla-put-layeron LAYOBJ :vlax-true)
(if (/= (strcase (vla-get-name LAYOBJ)) (strcase (getvar "clayer")))
(vla-put-freeze LAYOBJ :vlax-false)
)
(vla-put-lock LAYOBJ :vlax-false)
(vla-put-color LAYOBJ COLOR)
(vla-put-linetype LAYOBJ LTYPE)
(vla-put-plottable LAYOBJ PLOTL)
)
(prin1)
0 Likes