Author Topic: Get Layer Object from LayerName  (Read 6105 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Get Layer Object from LayerName
« Reply #15 on: April 02, 2014, 04:45:32 PM »
I love the way you make people work for their knowledge, Kerry. I know it's benefited me over the years.


Nah, I'm just a nasty bastard who enjoys inflicting pain.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BlackBox

  • King Gator
  • Posts: 3770
Re: Get Layer Object from LayerName
« Reply #16 on: April 02, 2014, 04:54:04 PM »
Example
Code - Auto/Visual Lisp: [Select]
Note that throws an error if the layer doesn't exist, so you might have to wrap it inside a vl-catch-all-apply.

FWIW -

The Add() Method will yield an existing, or create a new LayerTableRecord for the LayerName (string) passed, which is great for reactors that set a specific layer current prior to a given command execution, etc.

For the OP's situation though, the Item() Method is perfectly fine, given that the string passed is from a selected entity.

Cheers
"How we think determines what we do, and what we do determines what we get."

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Get Layer Object from LayerName
« Reply #17 on: April 02, 2014, 04:58:21 PM »

< .. >  but i want to use the vla- method.

mailmaverick,
When did you change your mind about what you wanted ?

1.2 seconds time difference for 25,000 iterations is miniscule.

I probably spend longer than that every 5 minutes finding a key on the keyboard.

Just to be fair , what happens is you run each of those routines on a drawing which doesn't contain the layer you want ?



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Get Layer Object from LayerName
« Reply #18 on: April 02, 2014, 05:12:35 PM »
I love the way you make people work for their knowledge, Kerry. I know it's benefited me over the years.


Nah, I'm just a nasty bastard who enjoys inflicting pain.
lol. Well, then I enjoy watching you annoying the hell out of everyone.  :-P
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Get Layer Object from LayerName
« Reply #19 on: April 02, 2014, 05:18:39 PM »
[< .. >
For the OP's situation though, the Item() Method is perfectly fine, given that the string passed is from a selected entity.

Cheers

I didn't know that (must have missed the memo) . If so, all the rules change.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BlackBox

  • King Gator
  • Posts: 3770
Re: Get Layer Object from LayerName
« Reply #20 on: April 02, 2014, 05:22:23 PM »
[< .. >
For the OP's situation though, the Item() Method is perfectly fine, given that the string passed is from a selected entity.

Cheers

I didn't know that (must have missed the memo) . If so, all the rules change.

I must have confused two different threads, regarding the selected entity part.  :-D
"How we think determines what we do, and what we do determines what we get."