Alternative to LAYMCUR that works in noun verb mode.

Alternative to LAYMCUR that works in noun verb mode.

John_in_NZ
Enthusiast Enthusiast
1,084 Views
16 Replies
Message 1 of 17

Alternative to LAYMCUR that works in noun verb mode.

John_in_NZ
Enthusiast
Enthusiast

Hey folks,

I'm not sure why this is causing me so much frustration, but it might be because my current clients drawings are such a mess ... I thought that by now people would understand the importance of drawing BYLAYER ... 🙄

Anyway, I'm so used to selecting an object, and then deciding what I want to do with it that the LAYMCUR command is making me pull my hair out, but I do recall that in the dark ages of Release 10 that there's was a lisp routine that allowed you to pre-select the layer that you want to make CURRENT, but I can't remember what it was called, so if someone could point me in the general direction of something that gives that functionally, I'd be grateful. 

 

Alternatively, if there's a way to create a little macro to pass a preselected object to the LAYMCUR command, that would work too.

 

TIA

John

0 Likes
Accepted solutions (1)
1,085 Views
16 Replies
Replies (16)
Message 2 of 17

john.uhden
Mentor
Mentor

@John_in_NZ ,

Ya know, I think that most of us lispers tend to make our routines initiate with verbs whereas it is little work to check for an existing selection set.

I think that decades ago (before LAYMCUR) I had a routine that would do the same thing, but I opted for a routine (MakeCurrent) that would set a whole lot more properties current, like for Hatching, MLeaders, Polylines, etc.  Out of habit (since 1989) I have used the verb/noun method.

Do you think that all of we contributors should adopt the possible noun/verb method (if there is an existing selection set)?

John F. Uhden

Message 3 of 17

John_in_NZ
Enthusiast
Enthusiast

@john.uhden Yep, my experience with Acad also dates back to '89 ... 😎

 

When it comes to encouraging folks to consider implementing noun/verb behaviour for lisp routines, it does seem like a good idea, however, the majority of the lisps and scripts that I use regularly are designed to perform one particular function so I think that noun/verb behaviour is less of a concern in that situation ... $0.10 ... 🙂

When it comes to the MakeCurrent lisp, I've managed to track it down in the forum, and I think my limited Lisp skills should be enough to edit it to the point where it only sets the layer, rather than inheriting any properties that have been overridden by the user ... 😎

 

If anyone else has any comments or suggestions, please keep 'em coming.

0 Likes
Message 4 of 17

Kent1Cooper
Consultant
Consultant

It has to be slightly more restrictive than just accepting pre-selection -- it needs to be pre-selection of only one object.  Try this:

 

;|
LMC command [like LAYMCUR but accepting single pre-selected object]
Kent Cooper, 2 November 2023
|;
(defun C:LMC (/ getobj ss ent); = Layer Make Current
  (defun getobj ()
    (while (not ent)
      (setq ent (car (entsel "\nSelect one object to set its Layer current: ")))
    ); while
  ); defun
  (cond ; OBJECT SELECTION
    ( (and
        (setq ss (ssget "_I")); something pre-selected
        (= (sslength ss) 1); only one object
      ); and
      (setq ent (ssname ss 0))
    ); first condition [single pre-selected object]
    ( (ssget "_I"); more than one object selected
      (sssetfirst nil); un-select multiple objects
      (getobj); User select
    ); second condition
    ((getobj)); User select [nothing pre-selected]
  ); cond
  (setvar 'clayer (cdr (assoc 8 (entget ent))))
  (prin1)
); defun

 

Kent Cooper, AIA
Message 5 of 17

ВeekeeCZ
Consultant
Consultant

Just out of interest. What versions are you all talking about? AFAIK the built-in LAYMCUR version accepts both methods... since I remember. Which is not '89 but still...

Message 6 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

@ВeekeeCZ wrote:

Just out of interest. What versions are you all talking about? AFAIK the built-in LAYMCUR version accepts both methods... ..


You're right, it works with pre-selection in Acad2024, either by typing in or picking the ribbon icon.  And like my LMC command, if you have more than one thing selected, it clears them and asks you to pick one.  [I'll be able to check 2020 from a different location later.]

EDIT:  Same in Acad2020.  So @John_in_NZ, are you using an older version in which perhaps it doesn't work?  Need updates?  Re-installation?  Does it work in some drawings but not others, and would AUDITing those others fix it?

Kent Cooper, AIA
Message 7 of 17

komondormrex
Mentor
Mentor

hey there,

no need for laymcur. reactor is better thing to do it. pick an object and instantly current layer becomes one of the picked object. different layers in picked objects - no change.

check the following code.

 

 

;*******************************************************************************************************************

(defun pickfirst_check (reactor_object pickfirst_changed / layer_list)
	(if (> (vla-get-count (vla-get-pickfirstselectionset (vla-get-activeDocument (vlax-get-acad-object)))) 0)
		(progn
			(vlax-for selected_item (vla-get-pickfirstselectionset (vla-get-activeDocument (vlax-get-acad-object)))
				(setq layer_list (append layer_list (list (vla-get-layer selected_item))))
			)
			(if (apply '= layer_list) (setvar 'clayer (car layer_list)))
		)
	)
)

(if (/= 'vlr-miscellaneous-reactor (type pickfirst_reactor))
	(setq pickfirst_reactor (vlr-miscellaneous-reactor nil '((:vlr-pickfirstmodified . pickfirst_check))))
)

;*******************************************************************************************************************

 

 

 

Message 8 of 17

Kent1Cooper
Consultant
Consultant

@komondormrex wrote:

hey there,

.... reactor is better thing to do it. pick an object and instantly current layer becomes one of the picked object. ....


[That's an interesting concept, and some people may find it useful, but it would never work for me.  I far too often have any number of reasons to select something when I don't need or want its Layer to become current, for example just to Move (or Rotate or Copy or....) something by grip-editing, or edit some Text/Mtext content, or just look at some property or other.  The current Layer would be constantly jumping around for no reason.  But it's an option available to those who want it.]

Kent Cooper, AIA
Message 9 of 17

John_in_NZ
Enthusiast
Enthusiast

@ВeekeeCZ I'm using a vanilla copy of Acad 2023, and noun / verb isn't working.

 

Unfortunately, my copy of acad2023 expired earlier this year, and my current client is providing the hardware and software so I can't play about to see if there is a setting that might disable noun / verb, so if you know of any way of enabling the desired functionality, I'd love to hear it ... 🙂

0 Likes
Message 10 of 17

Kent1Cooper
Consultant
Consultant

Does noun-verb operation work in other commands?  If not, look into the PICKFIRST System Variable.  If that's already set for it, I don't what else to suggest other than to check for updates, or maybe a re-installation or something.

Kent Cooper, AIA
Message 11 of 17

john.uhden
Mentor
Mentor

@ВeekeeCZ ,

1989?

Is it your memory that's short, or were you born after 1989?  😅

I remember trying to trim polyline contours on a 386.  Took about 5 mins. per trim, so I actually fell asleep at the keyboard and tablet.

John F. Uhden

Message 12 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

That's funny to me that you used (ssget "_I") as I always use (ssgetfirst), but I don't think there's any difference.

Anyway, I think that's a great solution!

John F. Uhden

Message 13 of 17

Sea-Haven
Mentor
Mentor

Noun/verb is in OPTIONS. I think its "user preferences" 

 

 

(defun c:zzz ( /)(setvar 'clayer (cdr (assoc 8 (entget (car (entsel "\nPick object for layer")))))

 

 

The zzz is easy to type compared to say laymcur.

Message 14 of 17

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

That's funny to me that you used (ssget "_I") as I always use (ssgetfirst), but I don't think there's any difference. ....


There's a difference in code length / number of functions / amount of parentheses, if that matters.  You're looking for a selection set, but since (ssgetfirst) returns a list, of which the selection set you want is only the second item, to get that set into a variable you need to do:

(setq test (cadr (ssgetfirst)))

[or, if you prefer, (last)], whereas this gives you that selection set directly:

(setq test (ssget "_I"))

 

Kent Cooper, AIA
Message 15 of 17

John_in_NZ
Enthusiast
Enthusiast

Thanks for all the replies, they're all much appreciated ... 😎

However, I've come into the office and LAYMCUR is behaving as some of you have said it should, and how I suspected it should, so there's obviously something that's not 100% with the system, but whether the problem is down to a corrupt drawing, a corrupt system file, aging hardware, or an aging user I'm not in the mood to analyse any further, at least not for the moment.

Once again, many thanks ... 🙂

0 Likes
Message 16 of 17

John_in_NZ
Enthusiast
Enthusiast

@john.uhden Presumably you also use to suffer from RSI from repeatedly stretching to reach the commands at the furthest reaches of the digitizer tablet.

I'm pretty sure I've got a digitizer overlay that came with ... dunno, maybe R14 or or something equally antiquated ... 🤣

0 Likes
Message 17 of 17

ВeekeeCZ
Consultant
Consultant

Also try QAFLAGS, this affects the pre-selection as well.

0 Likes