Layer Merge without deleting layers?

Layer Merge without deleting layers?

Anonymous
Not applicable
2,645 Views
9 Replies
Message 1 of 10

Layer Merge without deleting layers?

Anonymous
Not applicable

Looking for an idea...

 

My primary function with CAD is to maintain distribution warehouse drawings.

 

I developed a layer standard similar to the NCS... each layer has a prefix of N-, E-, M-, etc.... (New, Existing, Modified...)

 

At the end of a project, the New (N-) and Modified (M-) layers need to be "merged" to Existing (E-) layers because everything is installed and is no longer considered "new". My model then reflects "existing" and all objects are on the appropriate "existing" layers and my CAD file is ready for the next project. It's been a great way to recycle and update a single file over and over again.

 

Layer Merge works ok for this (I use a script), but the layers you're merging from (N-, M-, etc) are then deleted... I have these layers added back to the drawing file, but....... that short amount of time where the layers were merged/deleted, I also lose all of my VPFreeze settings throughout the drawing set.

 

So that's the long question, here's the short one: How can I merge two layers and keep both layers?

0 Likes
2,646 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Use "QSELECT"

You can select any object on the layer "New" and change them to existing.

There are many filters with the quick select popup and I use this feature every single day.

If you need any further guidance on the subject I would be glad to help.

QUICK.PNG

 

Please mark this as the solution if it has solved your problem.

 

 

 

0 Likes
Message 3 of 10

ArchD
Collaborator
Collaborator

If you are using a script to LAYMRG two layers together, you can also add to your script to recreate the layers in what ever state you want, frozen or what have you (of course this assumes that the (N-) and (M-) always have the same layer properties after making the layer migration).

 

So when you execute your script, it'll essentially move your objects to a new layer keeping all 3 layers.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 4 of 10

Kent1Cooper
Consultant
Consultant

If you use the QSELECT approach, you would need to do it separately for every N- and M- Layer, so that doesn't seem practical if there are any more than a very small number of them.  A routine could be made easily enough that would go through everything in the drawing, and if each object's Layer starts with either N- or M-, put it on the corresponding Layer that starts with E-.  BUT unlike the way LAYMRG works, that would not catch nested objects in Block definitions.  It could be done with additional code to step through all Block definitions and make the same Layer changes to the pieces.  Is that something that you would need to account for?

 

EDIT:  Not accounting for nested objects, try something like this [minimally tested]:

(defun C:A2EL (/ obj); = All {to} E- Layers
  (setq ss (ssget "_X")); everything in drawing
  (repeat (setq n (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
    (if (wcmatch (strcase (setq lay (vla-get-Layer obj))) "N-*,M-*")
      (vla-put-Layer obj (strcat "E-" (substr lay 3)))
    ); if
  ); repeat
  (princ)
); defun
Kent Cooper, AIA
Message 5 of 10

ChicagoLooper
Mentor
Mentor

Try this:

  1. Make the layer named EXISTING the current layer.
  2. Select an object on NEW layer and an object on MODIFIED layer, then right-click and choose SELECT SIMILAR.
  3. Click the CHANGE TO CURRENT LAYER icon (LAYCUR).

Change to Current Layer icon.Change to Current Layer icon.

All objects on NEW and MODIFIED layers will move to EXISTING layer and there will be no deleting of any layers.

 

Chicagolooper

EESignature

0 Likes
Message 6 of 10

ArchD
Collaborator
Collaborator

You could do something like this:

(defun c:MTE ( / ss )

	(setq ss (ssget "X" '((-4 . "<OR")(8 . "N-LIGHTS")(8 . "M-LIGHTS")(-4 . "OR>"))))
	(command
		"-layer"
		"S"
		"E-LIGHTS"
		""
		"_.LAYCUR"
		ss
		""
	)
(princ)
)

So anything on the layers N-LIGHTS and M-LIGHTS will move to E-LIGHTS.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes
Message 7 of 10

Kent1Cooper
Consultant
Consultant

@ChicagoLooper wrote:

.... Make the layer named EXISTING the current layer. ....  All objects on NEW and MODIFIED layers will move to EXISTING layer and there will be no deleting of any layers.


 

But I assume there are Layers such as [off-the-top-of-my-head possibilities] N-RACK, N-SHELF, N-LIGHT, M-RACK, M-SHELF, M-LIGHT, etc.  And there are Layers such as E-RACK, E-SHELF, E-LIGHT, etc. that things should be moved to, according to the endings of each object's current name without the N- or M- prefixes, not just a single EXISTING Layer.

Kent Cooper, AIA
0 Likes
Message 8 of 10

Kent1Cooper
Consultant
Consultant

@ArchD wrote:

You could do something like this:

(defun c:MTE ( / ss )

	(setq ss (ssget "X" '((-4 . "<OR")(8 . "N-LIGHTS")(8 . "M-LIGHTS")(-4 . "OR>"))))
	(command
		"-layer"
....

So anything on the layers N-LIGHTS and M-LIGHTS will move to E-LIGHTS.


 

Then you would need another for each type of Layer-name ending.  Also, using the (command) function, it will only get things in the current space.

 

See my EDIT to Message 4 [edited while some in-between Messages were coming in] for a routine that handles all possible such Layer names, and changes the Layers of eligible objects in all spaces.

Kent Cooper, AIA
0 Likes
Message 9 of 10

ArchD
Collaborator
Collaborator

Yeah, I'm not too advanced in Lisp so I use the rookie move of command. I need to learn more but I just wanted to give an idea of where to start. Fortunately you have already did a more advanced version. Kudos given. Solution should be accepted on post 4.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes
Message 10 of 10

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... 

EDIT:  Not accounting for nested objects, try something like this [minimally tested]: ....


 

Or, without selecting everything  in the drawing, only those things on eligible Layers, no test for Layer name is needed in stepping through the set:

(defun C:A2EL (/ ss n obj); = All {to} E- Layers
  (setq ss (ssget "_X" '((8 . "N-*,M-*")))); everything in drawing on eligible Layers
  (repeat (setq n (sslength ss))
    (vla-put-Layer
      (setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
      (strcat "E-" (substr (vla-get-Layer obj) 3))
    ); ...-put...
  ); repeat
  (princ)
); defun

I didn't do it that way before, because I thought the Layer name filter part would be case-sensitive, and it seemed possible that the Layer names might not always start with a Capital  N or M.  But I find in trying it that, as used in (ssget) filtering for Layer names like this, it does  find things in the other case situation.

Kent Cooper, AIA