Jump to content

Line positioning within limit problem


mdbdesign

Recommended Posts

As per picture: How I can do it with help of lisp?

Was trying to position it on AutoCAD but got no idea how without trial and error. Brain dead stage. Please help.

Axis 0X and 0Y is the limit.

MarekDesk056.jpg

Link to comment
Share on other sites

Hi Marek

 

I've tried to solve this problem some time ago and I couldn't find an exact mathematical solution using lisp, but just a (good) approximation.

I'll post it if you are interested, although it is a slightly different arrangement: the line starting from the known point H is perpendicular to the midpoint of the segment AB.

 

Anyway, you can use constraints to achieve the same result, or a dynamic block.

 

brackets.dwg

Link to comment
Share on other sites

Hi Marek

 

I've tried to solve this problem some time ago and I couldn't find an exact mathematical solution using lisp, but just a (good) approximation.

I'll post it if you are interested, although it is a slightly different arrangement: the line starting from the known point H is perpendicular to the midpoint of the segment AB.

 

Anyway, you can use constraints to achieve the same result, or a dynamic block.

 

[ATTACH]46884[/ATTACH]

Stefan, anything solving this problem is very needed. Please post it.

I did try constraints. Just wonder about AutoCAD function "grread" that let object slide along line(?) and combining it with constraints maybe work-this is still magic for me.

Link to comment
Share on other sites

My attempt (for x and y positive).

 

(defun c:test ( / p ab p1 p2 d )
   (setq p (getpoint "Pick a point "))
   (setq ab (getdist "\nLength Line  "))
   (if (< ab (cadr p))
       (progn
           (setq p1 (list 0.0 ab))
           (setq d ab)
           (while (not (equal (cadr p2) 0.0 1e-12))
               (setq p2 (polar p1 (- (angle p1 p) (* pi 0.5)) ab))
               (if (> (car p2) 0.0)
                   (cond
                       ( (< (cadr p2) 0.0) (setq p1 (polar p1 (* pi 0.5) (setq d (* d 0.5)))) )
                       ( (> (cadr p2) 0.0) (setq p1 (polar p1 (* pi 1.5) (setq d (* d 0.5)))) )
                   )
               )
           )
           (setq p1 (list 0.0 (cadr p1)))
           (setq p2 (list (car p2) 0.0))
           (entmake (list '(0 . "LINE") (cons 10 p1) (cons 11 p2)))
           (grdraw p p1 1 1)
           (princ (strcat "\nDistance = " (rtos (distance p p1))))
       )
       (alert (strcat "Out of range" "\nLength max = " (rtos (cadr p))))
   )
   (princ)
)

 

 

476a.gif

Link to comment
Share on other sites

Awesome. Thank you.

We almost there.

What about actually selecting x and y, because it's always away from standard 0,0 coord and remove limit of location of pick first point?

Something like:

Pick point:

Pick x line: (horizontal)

Pick y line: (vertical)

Enter length of line:

Link to comment
Share on other sites

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