Author Topic: Question on Layers and changing Layers through code  (Read 2278 times)

0 Members and 1 Guest are viewing this topic.

AVCAD

  • Guest
Question on Layers and changing Layers through code
« on: November 07, 2007, 11:05:27 AM »
I have this little problem here, that is very time consuming.

We have our Company Standard layers, and on some projects we need to change those layers to suite a some very anal clients to match their standard which they claim to be based on AIA standards but is no where near the stanards. Anywho....

Is there a way to change Our Layers to their layers. I guess it would be a simple rename layer1 to layer2 but I dont want to use the standards checker cause its pretty time consuming and you have to manually tell Autocad to change layer1 to layer2.

So if there is a way to write that in a lisp or a script even would great. Yes I said script good old scriptpro is still a main program i use I can work 24 hours and be sitting on my couch for 4 of them! lol

As always thanks for the help.


VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Question on Layers and changing Layers through code
« Reply #1 on: November 07, 2007, 11:36:46 AM »
what's bad about "_laytrans"?

AVCAD

  • Guest
Re: Question on Layers and changing Layers through code
« Reply #2 on: November 07, 2007, 11:51:21 AM »
doing that on projects that are over 800 sheets is an extreme waste of time and money.

Now If I can do it in a script that would be awesome. Scripts allow me to use multiple computers or just let it run over night with out taking money out of the budget seeing as there is no human sitting there, I cant justify billing out overtime if its just a computer working, I know I could but....

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Question on Layers and changing Layers through code
« Reply #3 on: November 07, 2007, 12:16:33 PM »
just execute "_laytrans", create a template and then you can use (acet-laytrans "filename" [settings])

AVCAD

  • Guest
Re: Question on Layers and changing Layers through code
« Reply #4 on: November 07, 2007, 12:29:32 PM »
hmm...yet another code feature i didn't know was there...I will have to look into this.

Thanks, be back later with more "huh?" questions lol.

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Question on Layers and changing Layers through code
« Reply #5 on: November 07, 2007, 12:43:00 PM »
hmm...yet another code feature i didn't know was there...I will have to look into this.

Thanks, be back later with more "huh?" questions lol.

Not exactly sure what you are trying to accomplish...but you could use this to rename a layer from one name to another.
Code: [Select]
(defun c:test (/ lays)
  (setq lays (vla-get-layers
       (vla-get-activedocument (vlax-get-acad-object))
     )
  )
  (vlax-map-collection
    lays
    '(lambda (x)
       (mapcar
'(lambda (y)
    (if (= (strcase (vla-get-name x)) (strcase (car y)))
      (vl-catch-all-error-p
(vl-catch-all-apply 'vla-put-name (list x (cdr y)))
      )
    )
  )
'(("name1" . "rename1") ("name2" . "rename2"));;ADD ALL YOUR LAYER NAMES TO THIS LIST
       )
     )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC