Jump to content

Create Block of All Entities Except from Locked or Frozen Layer


MAzri

Recommended Posts

Hi everyone,

 

When handed over drawing from others, sometimes I had to deal with drawing with base layout that are not blocked but instead of 'exploded' geometries. This lead to hard time editing drawing where I cannot box-select essential item in my services without selecting layout items. Locking there layout geometries are simple but time consuming as there are normally consisted of almost up to hundred of layers (architects drawing, topo surveys, civil infra drawing, town planning drawing).

 

Is there any way I can just lock layers of my services and block the rest of items in all unlocked layer and name the block with user input?

 

I attached here a sample drawing with unblocked layout and locked layers of electrical services.

 

Thank you.

EM1029-ES-2001-2002.dwg

Link to comment
Share on other sites

AS a quick thought - not written this to check it works, but it will give you something to do on a Friday...

 

If you look at Lee Macs SSGet reference page (it is on an internet search), there is an option (ssget "_A") to select everything in the drawing apart from locked layers. Also an option to exclude frozen layers (+_:F I think), but can't remember just now if you can combine both these options to exclude locked and frozen items from a selection.

 

This might be able to be modified to wblock through a LISP

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/wblock-lisp-routine/td-p/2696828

 

So.... if it was me I might be tempted to write block using the LISP in the link, using the ssget "_A" to exclude locked layer - locking the layers of all the stuff you want to keep. Since it is in LISP you should be able to specify a temporary file name for the wblock - delete what you don't need in your original, purge all a couple of times and insert the block you just created.

 

 

Else without the wblock command, you can copy everything in the selection set (above) to the clipboard (-copybase with a base point of 0,0,0), delete everything in that selection set, purge (not always needed but why not, and then pasteblock.

 

 

The key to it all is the ssget though - see how you get on with that idea

Link to comment
Share on other sites

My 0.02¢ xref the drawings in question. This is what I did for my old job anything that was reference drawing (arch, sprinkler, civil) I would open their drawing change everything to 252 color and then xref into my drawing.

with plot styles 252 color was set to 50% screening. Meaning anything drawing by me would pop and the reference drawing was still seen but muted.

 

Only draw back is if you move project folders you will have to tell autocad where the xref files are located.

  • Like 2
Link to comment
Share on other sites

22 hours ago, Steven P said:

AS a quick thought - not written this to check it works, but it will give you something to do on a Friday...

 

If you look at Lee Macs SSGet reference page (it is on an internet search), there is an option (ssget "_A") to select everything in the drawing apart from locked layers. Also an option to exclude frozen layers (+_:F I think), but can't remember just now if you can combine both these options to exclude locked and frozen items from a selection.

 

This might be able to be modified to wblock through a LISP

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/wblock-lisp-routine/td-p/2696828

 

So.... if it was me I might be tempted to write block using the LISP in the link, using the ssget "_A" to exclude locked layer - locking the layers of all the stuff you want to keep. Since it is in LISP you should be able to specify a temporary file name for the wblock - delete what you don't need in your original, purge all a couple of times and insert the block you just created.

 

 

Else without the wblock command, you can copy everything in the selection set (above) to the clipboard (-copybase with a base point of 0,0,0), delete everything in that selection set, purge (not always needed but why not, and then pasteblock.

 

 

The key to it all is the ssget though - see how you get on with that idea

 

I think I got the basic idea. The only problem is I'm mostly a beginner and whenever I'm try to create any routine, I always refer to other code and not writing my own. The way I went about coding is referring to other code, looking for likely solution and modified it to suit what I need to do. 

 

20 hours ago, mhupp said:

My 0.02¢ xref the drawings in question. This is what I did for my old job anything that was reference drawing (arch, sprinkler, civil) I would open their drawing change everything to 252 color and then xref into my drawing.

with plot styles 252 color was set to 50% screening. Meaning anything drawing by me would pop and the reference drawing was still seen but muted.

 

Only draw back is if you move project folders you will have to tell autocad where the xref files are located.

 

I got what you mean and I do did practice it like that. However, my situation is not that I'm working a file on my own from beginning, rather that what would I do if I got that drawing from someone like I attached. When I got that drawing, making that layout into xref is just a hassle and time consuming. 

  • Like 1
Link to comment
Share on other sites

50 minutes ago, MAzri said:

I think I got the basic idea. The only problem is I'm mostly a beginner and whenever I'm try to create any routine, I always refer to other code and not writing my own. The way I went about coding is referring to other code, looking for likely solution and modified it to suit what I need to do. 

 

The last one I put together for someone on here was all copied from the internet - nothing wrong with that!

 

Might try something like:

(defun c:testthis ( / MySS )               ; define the function, thest this, define local variables after the '/'
  (setq MySS (ssget "_A") )                ; Make a selection set - a selection of everything (ssget) with a filter "_A" - excluding locked layers
  (command "copybase" (list 0 0) MySS "")  ; Run the CAD command "Copybase". Whjat is after it is all the imputs you'd normally do
)

 

as a simple start to copy everything on the drawing apart from locked layers. Added some notes - it isn't too hard to follow these 4 lines though

 

From there just search out each step as you need - perhaps the next one is "how to delete a selection set" and just add it in, using MySS

 

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thank you Steven P! This turn out simpler than i though it would be!

 

I got the basic what i need with that code with below. Later I would need to set so that the new layout will be created in a new layer with new name. And also maybe user input of the new block name and also prompt to say that the process completed or something so that user aware of the completed process.

 

(defun c:testthis ( / MySS )               ; define the function, thest this, define local variables after the '/'
  (setq MySS (ssget "_A") )                ; Make a selection set - a selection of everything (ssget) with a filter "_A" - excluding locked layers
  (command "copybase" (list 0 0) MySS "")  ; Run the CAD command "Copybase". Whjat is after it is all the imputs you'd normally do
  (command "pasteblock" (list 0 0))
  (command "erase" MySS "")
)

 

  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...