Draw trapezoid on the face of 3d solid

Draw trapezoid on the face of 3d solid

Anonymous
Not applicable
2,511 Views
4 Replies
Message 1 of 5

Draw trapezoid on the face of 3d solid

Anonymous
Not applicable

Hi guys
Can make this routine draw trapezoid on the face of 3d solid ?

Here is draw isosceles trapezoid
code was at:  http://www.cadtutor.net/forum/showthread.php?88383-Draw-an-isosceles-trapezoid

 

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

Reference image  from other member. Thanks.

 

 test.png

0 Likes
Accepted solutions (1)
2,512 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

This idea feasible?

0 Likes
Message 3 of 5

Anonymous
Not applicable

0 Replies . why ? sad...

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

0 Replies . why ? sad...


Only because no one has chosen to work it out yet -- we're all just users like you, volunteering whatever effort we may put in here, but [sadly, I agree] we have jobs, find other topics we can answer more quickly or easily, put our attention to subjects we are more interested in because we will ourselves have a use for any code we may work out, etc.

 

It may not be as simple as you might expect.  You would need to change the User Coordinate System to align with the face of the solid you want to draw the trapezoid on [that's the easy part].  The (getpoint) and (polar) functions return values in the current UCS, but the angle argument in the (polar) function is relative to the World CS, and I would need to experiment to see whether that causes trouble in UCS's oriented in certain directions.  There would need to be some (trans) function(s) applied in the making of the trapezoid itself, since point locations in entity data are in the World CS, but I would need to experiment with that to get it right, and/or it might be easier to use a (command) function to draw it than (entmake), since the input to a Polyline command will be taken in the current CS.

 

I may come back to it later, or someone else may chime in, but I can't take that much time right now.  In the meantime, you could draw the trapezoid on the WCS plane, and change UCS's as appropriate to Copy/Rotate/Move it into the position(s) needed.

Kent Cooper, AIA
0 Likes
Message 5 of 5

Anonymous
Not applicable

@Kent1Cooper wrote:

@Anonymous wrote:

0 Replies . why ? sad...


Only because no one has chosen to work it out yet -- we're all just users like you, volunteering whatever effort we may put in here, but [sadly, I agree] we have jobs, find other topics we can answer more quickly or easily, put our attention to subjects we are more interested in because we will ourselves have a use for any code we may work out, etc.

 

It may not be as simple as you might expect.  You would need to change the User Coordinate System to align with the face of the solid you want to draw the trapezoid on [that's the easy part].  The (getpoint) and (polar) functions return values in the current UCS, but the angle argument in the (polar) function is relative to the World CS, and I would need to experiment to see whether that causes trouble in UCS's oriented in certain directions.  There would need to be some (trans) function(s) applied in the making of the trapezoid itself, since point locations in entity data are in the World CS, but I would need to experiment with that to get it right, and/or it might be easier to use a (command) function to draw it than (entmake), since the input to a Polyline command will be taken in the current CS.

 

I may come back to it later, or someone else may chime in, but I can't take that much time right now.  In the meantime, you could draw the trapezoid on the WCS plane, and change UCS's as appropriate to Copy/Rotate/Move it into the position(s) needed.

 

Dear Kent1Cooper ,

Thank you!  I agree with what you said. 

 

 

0 Likes