- UID
- 190918
- 积分
- 541
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-11-9
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
; Modified by CAB 01.23.2008
; Sets the correct layer for certain commands.
; 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.
; CAB added error trap for layer creator
; added layer restore at command exit
(defun C:VLR_COMMAND ()
(vl-load-com)
(vl-load-reactors)
(or *vlr-CWS ; Load only once
(setq *vlr-CWS (vlr-command-reactor nil '((:vlr-commandwillstart . StartCommand)))))
(or *vlr-CE
(setq *vlr-CE (vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))))
(or *vlr-CC
(setq *vlr-CC (vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)))))
)
(defun StartCommand (CALL CALLBACK / COMLAYLST)
;; current layer restored on exit of command
(setq *Currentlayers* (cons (getvar "CLAYER") *Currentlayers*))
; Examples of Command vs Layer
; List of corrusponding command layerName color linetype plottable
; NOTE command names must be in Upper Case
; (if (= (strcase *user*) "DAN")
(setq COMLAYLST (list
(list "DIMANGULAR" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMALIGNED" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMBASELINE" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMCENTER" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMCONTINUE" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMDIAMETER" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMLINEAR" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMRADIUS" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "QDIM" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "LEADER" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "QLEADER" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "DTEXT" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "MTEXT" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "TEXT" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "REVCLOUD" "PS_TXT_文字标注" 1 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
;|
(setq COMLAYLST (list
(list "DIMANGULAR" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMALIGNED" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMBASELINE" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMCENTER" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMCONTINUE" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMDIAMETER" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMLINEAR" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "DIMRADIUS" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "QDIM" "PS_DIM_尺寸标注" 3 "continuous" :vlax-true)
(list "LEADER" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "QLEADER" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "DTEXT" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "MTEXT" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "TEXT" "PS_TXT_文字标注" 3 "continuous" :vlax-true)
(list "REVCLOUD" "PS_TXT_文字标注" 1 "continuous" :vlax-true)
; Add your own command layer lists here....
)
)
)
|;
(if (setq N (assoc (strcase (car CALLBACK)) COMLAYLST))
(if (make_layers (cadr N) (caddr N) (cadddr N) (car (cddddr N)))
(vla-put-activelayer (vla-get-activedocument (vlax-get-acad-object))
(vlax-ename->vla-object (tblobjname "LAYER" (cadr N)))
)
)
)
(prin1)
)
; Make layers using activeX
; return t if sucessful else nil
(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 (tblobjname "layer" LAY_NAM)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(setq LAYOBJ (vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM)))
)
;;(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (vl-catch-all-error-p LAYOBJ)
(not (print (vl-catch-all-error-message LAYOBJ)))
(progn ; update layer properties
(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)
t
)
)
)
(defun endCommand (CALL CALLBACK)
(if *Currentlayers*
(progn
(vla-put-lock
(vla-item
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
(car *Currentlayers*)) :vlax-false)
(setvar "CLAYER" (car *Currentlayers*))
(setq *Currentlayers* (cdr *Currentlayers*))
)
)
)
(defun cancelCommand (CALL CALLBACK)
(if *Currentlayers*
(progn
(vla-put-lock
(vla-item
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
(car *Currentlayers*)) :vlax-false)
(setvar "CLAYER" (car *Currentlayers*))
(setq *Currentlayers* (cdr *Currentlayers*))
)
)
)
(c:vlr_command)
(prin1)
;------------------<The End>--------------------------
;(vlr_command)
问题出在哪里谁能帮忙解决一下! |
|