Jump to content

Recommended Posts

Posted

Hi

Thank you all for these codes.

However, I think this tool would be much better if the trapezoid angle could be adjusted interactively. It's often necessary to make adjustments to adapt it to the elements of the drawing.

Posted

 

1 hour ago, Vica said:

Hi

Thank you all for these codes.

However, I think this tool would be much better if the trapezoid angle could be adjusted interactively. It's often necessary to make adjustments to adapt it to the elements of the drawing.

I mean that one side of the trapezoid must usually be irregular.

IMG-20251118-WA0000.thumb.jpg.aab019f8d0abb3f4b5a6bf26a5442087.jpg

Posted (edited)
7 hours ago, Vica said:

I think this tool would be much better if...

 

These lisp's are to draw a trapezoid. I don't know if adding more features makes this completed code better. Id would have a separate code to make the irregular trapezoid and a main function to ask what shape you want to make. as far as dynamic mode modifying the poly in the drawing nothing more dynamic then that. this creates more options by call the irregular trapezoid lisp by itself or from a main list. you can even add other shapes to the main lisp.

 

;;----------------------------------------------------------------------------;;
;; All-Shapes or AS creates a DCL menu to pick what shape you want to create
;; and runs sub lisp of option picked
;; https://www.cadtutor.net/forum/topic/98827-the-coordinates-of-the-trapezoid/
(defun C:AS () (C:ALL-Shapes))
(defun C:All-Shapes (/ shplst shp)
  (setq shplst (list  "Trapezoid" "Irregular Trapezoid" "Circle"))
  (setq shp (nth (ahlstbox "Pick a Shape" shplst  20 10) shplst))
  (cond
    ((= shp "Trapezoid")(C:Trapezoid))
    ((= shp "Irregular Trapezoid")(C:IrrTrapezoid))
    ((= shp "Circle")(C:Cir))
  )
)
;; code by pkenewell
(defun C:Trapezoid (/ bw p0 p1 p2 p3 p4 ra sa th)
   (if
      (and
         (setq bw (getreal "\nEnter the width of the Base: ")
               th (getreal "\nEnter the Height: ")
               sa (getreal "\nEnter the side angles: ")
               p0 (getpoint "\nSelect the insertion point: ")
		 )
      )
      (progn
         (setq ra (* pi (/ sa 180.0))
               p1 (list (- (car p0) (/ bw 2)) (cadr p0) (caddr p0))
               p2 (list (+ (car p1) bw) (cadr p0) (caddr p0))
               p3 (list (+ (car p2) (* (/ th (cos ra)) (sin ra))) (+ (cadr p0) th) (caddr p0))
               p4 (list (- (car p1) (* (/ th (cos ra)) (sin ra))) (+ (cadr p0) th) (caddr p0))
         )
         (entmakex
            (append
                (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1))
                (mapcar '(lambda (x) (cons 10 x)) (list p1 p2 p3 p4))
            )
         )
      )
   )
)
(defun C:IrrTrapezoid (/ bw p0 p1 p2 p3 p4 ra sa th)
  (alert "Code Needed for Irregular Trapezoid")
  (princ)
)
(defun C:Cir ()
  (while (setq p (getpoint "\nSelect Point Center of Circle: "))
    (command "_.CIRCLE" p pause)
  )
)
; listbox-ah a library lst box routine pick just one from 
; By Alan H March 2019
; (if (not AHlstbox)(load "Listbox-AH.lsp"))
;(setq ans (ahlstbox "Pick a number" (list "150" "200" "225" "250" "300" "375" "450" "600") 20 10))
; ans is returned as item number selected of the list
(defun AHlstbox (heading lst wid ht / fo fname lsec )
  (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
  (write-line "AHlstbox : dialog {" fo)
  (write-line   (strcat " label = " (chr 34) heading (chr 34)  "  ;" )   fo)
  (write-line   "    spacer  ; " fo)
  (write-line   "    :list_box { " fo)
  (write-line (strcat " key=" (chr 34) "lst" (chr 34) " ; ") fo)
  (write-line  (strcat "    multiple_select=" (chr 34) "false" (chr 34)  " ; ") fo)
  (write-line   (strcat "    width= " (rtos wid 2 0) " ; ") fo)
  (write-line   (strcat "    height=" (rtos ht 2 0 ) " ; ") fo)
  (write-line   "    }   " fo)
  (write-line   "spacer ;" fo)
  (write-line    "   ok_cancel ; " fo)
  (write-line "  } " fo)
  (close fo)
  (setq dcl_id (load_dialog fname))
  (if (not (new_dialog "AHlstbox" dcl_id))
    (exit)
  )
  (start_list "lst")
  (foreach itm lst (add_list itm))
  (end_list)
  (action_tile "lst" "(setq lsec (atoi $value) )")
  (start_dialog)
  (unload_dialog dcl_id)
  (vl-file-delete fname)
  (princ lsec)
)

 

Edited by mhupp

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