- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I need some help to create an array with for the rectangle 3 (the one laying on the bottom), having 1 column, 1 row and 6 levels with a total height of the user's height input (95 or 119) -0.75", so the top rectangle is flush with the walls holding it.
I'm new using LISP, so I don't know completely how the syntaxis for calling commands and entering their values works. I hit the wall when I tried to call the ARRAYREC command, just can't make it work. I also don't know if it would be easier to create copies of the entity and spacing them equally instead to get the same result, because I would need to explode the array after anyway. Like I said I have been using LISP only for a few hours.
This is the code that I managed to make work so far.
Any help is appreciated.
Thank you.
(defun c:Createfiller (/ pt len ht rect1-base rect2-base rect3-base rect4-base rect5-base rect1 rect2 rect3 rect4 rect5)
;; Prompt for the insertion point (base point)
(setq pt (getpoint "\nSpecify insertion point: "))
;; Prompt for the length
(setq len (getdist "\nEnter length of the rectangle: "))
;; Prompt for the height (either 95 or 119)
(setq ht (getint "\nEnter height (95 or 119 inches): "))
;; Ensure height is either 95 or 119
(while (not (or (= ht 95) (= ht 119)))
(setq ht (getint "\nInvalid height. Enter height (95 or 119 inches): "))
)
;; Draw the first rectangle:
(setq rect1-base pt)
(command "_.rectangle" rect1-base (list (+ (car rect1-base) 0.25) (+ (cadr rect1-base) len)))
(setq rect1 (entlast)) ;; Capture the first rectangle
;; Extrude rectangle 1 to the user height
(command "_.extrude" rect1 "" (rtos ht 2 2))
;; Draw the second rectangle:
(setq rect2-base (list (+ (car pt) 0.25) (cadr pt)))
(command "_.rectangle" rect2-base (list (+ (car rect2-base) 2.5) (+ (cadr rect2-base) 0.75)))
(setq rect2 (entlast)) ;; Capture the second rectangle
;; Extrude rectangle 2 to the user height
(command "_.extrude" rect2 "" (rtos ht 2 2))
;; Draw the third rectangle:
(setq rect3-base (list (+ (car pt) 0.25) (+ (cadr pt) 0.75)))
(command "_.rectangle" rect3-base (list (+ (car rect3-base) 2.5) (+ (cadr rect3-base) (- len 1.5))))
(setq rect3 (entlast)) ;; Capture the third rectangle
;; Extrude rectangle 3 to 0.75"
(command "_.extrude" rect3 "" "0.75")
;; Draw the fourth rectangle:
(setq rect4-base (list (+ (car pt) 0.25) (+ (cadr pt) (- len 0.75)))) ;; Fixed the base point
(command "_.rectangle" rect4-base (list (+ (car rect4-base) 2.5) (+ (cadr rect4-base) 0.75)))
(setq rect4 (entlast)) ;; Capture the fourth rectangle
;; Extrude rectangle 4 to the user height
(command "_.extrude" rect4 "" (rtos ht 2 2))
;; Draw the fifth rectangle:
(setq rect5-base (list (+ (car pt) 2.75) (cadr pt))) ;; Fixed the base point
(command "_.rectangle" rect5-base (list (+ (car rect5-base) 0.25) (+ (cadr rect5-base) len)))
(setq rect5 (entlast)) ;; Capture the fifth rectangle
;; Extrude rectangle 5 to the user height
(command "_.extrude" rect5 "" (rtos ht 2 2))
;; Finished
(princ "\nFiller created.")
(princ)
)
Solved! Go to Solution.