Jump to content

Recommended Posts

Posted

Hi, I was wondering if anyone could help me with a simple (I assume) lisp. Essentially I would like to the lisp to:

-Prompt the user to select a line or polyline (1st element). "Select pipe line"

-Prompt the user to select a point within the selected line/polyline (1st point) "Select connection point"

-Prompt the user to select a second line or polyline (2nd element) "Select boundary line"

-Create a line perpendicular to the 1st element which extends 1m beyond the 2nd element (2nd point).

 

Thanks

Posted (edited)

Google "draw line perp to point lisp autocad". There are numerous solutions out there already. Then will need a extend 1m added.

 

Note step1 & 2 are actually 1 step when select point on line etc.

 

Thinking aloud can get 1stderiv angle of line/pline at a point use xline to intersect with 2nd object then extend.

Edited by BIGAL
Posted
Quote
11 minutes ago, BIGAL said:

Thinking aloud can get 1stderiv angle of line/pline at a point use xline to intersect with 2nd object then extend.

 

 

Gosh, I wished I could understand what you are talking about :P

Posted

For better understanding, and  maybe get further help, please upload such sample.dwg 

 

Posted (edited)

Try this found problem the xline is a bit fussy about ang direction.

 

; https://www.cadtutor.net/forum/topic/74329-perpendicular-extend-beyond-1m/
; line sq off line pline crossing another line + 1 to dist
; By AlanH info@alanh.com.au Jan 2022

(defun c:sqp ( / ent obj pt ang obj2 obj3 intpt oldsnap oldang)

(defun alg-ang (objpl pnt)
  (angle '(0. 0. 0.)
     (vlax-curve-getfirstderiv
       objpl
       (vlax-curve-getparamatpoint
         objpl
         pnt
       )
     )
  )
)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 512)
(setq oldang (getvar 'aunits))
(setvar 'aunits 3)
(setq oldangbase (getvar 'angbase))
(setvar 'angbase 0)
(setq oldangdir (getvar 'angdir))
(setvar 'angdir 0)

(setq ent (entsel "\Pick line or pline pt "))

(setq pt (cadr ent))
(setq obj (vlax-ename->vla-object (car ent)))
(setq pt (vlax-curve-getclosestpointto obj pt))
(setq obname (vla-get-objectname obj))
(setq ang (+ (alg-ang obj pt) (/ pi 2.0)))

(setq obj3 (vlax-ename->vla-object (car  (entsel "\nPick other object" ))))

(command "xline" "A" ang  pt "")

(setq obj2 (vlax-ename->vla-object (entlast)))
(setq intpt (vlax-invoke obj2 'intersectWith obj3 acExtendnone))
(command "erase" (entlast) "")
(setq pt2 (polar pt (angle pt intpt) (+ 1.0 (distance pt intpt))))
(command "LINE" pt pt2 "")

(setvar 'osmode oldsnap)
(setvar 'aunits oldang)
(setvar 'angdir oldangdir)
(setvar 'angbase oldangbase)

(princ)
)

(c:sqp)

 

 

image.png.b1c79b7b59eb7d2ae6d6c00e7dcb6961.png

Edited by BIGAL
Posted

Hi Bigal, that's AWESOME! Thank you so much. But after testing I realized the brief was not quite right. Would be possible to make a few changes to this function? What if I want to include a 3rd line for the user to pick which would define another offset. Basically, the second point (pt2) is an intersection of 1st and 2nd bdy lines as shown in picture below. However starting from that intersection point might be another solution.

 

Cheers

 

 

Capture.JPG

Posted

Yes have that, if you had said for sewer house lot connections would have done that,  I did multiple lots in one go,  pick "100" line then drag over lot boundaries all done. That is why its a good idea to always post at least an image.

 

Had a look and I used a block so will need to change. It also takes into account angled lot boundary.

 

Like Devitg post a sample dwg. 

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