Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing layers in LISP

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
197 Views, 5 Replies

Changing layers in LISP

I've written a little routine to do a 66 Road Right of Way offset, what I wanted to happen was have the orginal line selected to change to our company's default Centerlines layer (all of our drawings have this layer), but when I run the routine it doesn't change the layer, am I doing something wrong?

Here is the code:

;;OFFSET ROW LINES AT 33 FEET ON BOTH SIDES OF CENTERLINE
;;Created August 3, 2007 (C) Nathan Karnes

(defun c:rowoffset (/ ent dist obj kwrd)
(vl-load-com)
(while (not ent)
(if (eq (setq ent (car (entsel "\n Please select line to multi-offset: ")))
nil
)
(princ "\nTHe object you have chosen is not a line! Please select a line to multi-offset: ")
)
)
(initget (+ 1 2 4 64))
(setq dist 33)
(initget (+ 2 4) "Yes No")
(setq kwrd (getkword "\nDo you wish to put selected line on Centerlines layer? [Yes/No] : "))
(if (/= kwrd "No")
(setq kwrd "Yes")
)
(setq obj (vlax-ename->vla-object ent))
(vla-offset obj dist)
(vla-offset obj (* dist -1))
(if (eq kwrd "Yes")
(command "_layer" ent "CENTERLINES")
)
(princ)
)
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

You can't use the LAYER command to change an entity's layer property. Use
CHPROP.
___

wrote in message news:5683652@discussion.autodesk.com...
(if (eq kwrd "Yes")
(command "_layer" ent "CENTERLINES")
)
Message 3 of 6
Anonymous
in reply to: Anonymous

Since you have, and use the object of the line, then just change this line
(command "_layer" ent "CENTERLINES")
to
(vla-put-Layer obj "CENTERLINES")


The layer command is used to create layers, not to change the layers of
entities.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5683652@discussion.autodesk.com...
I've written a little routine to do a 66 Road Right of Way offset, what I
wanted to happen was have the orginal line selected to change to our
company's default Centerlines layer (all of our drawings have this layer),
but when I run the routine it doesn't change the layer, am I doing something
wrong?

Here is the code:

;;OFFSET ROW LINES AT 33 FEET ON BOTH SIDES OF CENTERLINE
;;Created August 3, 2007 (C) Nathan Karnes

(defun c:rowoffset (/ ent dist obj kwrd)
(vl-load-com)
(while (not ent)
(if (eq (setq ent (car (entsel "\n Please select line to multi-offset:
")))
nil
)
(princ "\nTHe object you have chosen is not a line! Please select a
line to multi-offset: ")
)
)
(initget (+ 1 2 4 64))
(setq dist 33)
(initget (+ 2 4) "Yes No")
(setq kwrd (getkword "\nDo you wish to put selected line on Centerlines
layer? [Yes/No] : "))
(if (/= kwrd "No")
(setq kwrd "Yes")
)
(setq obj (vlax-ename->vla-object ent))
(vla-offset obj dist)
(vla-offset obj (* dist -1))
(if (eq kwrd "Yes")
(command "_layer" ent "CENTERLINES")
)
(princ)
)
Message 4 of 6
Lee Barnard
in reply to: Anonymous

Use (command "chprop" "la" ""CENTERLINES" "") instead

or,
(setq E (entsel))
(setq ENTLIST (entget (car E)))
(setq ENTLIST (subst (cons 8 "CENTERLINES")
(assoc 8 ENTLIST) ENTLIST)
)
(entmod ENTLIST)
(setq E (entnext E))
Message 5 of 6
Anonymous
in reply to: Anonymous

Thank you to everyone for their help, works ike a charm now, does anyone know if you can run a selection window and run the offset section of my code to offset all the lines in the selection set? THAT would be awesome, and would save over 3 hours of putz work. Any ideas would be greatly appreciated, also everyone can feel free to use the program I wrote (you all probably have it anyway, but what the heck)
Message 6 of 6
Anonymous
in reply to: Anonymous

Once you get your selection set, just step through it like you do applying
the logic to each object. Something like

(if (setq ss (ssget))
(progn
(setq cnt 0)
(while (setq Ent (ssname ss cnt))
(setq Obj (vlax-ename->vla-object Ent))
..... here you do your offset, and change layers ...
(setq cnt (1+ cnt))
)
)
)

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5683674@discussion.autodesk.com...
Thank you to everyone for their help, works ike a charm now, does anyone
know if you can run a selection window and run the offset section of my code
to offset all the lines in the selection set? THAT would be awesome, and
would save over 3 hours of putz work. Any ideas would be greatly
appreciated, also everyone can feel free to use the program I wrote (you all
probably have it anyway, but what the heck)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost