Jump to content

Lisp to draw 2 small lines


Recommended Posts

Posted (edited)

I want a Lisp to convert the selected line into two separated lines.

The two separated lines are red colored, and their total length is less than the original line by 1mm (0.5mm from each side).

It's better if the Lisp allows entering the length of  the red line (10mm in the picture).

The attached picture indicates the Lisp required.

 

Capture_.JPG

Edited by Mohamed_Essam_2000
Posted

For the red lines, how are they positioned? Anywhere along the rectangle long edge? Half way? Mid way between small rectangle and the other end or user defined?

 

Are the red lines just coloured red or are they 'by-layer' on a separate red coloured layer?

 

The LISP itself is quite easy when we know the parameters

Posted

Like @Steven P I have select near end and enter distance along, Enter=mid, so answer the questions then something can be done, please post a sample dwg not image so dim style can be set, same with red line correct layer.

Posted (edited)
2 hours ago, BIGAL said:

Like @Steven P I have select near end and enter distance along, Enter=mid, so answer the questions then something can be done, please post a sample dwg not image so dim style can be set, same with red line correct layer.

It's the same idea of the Lisp that had been created before and it's shown in this URL

But this time the small lines will be red instead of yellow, and they will be offset from ends by 0.5mm

 

Edited by Mohamed_Essam_2000
Posted (edited)
8 hours ago, Steven P said:

For the red lines, how are they positioned? Anywhere along the rectangle long edge? Half way? Mid way between small rectangle and the other end or user defined?

 

Are the red lines just coloured red or are they 'by-layer' on a separate red coloured layer?

 

The LISP itself is quite easy when we know the parameters

The rectangle is just an example, this means the line may be positioned anywhere and at any angle.

Simply, there will be a line to be selected.

The Lisp will convert the line into two separated lines which are red colored and the distance between their outward ends is smaller by 1mm than the original line (0.5mm from each side).

No by-layer, just red coloring.

Edited by Mohamed_Essam_2000
Posted

So you want lines drawn 90 off the base line ? Still asking question how to select start point ? Distance along or mid ?

  • Like 1
Posted
(defun c:pp()
  (setq dist (getdist "red line length? "))
  ;(setq dist 10)
  (setq d1 0.5)
  (setq line (car (entsel))
	lst (entget line)
	a8 (assoc 8 lst)
	p1 (cdr (assoc 10 lst))
	p2 (cdr (assoc 11 lst))
	)
  (entmake (list (cons 0 "LINE") (cons 10 (polar p1 (angle p1 p2) d1)) (cons 11 (polar p1 (angle p1 p2) (+ d1 dist))) a8 '(62 . 2)))
  (entmake (list (cons 0 "LINE") (cons 10 (polar p2 (angle p2 p1) d1)) (cons 11 (polar p2 (angle p2 p1) (+ d1 dist))) a8 '(62 . 1)))
  (entdel line)
  )

😉

  • Thanks 1
Posted

@Mohamed_Essam_2000

I asked you previously HERE, and I ask you again now: please post your questions in the forum. My profile is not your gear stick to make me work faster for you.

  • Funny 1
Posted
10 hours ago, fuccaro said:
(defun c:pp()
  (setq dist (getdist "red line length? "))
  ;(setq dist 10)
  (setq d1 0.5)
  (setq line (car (entsel))
	lst (entget line)
	a8 (assoc 8 lst)
	p1 (cdr (assoc 10 lst))
	p2 (cdr (assoc 11 lst))
	)
  (entmake (list (cons 0 "LINE") (cons 10 (polar p1 (angle p1 p2) d1)) (cons 11 (polar p1 (angle p1 p2) (+ d1 dist))) a8 '(62 . 2)))
  (entmake (list (cons 0 "LINE") (cons 10 (polar p2 (angle p2 p1) d1)) (cons 11 (polar p2 (angle p2 p1) (+ d1 dist))) a8 '(62 . 1)))
  (entdel line)
  )

😉

Yes, that seems good.

Thanks.

Posted
10 hours ago, fuccaro said:
(defun c:pp()
  (setq dist (getdist "red line length? "))
  ;(setq dist 10)
  (setq d1 0.5)
  (setq line (car (entsel))
	lst (entget line)
	a8 (assoc 8 lst)
	p1 (cdr (assoc 10 lst))
	p2 (cdr (assoc 11 lst))
	)
  (entmake (list (cons 0 "LINE") (cons 10 (polar p1 (angle p1 p2) d1)) (cons 11 (polar p1 (angle p1 p2) (+ d1 dist))) a8 '(62 . 2)))
  (entmake (list (cons 0 "LINE") (cons 10 (polar p2 (angle p2 p1) d1)) (cons 11 (polar p2 (angle p2 p1) (+ d1 dist))) a8 '(62 . 1)))
  (entdel line)
  )

😉

How to enable multi-selection?

Posted
(defun c:zz()
  (setq dist (getdist "red lines length? "))
  (setq lines (ssget '((0 . "LINE"))))
  (setq d1 0.5 red '(62 . 1))
  (repeat (setq i (sslength lines))
    (setq line (ssname lines (setq i (1- i)))
	  lst (entget line)
	  a8 (assoc 8 lst)
	  p1 (cdr (assoc 10 lst))
	  p2 (cdr (assoc 11 lst))
	  )
    (entmake (list (cons 0 "LINE") (cons 10 (polar p1 (angle p1 p2) d1)) (cons 11 (polar p1 (angle p1 p2) (+ d1 dist))) a8 red))
    (entmake (list (cons 0 "LINE") (cons 10 (polar p2 (angle p2 p1) d1)) (cons 11 (polar p2 (angle p2 p1) (+ d1 dist))) a8))
    (entdel line)
    )
  )

Did you start to learn AutoLisp?

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