TOMJETLAND Posted November 27 Posted November 27 Hi all, I was wondering if anyone one knows of a Lisp that would allow me to draw a new line or polyline that automatically draws it in the layer at which the lines start point layer is? I.E The current layer is:0 I want to draw line from a point or end of line that is in layer building I want the layer of new line automatically to be drawn in building.. and so on.. Fingers crossed there is such a thing! Thanks Quote
Steven P Posted November 27 Posted November 27 How are your LISP abilities? Could draw the line, use a selection set 'window' with a small aperture centred on the start point to grab all the entities at the start point. Remove the new line from the selection set and with luck you'll be left with just one.. which you can get the layer from with (assoc 8 -EntityDescription- ) and apply that to 'entlast' - the line you just drew. Lisp could be a whole lisp including draw line or could be modify the line after it has been drawn (though use format painter would be just as easy in that case) I don't have something to copy and paste though 2 Quote
pkenewell Posted November 27 Posted November 27 Even Better: https://www.lee-mac.com/layerdirector.html 1 Quote
BIGAL Posted November 27 Posted November 27 You can use (ssget pt) then (ssname ss 0) this allows you to get say the layer of the object selected as well as say end point. A crude example. Can be made smarter. (defun c:testline ( / oldsnap pt ss) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 1) (setq pt (getpoint "\nPick start point ")) (setq ss (ssget pt)) (setq entlay (cdr (assoc 8 (entget (ssname ss 0))))) (setvar 'clayer entlay) (command-s "line" pt ) (setvar 'osmode oldsnap) (princ) ) Quote
TOMJETLAND Posted November 28 Author Posted November 28 BIGAL, This is ideal. Thank you. One little thing, the start of the line will only snap to a line end point. Any idea why? Quote
mhupp Posted November 28 Posted November 28 (edited) 53 minutes ago, TOMJETLAND said: BIGAL, This is ideal. Thank you. One little thing, the start of the line will only snap to a line end point. Any idea why? On 11/27/2024 at 5:16 AM, TOMJETLAND said: ... I want to draw line from a point or end of line that is in layer building ... or if your asking how to snap to other snap points add up the values of what you want to snap to. and set osmode to that. Example you want end point and mid point (setvar osmode 3) OSMODE Edited November 28 by mhupp 1 Quote
ronjonp Posted December 2 Posted December 2 Another quick one for fun. It defaults to a nearest snap. (defun c:foo (/ fz lyr p1 p2 s) ;; Adjust this value for your needs (setq fz 0.1) (while (and (or p1 (setq p1 (getpoint "\nSpecify start point: "))) (setq p2 (getpoint p1 "\nSpecify next point: ")) ) (and (not lyr) (setq s (ssget "_C" (mapcar '- p1 (list fz fz fz)) (mapcar '+ p1 (list fz fz fz)) '((0 . "LINE"))) ) ;; Take this line out if you don't want to use closest to snap (setq p1 (vlax-curve-getclosestpointto (ssname s 0) p1)) (setq lyr (assoc 8 (entget (ssname s 0)))) ) (if lyr (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 p2) lyr)) (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 p2))) ) (setq p1 p2) ) (princ) ) 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.