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)
)