天非深化设计 发表于 2012-9-12 15:40:18

悬赏求图层切换工具,(类似变色插件)欢迎各位高手赐教!

求一插件最好是LSP(源码给我,加上天非专用插件www.tifchina.com版权信息 )
*图层切换功能(类似变色插件原理)
功能要求:我们做图只有十二种图层
例如A1命令就可以使”墙体图层“置为当前,选中图形后用A1命令还可以把选中的图形放在”墙体图层“ 去。
(最好带图块归0效果,例如我有一个图块,我用命令放到“墙体图层”要求这个图层内的所有文件都在墙体图层里面,不要我把这个图块放在“墙体图层”,结果我隐藏“墙体图层”,这个图层还没有被隐藏。)

我们的图层对应的命令如下,请参考以下内容进行编写程序。
图层名称                   命令
1-TIF-原墙体             11
2-TIF-FF-jiaju             12
2-TIF-FF-jiajuDW       13
2-TIF-FF-jieju             14
2-TIF-FF-men             15
2-TIF-FF-menxian   16
2-TIF-FF-完成面      17
3-TIF-ARDW          18
4-TIF-RC               21
4-TIF-RC-DW      22
4-TIF-RCdengju    23
5-TIF-fc               24
7-TIF-IE                25
8-TIF-DS             26
9-TIF-布局标注    27
9-TIF-布局图框   28
Defpoints         31


lijiao 发表于 2012-9-12 15:40:19

(defun c:11 ( / )
(to-lay "1-TIF-原墙体")
(princ)
)
(defun c:12 ( / )
(to-lay "2-TIF-FF-jiaju")
(princ)
)
(defun c:13 ( / )
(to-lay "2-TIF-FF-jiajuDW")
(princ)
)
(defun c:14 ( / )
(to-lay "2-TIF-FF-jieju")
(princ)
)
(defun c:15 ( / )
(to-lay "2-TIF-FF-men")
(princ)
)
(defun c:16 ( / )
(to-lay "2-TIF-FF-menxian")
(princ)
)
(defun c:17 ( / )
(to-lay "2-TIF-FF-完成面")
(princ)
)
(defun c:18 ( / )
(to-lay "3-TIF-ARDW")
(princ)
)
(defun c:21 ( / )
(to-lay "4-TIF-RC")
(princ)
)
(defun c:22 ( / )
(to-lay "4-TIF-RC-DW")
(princ)
)
(defun c:23 ( / )
(to-lay "4-TIF-RCdengju")
(princ)
)
(defun c:24 ( / )
(to-lay "5-TIF-fc")
(princ)
)
(defun c:25 ( / )
(to-lay "7-TIF-IE")
(princ)
)
(defun c:26 ( / )
(to-lay "8-TIF-DS")
(princ)
)
(defun c:27 ( / )
(to-lay "9-TIF-布局标注")
(princ)
)
(defun c:28 ( / )
(to-lay "9-TIF-布局图框")
(princ)
)
(defun c:27 ( / )
(to-lay "Defpoints")
(princ)
)


(defun to-lay (lay / I LAYS LAY_OBJ SS SS_OBJS X)
(vl-load-com)
(setq ss (cadr (ssgetfirst)))
(setq lays (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))))
(if (vl-catch-all-error-p
        (setq lay_obj (vl-catch-all-apply 'vla-item (list lays lay)))
      )
    (setq lay_obj (vla-add lays lay))
)
(vla-put-Freeze lay_obj :vlax-false)
(vla-put-Lock lay_obj :vlax-false)
(vla-put-LayerOn lay_obj :vlax-true)
(vla-put-ActiveLayer (vla-get-ActiveDocument (vlax-get-acad-object)) lay_obj)
(if ss
    (progn
      (setq i -1 ss_objs '())
      (repeat (sslength ss)
        (setq ss_objs (cons (ssname ss (setq i (1+ i))) ss_objs))
        )
      (setq ss_objs (mapcar 'vlax-ename->vla-object ss_objs))
      (mapcar '(lambda(x) (vla-put-Layer x lay)) ss_objs)
      )
    )
(princ)
)

CTC 发表于 2012-9-12 15:43:42

源码给我,加上天非专用插件www.tifchina.com版权信息???
大笑三声

天非深化设计 发表于 2012-9-12 15:46:41

CTC 发表于 2012-9-12 15:43 static/image/common/back.gif
源码给我,加上天非专用插件www.tifchina.com版权信息???
大笑三声

按我上面的要求编写。至于版权信息,必须的,因为我是悬赏贴。这个图层也是我们专用的。

天非深化设计 发表于 2012-9-12 15:48:07

本帖最后由 天非深化设计 于 2012-9-12 15:51 编辑

以下是变色插件的源码,大家可以参考一下!

;;IDSPA.CN颜色及线型数字快捷键

;--------------------------------------------------------- `
(defun c:Y(/ ent)
(setq ent (ssget))
(command "change" ent "" "p" "c" "bylayer" "")
)
(defun c:cy()
(command "-color" "bylayer" )
)
;--------------------------------------------------------- 0
(defun c:0(/ ent)
(setq ent (ssget))
(command "change" ent "" "p" "c" "byblock" "")
)
(defun c:c0()
(command "-color" "byblock" )
)
;--------------------------------------------------------- 1
(defun c:1(/ ent)
(setq ent (ssget))
(command "change" ent "" "p" "c" "1" "")
)
(defun c:c1()
(command "-color" "1" )
)
;--------------------------------------------------------- 2
(defun c:2(/ ent)
(setq ent (ssget))
(command "change" ent "" "p" "c" "2" "")
)
(defun c:c2()
(command "-color" "2" )
)
;--------------------------------------------------------- 3
(defun c:3(/ ent)
(setq ent (ssget))
(command "change" ent "" "p" "c" "3" "")
)
(defun c:c3()
(command "-color" "3" )
)
;--------------------------------------------------------- 4
(defun c:4(/ ent)
(setq ent (ssget))
(command "change" ent "" "p" "c" "4" "")
)
(defun c:c4()
(command "-color" "4" )
)

yokees 发表于 2012-9-12 16:41:57

这版权肯定不可能给你,楼主还是不要多想了。

天非深化设计 发表于 2012-9-12 16:44:34

yokees 发表于 2012-9-12 16:41 static/image/common/back.gif
这版权肯定不可能给你,楼主还是不要多想了。

恩,行吧,给我把他编写成LSP吧!

念一份安逸 发表于 2012-10-24 11:12:44

lijiao 发表于 2012-9-12 15:40 static/image/common/back.gif
(defun c:11 ( / )
(to-lay "1-TIF-原墙体")
(princ)


怎么不好用啊   求指教

atone 发表于 2024-2-12 15:25:53

http://bbs.mjtd.com/plugin.php?id=imc_attachplug:attachad&aid=NjU3NDN8Zjc2ZTVlNTl8MTcwNzcyMjcyM3w3MzMxNTI2fDcwMDA5;非常好的图层切换工具
页: [1]
查看完整版本: 悬赏求图层切换工具,(类似变色插件)欢迎各位高手赐教!