找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2559|回复: 1

[求助]:用了此LSP就不能切换当前图层(在线等)

[复制链接]
发表于 2010-3-10 10:52:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

    ;  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)





问题出在哪里谁能帮忙解决一下!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 593个

财富等级: 财运亨通

发表于 2013-5-15 23:29:20 来自手机 | 显示全部楼层
已经自动了,还要手动干什么
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-22 05:01 , Processed in 0.209364 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表