LAYMRG but allowing current layer and not asking if I am sure

LAYMRG but allowing current layer and not asking if I am sure

aitorm
Advocate Advocate
1,207 Views
13 Replies
Message 1 of 14

LAYMRG but allowing current layer and not asking if I am sure

aitorm
Advocate
Advocate

Hi, first of all, thanks.

 

"LAYMRG but allowing current layer and not asking if I am sure". Title says all. I use a lot this command but this two things gives me some anxiety. For creating this, I think all the command code must be rewritten in a lsp, and I don't know how to face that.

 

If the current layer is the one that will dissapear, then change layers to the new one. I don't need to preview things as the original command does.

 

Thanks again,

 

PS. Why does people program "Are you sure" steps when cntrl+Z exists?

 

aitor

0 Likes
Accepted solutions (2)
1,208 Views
13 Replies
Replies (13)
Message 2 of 14

paullimapa
Mentor
Mentor

You should submit that to product feedback 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 14

Moshe-A
Mentor
Mentor

@aitorm hi,

 

Create a tool button and copy and paste this macro...with 2 clicks you now merge layers (the current layer can not be picked first)

 

Moshe

 

 

[LMG]^C^CLAYMRG \;\yes

 

Message 4 of 14

aitorm
Advocate
Advocate

Thanks 🙂 still looking to something I can convert to a command

0 Likes
Message 5 of 14

Kent1Cooper
Consultant
Consultant

@aitorm wrote:

....

If the current layer is the one that will dissapear,

....


That raises the question:  Do you always and only use this to merge only one source Layer into a target Layer?  LAYMRG allows you to merge multiple source Layers into a single target Layer -- would that ever be part of what you want to do with a presumed custom command?

Kent Cooper, AIA
0 Likes
Message 6 of 14

aitorm
Advocate
Advocate
Only one is ok :). If I need two (only occasionaly) then I prefer to repeat the command.

thanks
0 Likes
Message 7 of 14

pendean
Community Legend
Community Legend

@aitorm CLAYER will need to be set to 0 (always there and always on/thawed is how it needs to be) before you can continue with LAYMRG the way you want. If you need the destination to then become active, add that too.

 

Do you need help writing that up?

 

How will you choose the destination layer?
And will the source layer always, ALWAYS, be the active layer?

0 Likes
Message 8 of 14

aitorm
Advocate
Advocate
Thank you so much. I've got no idea how to do this, so I would apreciate it if you could write it.

1.— The destination layer could be chosen as it is done in laymerge: choosing an object in that layer.
2.— No, the source layer has to be choosen too, selecting an object as in the laymerge command.
0 Likes
Message 9 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

@aitorm wrote:
Only one is ok :). If I need two (only occasionaly) then I prefer to repeat the command.

Then it seems simple enough:

 

(defun C:LAYMRG2 ()
  (command
    "_.layer" "_thaw" "0" "_set" "0" "" ; can't be merged
    "_.laymrg" pause "" pause "_yes"
  )
  (prin1)
)

 

It's up to you to not pick as source Layer something on Layer 0 or a locked Layer.  It could probably be made to control for that kind of thing, but maybe it's not worth it -- if you pick something on a locked Layer, presumably that's the one you want to Merge, so having it ask you to select again [i.e. something on a different Layer] would be pointless, and you'll need to get out of the command anyway, and thaw that Layer if that's what you really want, or not if there's good reason for it to be locked.

Kent Cooper, AIA
0 Likes
Message 10 of 14

aitorm
Advocate
Advocate
Great!
That is a big change for the Laymrg command. Next step would be to be able to merge current layer even if it is 0, and let you choose several layers. But, this is a nice improvement for my life 🙂 thanks
0 Likes
Message 11 of 14

Kent1Cooper
Consultant
Consultant

@aitorm wrote:
.... Next step would be to be able to merge current layer even if it is 0, ....

Not possible.  You could presumably have something that would take everything on that Layer and put it on a different one.  But LAYMRG removes the merged Layer from the drawing, and does not permit you to select something on Layer 0 for merging, whether or not it's current.

 

Command: LAYMRG
Select object on layer to merge or [Name]: {picked something on Layer "0"}
Cannot merge layer "0".

 

[If it's current, the "top-level" scolding is that you can't merge the current Layer -- it doesn't scold you twice for violating both restrictions at the same time.]  That's why Layer "0" is the universal and unequivocal switch-to for when you want to merge what's the current Layer when you call the earlier command, into something else -- it can never be the Layer that is to be merged into another.

Kent Cooper, AIA
Message 12 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

@aitorm wrote:
... and let you choose several layers. ...

It shouldn't be hard to do that* if you are willing to always pick something on the target Layer, and not use the Name option.  That way, the pause for that pick can have the Yes answer built in right after it.  If you might want to be able to use the Name option, I'd have to think about how [whether?] that could be constructed to allow two inputs instead of one before the Yes answer.

* EDIT:

(defun C:LAYMRG3 (/ esel layname laylist laystr)
  (while (setq esel (entsel "\nSelect object on Layer to Merge <Enter when done>: "))
    (setq layname (cdr (assoc 8 (entget (car esel)))))
    (if
      (and
        (/= layname "0"); [can't be merged]
        (not (member layname laylist)); not already picked
      ); and
      (setq ; then
        laylist (cons layname laylist)
        laystr (strcat (cond (laystr) ("")) layname ",")
      ); setq
    ); if
    (sssetfirst nil (ssget "_X" (list (cons 8 laystr))))
      ; highlight all on selected Layer(s) to discourage duplication
  ); while
  (if (member (getvar 'clayer) laylist)
    (command "_.layer" "_thaw" "0" "_set" "0" ""); then
  ); if
  (command "_.laymrg")
  (foreach layname laylist (command "_name" layname))
  (command "" pause "_yes"); Layer to merge into [User pick]
  (prin1)
)
Kent Cooper, AIA
Message 13 of 14

aitorm
Advocate
Advocate
Hurrah! Tooons of thanks!!!

No need for me to choose by name, I never do that (I find it more complicated to write the name correctly than drawing a line in that layer and then selecting it).



0 Likes
Message 14 of 14

aitorm
Advocate
Advocate
This makes a lot of sense, so basic. Also, merging layer 0 could be dangerous, as it is used for giving inherit properties to blocks objects.

Thanks
0 Likes