MISAH Posted January 19, 2018 Posted January 19, 2018 (edited) Hi, I have a problem that I have many drawings which contain number of the same block which should be hide. Based on tips from another threads I came up the following solution which I don't know how to utilize. First -> I use lisp which create new layer, then blocks with the same name are moved to this layer. For example something like this: (vl-load-com) ;Load VLisp extensions ;; Function to change bllocks to a layer by wildcard (defun Blk2Lay (LName ss / n en eo) (if (not (tblobjname "LAYER" LName)) ;Check if layer doesn't exist (command "._LAYER" "_Make" LName "") ;Make the layer ) ;_ end of if (setq n (sslength ss)) ;Initialize counter (while (>= (setq n (1- n)) 0) ;Step through all entities in selection set (setq en (ssname ss n) ;Get the nth EName eo (vlax-ename->vla-object en) ;Get the ActiveX object ) ;_ end of setq (vla-put-Layer eo LName) ;Change block reference to new layer ) ;_ end of while ) ;_ end of defun ;; Command to change blocks to a layer by wildcard (defun c:Blk2Lay (/ LName BWild ss) (if (setq LName (getstring "Enter the layer's name: ")) ;Get the layer's name (if (and (or (and (= (setq BWild (getstring ;Get wildcard, default as layer name (strcat "Enter the wildcard for the block name <*" LName "*>: ") ) ;_ end of getstring ) ;_ end of setq "" ) ;_ end of = (setq BWild (strcat "*" LName "*")) ;Default to LName ) ;_ end of and (and BWild (/= BWild "")) ) ;_ end of or (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BWild)))) ;And some blocks found ) ;_ end of and (Blk2Lay LName ss) ;Perform the change ) ;_ end of if ) ;_ end of if (princ) ) ;_ end of defun Second - > I changed property of this layer to non visible. Third - > I applied above changes on selected drawings. Based on another example I found that there is possible to use LISP getfiles as well as ObjectDBX Wrapper which allow to use another function like below: //This is example of script which remove blocks with name "KOLKO' from selected drawings (defun c:dbtest ( / lst ) (if (setq lst (LM:getfiles "Select Drawings to Process" nil "dwg;dws;dwt")) (LM:odbx '(lambda ( doc ) (LM:deleteblocks doc '("KOLKO"))) lst t) (princ "\n*Cancel*") ) (princ) ) Can anyone help me how I can solve my problem? Edited January 22, 2018 by SLW210 Added Code Tags! Quote
ReMark Posted January 19, 2018 Posted January 19, 2018 Will the "hidden" layer be turned off or will it be frozen? Quote
MISAH Posted January 19, 2018 Author Posted January 19, 2018 It doesn't matter in this case. They may be hidden or frozen. I just wanna keep these blocks, but not remove them Quote
ReMark Posted January 19, 2018 Posted January 19, 2018 I think it would make a difference. You might want to provide a sample drawing for anyone who wishes to help you to test their code against. Be specific about which blocks must be "hidden" and the method you prefer. We'll need a .dwg file not an image file. Quote
MISAH Posted January 19, 2018 Author Posted January 19, 2018 Right now I can only try to explain my problem more in detail using examples which are comparable to my primary ones. Of course number of drawings in my case is much more bigger. Example. I have three drawings - lets assume: 1.dwg - 2 obejcts of the same block named "KOLKO" which are on 0 layer. For example, block represents circle put somewhere two times. 2.dwg - 1 object of the block named "KOLKO" - 0 layer. 3.dwg - 5 objects of the block named " - 0 layer. Another objects if they exist, don't care me. Now I open file 1.dwg and I want to move all objects of block "KOLKO" to the new layer, for example TEST, and set this layer as hidden. And without opening another drawing repeat this action. Using LISP http://www.lee-mac.com/getfilesdialog.html I can choose which drawings should be applied (in this example 1.dwg, 2.dwg, 3.dwg). Then using LISPhttp://www.lee-mac.com/odbxbase.html I want to utilize script (code showed in first post) which allows to create new layer and select, by name of the block, objects which will be moved. Unfortunately I don't know also how to change layer property on hidden option. Maybe there is easier way to do it becuase I saw scirpt which allow move all object of the block to another layer by selecting one of them. But there is a constrain that destination layer must exists in all drawings. But it's not a problem becuase I know how to do it in another way without need to use LISP to change layer on hidden. But still I don't know how to apply particular scipt on all selected drawings, using this LISPhttp://www.lee-mac.com/odbxbase.html I am not familiar with LISP so this is a reason why it is hard to me find out how it works :/ Quote
SLW210 Posted January 19, 2018 Posted January 19, 2018 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
BIGAL Posted January 20, 2018 Posted January 20, 2018 A simple layer situation (command "-layer" "off" layername "") or freeze. Wildcards can be used also -layer off k* Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.