Jump to content

Draw an isosceles trapezoid


andy_lee

Recommended Posts

Hi guys

Have a routine like this? Thanks for any help!

Enter the value of the " L " and " H" , pick a basic point , Dynamic specified direction. Draw an isosceles trapezoid.

01.jpg

 

Dynamic specified direction

2.png

Link to comment
Share on other sites

A good start for learning lisp very easy just a couple of commands think of it as 5 pts 1st point is pick point then using new pt = polar angle distance or old fashioned trig can work out all the corners then create pline pt1 pt2 pt3 pt4 C and then rotate.

Link to comment
Share on other sites

Try this Andy and let me know :)

 

(defun c:Test (/ dtr ac ab p sl a b c d e p)
 ;;	Author : Tharwat Al Shoufi			;;
 ;; Draw Trapezoid with angle 55 on the two sides	;;
 ;; --------------------------------------------------	;;
 (defun dtr (a) (* pi (/ a 180.0)))
 (if (not *traplen*)
   (setq *traplen* 10.0)
 )
 (if (not *traphgt*)
   (setq *traphgt* 4.0)
 )
 (if (and (setq *traplen* (cond ((getdist (strcat "\n Specify Length of Trapezoid < " (rtos *traplen* 2 2) " > :")))
                                (*traplen*)
                          )
          )
          (setq *traphgt* (cond ((getdist (strcat "\n Specify Height of Trapezoid < " (rtos *traphgt* 2 2) " > :")))
                                (*traphgt*)
                          )
          )
          (setq ac (/ *traphgt* (sin (dtr 55.)))
                ab (* ac (cos (dtr 55.)))
          )
          (if (>= (setq sl (- *traplen* (+ ab ab))) 0.)
            (setq p (getpoint "\n Specify top center point of Trapezoid :"))
            (progn (alert "Length of Trapezoid is too small !!") nil)
          )
     )
   (progn (setq a (polar p pi (/ sl 2.))
                b (polar a (dtr 235.) ac)
                c (polar b 0. *traplen*)
                d (polar c (dtr 125.) ac)
                e (entmakex
                    (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1))
                            (mapcar '(lambda (pt) (cons 10 (list (car pt) (cadr pt)))) (list a b c d))
                    )
                  )
          )
   )
 )
 (if e
   (command "_.rotate" e "" "_non" p "\\")
 )
 (princ)
)

Link to comment
Share on other sites

  • 9 months later...

Hi Tharwat,

 

 

Kindly asking to another solution to draw difference four sides (input) and angle of trapezoid (angle not fix). How to add more feature in your code? Thank you in advance.

 

 

Untitled.jpg

Link to comment
Share on other sites

As Lee is stating without a known angle there is no solution. How do you do this now you must be fixing something or do you have a diagonal distance then its solvable.

Link to comment
Share on other sites

Eldon I got Length = 263.495 not 265 so diagram is not correct for whole degrees

 

When I saw the picture, I thought that it showed typical OOB settings, with the length precision set at 4 and the angle precision set at 0, with decimal degrees set in the dimensions.

 

So that meant that there was up to half a degree tolerance in each angle, which when dimensioned would be as shown.

 

I got 1.8 units misclosure going round with whole angles. So I adjusted angles here and there, keeping the adjustments below half a degree.

 

For the record, here are the angles that I used:-

70°-33'-34" (dimensioned as 71°)

74°-45'-54" (dimensioned as 75°)

91°-29'-55" (dimensioned as 91°)

123°-10'-37" (dimensioned as 123°)

 

These values are probably not unique, but once I had found one set, I was content.

Link to comment
Share on other sites

Regarding uniqueness: if all four lengths are constrained, only one angle is required for uniqueness; if all four lengths are given & more than one angle is specified, the geometry will be over-constrained unless the given angles are exact. I find the best way to visualise this is to reduce the problem to a rectangle which may be deformed into an infinite set of parallelograms unless an angle is given.

Link to comment
Share on other sites

Try this Andy and let me know :)

 

(defun c:Test (/ dtr ac ab p sl a b c d e p)
 ;;	Author : Tharwat Al Shoufi			;;
 ;; Draw Trapezoid with angle 55 on the two sides	;;
 ;; --------------------------------------------------	;;
 (defun dtr (a) (* pi (/ a 180.0)))
 (if (not *traplen*)
   (setq *traplen* 10.0)
 )
 (if (not *traphgt*)
   (setq *traphgt* 4.0)
 )
 (if (and (setq *traplen* (cond ((getdist (strcat "\n Specify Length of Trapezoid < " (rtos *traplen* 2 2) " > :")))
                                (*traplen*)
                          )
          )
          (setq *traphgt* (cond ((getdist (strcat "\n Specify Height of Trapezoid < " (rtos *traphgt* 2 2) " > :")))
                                (*traphgt*)
                          )
          )
          (setq ac (/ *traphgt* (sin (dtr 55.)))
                ab (* ac (cos (dtr 55.)))
          )
          (if (>= (setq sl (- *traplen* (+ ab ab))) 0.)
            (setq p (getpoint "\n Specify top center point of Trapezoid :"))
            (progn (alert "Length of Trapezoid is too small !!") nil)
          )
     )
   (progn (setq a (polar p pi (/ sl 2.))
                b (polar a (dtr 235.) ac)
                c (polar b 0. *traplen*)
                d (polar c (dtr 125.) ac)
                e (entmakex
                    (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1))
                            (mapcar '(lambda (pt) (cons 10 (list (car pt) (cadr pt)))) (list a b c d))
                    )
                  )
          )
   )
 )
 (if e
   (command "_.rotate" e "" "_non" p "\\")
 )
 (princ)
)

 

 

Dear Tharwat

 

Why can't use for 3D mode ,:cry: , like this .

 

test.png

Link to comment
Share on other sites

  • 3 weeks later...
Dear Tharwat

 

Why can't use for 3D mode ,:cry: , like this .

 

[ATTACH=CONFIG]54752[/ATTACH]

 

Yes , This is a disadvantage.

 

Hi Tharwat. can fix this ?

Link to comment
Share on other sites

Tharwat tried using new ucs in plane but did not work, a more polar method 4 points would, but anyway I cheated and used rotate3d to get the answer. Something in the entmakex.

 

ScreenShot038.jpg

Edited by BIGAL
Link to comment
Share on other sites

Tharwat tried using new ucs in plane but did not work, a more polar method 4 points would, but anyway I cheated and used rotate3d to get the answer. Something in the entmakex.

 

[ATTACH=CONFIG]54913[/ATTACH]

 

Hi BIGAL ,Can you fix this?

Link to comment
Share on other sites

Tharwat tried using new ucs in plane but did not work, a more polar method 4 points would, but anyway I cheated and used rotate3d to get the answer. Something in the entmakex.

 

[ATTACH=CONFIG]54913[/ATTACH]

 

feasible? BIGAL

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