View Full Version : turn last pickpoint into current layer?
airick01
2008-11-19, 06:04 AM
I'm looking for a quick lisp routine that will turn the layer of my last pick point into the current layer. basically the same thing as the 'laycur' command, but instead of a pickbox, it uses the 'lastpoint' or something similar. I just don't know enough about lisp to do this myself.
kennet.sjoberg
2008-11-19, 02:33 PM
lastpoint is a coordinate, and a coordinat do not have any layer information
but you can use lastpoint to select an object and use the layer information from it.
(defun c:test ( / )
(if (nentselp (getvar "LASTPOINT" ))
(setvar "CLAYER" (cdr (assoc 8 (entget (car (nentselp (getvar "LASTPOINT" )))))))
(princ "no object at point " )
)
(princ)
)
try
Command: id
and then run test
: ) Happy Computing !
kennet
prose
2008-11-19, 04:09 PM
try the command laycur
airick01
2008-11-19, 07:07 PM
Thanks for the lisp. It works, but not in the way I was hoping....
Ultimately, I am trying to insert one block onto multiple lines on different layers, and have this block take the layer of the line that I am inserting the block onto in one click.
My original thought was to:
1. insert block as normal and snap to line.
2. run lisp that takes the layer of my 'insertion point' and makes this the current layer. ( the lisp I just got)
3. run laycur command making my 'last' block to the current layer.
4. layerp
Command String so far: ^C^C-I;MYBLOCK;\;;\LISP;LAYCUR;L;;LAYERP
Unfortunately, the AutoCAD considers the 'lastpoint' the layer of my block and ignores the line layer that I am wanting to make current.
Any suggestions?
kennet.sjoberg
2008-11-20, 01:22 AM
Ok, so I suggest this
1. A reactor switch to the layer, when and before you inserting the block with the insert command, to the layer that the line lays on that you pick.
You can find a similar reactor that I created in this thread that does it for an Xref.
2. An other way is to insert the block normally at the line at current layer, and next command in the lisp would flip the block (entlast) to the layer of the line.
In both ways you do not need laycur
: ) Happy Computing !
kennet
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.