只是为了好玩,这是我能做的最好的这么快-我可能需要修改再生步骤-但试一试:
- (defun c:LAYSWAP (/ *error* _swapVal _layswap)
- (vl-load-com)
- (princ "\rLAYSWAP ")
- (defun *error* (msg)
- (if acDoc
- (vla-endundomark acDoc))
- (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))
- (defun _swapVal (val)
- (if (= :vlax-true val)
- :vlax-false
- :vlax-true))
- (defun _layswap (oLayer lst)
- (foreach item lst
- (eval item)))
- ((lambda (acDoc cLayer / mode)
- (initget "ALL FREEZE ON LOCK PLOT")
- (if (or (setq mode
- (getkword
- "\nSpecify mode [All/Freeze/On/Lock/Plot] <Freeze>: "))
- (not mode))
- (progn
- (vla-startundomark acDoc)
- (vlax-for oLayer (vla-get-layers acDoc)
- (if (/= (vla-get-name oLayer) cLayer)
- (cond
- ((or (= nil mode) (= "FREEZE" mode))
- (_layswap
- oLayer
- (list '(vla-put-freeze
- oLayer
- (_swapVal (vla-get-freeze oLayer))))))
- ((= "ALL" mode)
- (_layswap
- oLayer
- (list '(vla-put-freeze
- oLayer
- (_swapVal (vla-get-freeze oLayer)))
- '(vla-put-layeron
- oLayer
- (_swapVal (vla-get-layeron oLayer)))
- '(vla-put-lock
- oLayer
- (_swapVal (vla-get-lock oLayer)))
- '(vla-put-plottable
- oLayer
- (_swapVal (vla-get-plottable oLayer))))))
- ((= "ON" mode)
- (_layswap
- oLayer
- (list '(vla-put-layeron
- oLayer
- (_swapVal (vla-get-layeron oLayer))))))
- ((= "LOCK" mode)
- (_layswap
- oLayer
- (list '(vla-put-lock
- oLayer
- (_swapVal (vla-get-lock oLayer))))))
- ((= "PLOT" mode)
- (_layswap
- oLayer
- (list '(vla-put-plottable
- oLayer
- (_swapVal (vla-get-plottable oLayer)))))))))
- ;;(vla-regen acDoc acAllViewports)
- (vl-cmdf "._regenall")
- ))
- (*error* nil))
- (vla-get-activedocument (vlax-get-acad-object))
- (getvar 'clayer)))
再次执行同一选项的LAYSWAP将“撤消”初始选项。
|