Jump to content

Recommended Posts

Posted

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

Posted

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

  • Like 2
Posted

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

 

Posted

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?

Posted (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 by mhupp
  • Like 1
Posted

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

 

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...