Author Topic: separating layer names within a script  (Read 1787 times)

0 Members and 1 Guest are viewing this topic.

Dave M

  • Newt
  • Posts: 196
separating layer names within a script
« on: July 31, 2018, 06:08:37 PM »
Hey there,


I was wondering if someone could help me with this script.  I am changing the color of several layers and I was thinking that I could list all the layers that will be changed on one line, but I can't get it to work.  The script that is attached works,  but I was hoping to be able to condense it.


Would someone be willing to look at this and possibly tell me what i am doing wrong?


Thanks
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

BIGAL

  • Swamp Rat
  • Posts: 1418
  • 40 + years of using Autocad
Re: separating layer names within a script
« Reply #1 on: July 31, 2018, 11:00:01 PM »
You can have lisp in a script  so you could make a list of color and layername then just loop trough them. just easier to call the lisp direct

Code: [Select]
(setq lst (list
"0,0,255" "318038_TOPO_001|EX-P IRR"
"0,0,255" "318038_TOPO_001|EX-SPRINKLER"
"0,0,255" "318038_TOPO_001|EX-WATER"
"0,0,255" "318038_TOPO_001|EX-WELL"
"0,255,0" "318038_TOPO_001|EX-SD"
"0,255,0" "318038_TOPO_001|EX-SEWER"
"127,0,255" "318038_TOPO_001|EX-IRR"
"204,204,0" "318038_TOPO_001|EX-GAS"
"204,204,0" "318038_TOPO_001|EX-GAS LOC PAINT"
"255,0,0" "318038_TOPO_001|EX-POWER"
"255,0,0" "318038_TOPO_001|EX-POWER LOC PAINT"
"255,127,0" "318038_TOPO_001|EX-FIBER OPTIC"
"255,127,0" "318038_TOPO_001|EX-SIGNAL"
"255,127,0" "318038_TOPO_001|EX-SIGNAL LOC PAINT"
"255,127,0" "318038_TOPO_001|EX-TELE"
"255,127,0" "318038_TOPO_001|EX-TELE LOC PAINT"
))
(setq x 0)
(repeat (/ (length lst) 2)
(command "vplayer" "C" "T" (nth x lst) (nth (+ x 1) lst) "Current" "")
(setq x (+ x 2))
)
« Last Edit: July 31, 2018, 11:04:13 PM by BIGAL »
A man who never made a mistake never made anything

Dave M

  • Newt
  • Posts: 196
Re: separating layer names within a script
« Reply #2 on: August 01, 2018, 10:59:28 AM »
Thanks BIGAL,


I don't have to do this very often, so I am okay with just writing a script.  I was really just hoping to be able to simplify the script by having the layers grouped together on one line, e.g. layer1,layer2, etc.  I tried it in AutoCAD at the command line and it seemed to work.  I must be doing something wrong.  Some of the layer names have spaces in them so I put quotes around the names, but that didn't seem to matter.


Thanks again!
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox