I want to change circles to squares in this lisp

I want to change circles to squares in this lisp

ritagarciabrito
Explorer Explorer
766 Views
2 Replies
Message 1 of 3

I want to change circles to squares in this lisp

ritagarciabrito
Explorer
Explorer

Hi,

Thank you a lot for helping me.

I have this lisp, that creates different shapes of cups, but i want to replace circles to squares. With the intention  to have a lisp that creates different shapes of towers.

 

 

;lisp that makes cups but i want to change to a tower
(defun c:tower ()
(setq pontos2d (getvar "osmode"))
(setq pontos3d (getvar "3dosmode"))

(setvar "osmode" 0)
(setvar "3dosmode" 0)
(command "ucs" (getpoint "Insert point. ") "")
(setq nu 0)
(command "_circle" (list 0 0 0) 1) ;first circle
(guardar)
(command "_circle" (list 0 0 (alea 1 2)) (alea 1 4))
(guardar)
(command "_circle" (list 0 0 (alea 2 7)) (alea 1 1.5))
(guardar)
(command "_circle" (list 0 0 10) 1.5) ;last circle
(guardar)

(solido)

(setq lista nil)
(setvar "osmode" pontos2d)
(setvar "3dosmode" pontos3d)
(command "ucs" "")
)


(defun guardar ()
(setq lista (append lista (list (set (read (strcat "entidade" (rtos nu))) (entlast)))))
)


(defun solido ()
(command "loft" "_mo" "_su")
(foreach p lista (command p))
(command "" "")
)

 

(defun alea ( min max / )
(+ min (valor (- max min)))
)
(defun valor (num)
(* num (rnd))
)
(defun rnd (/ modulus multiplier increment random)
(if (not seed)
(setq seed (getvar "DATE"))
)
(setq modulus 65536
multiplier 25173
increment 13849
seed (rem (+ (* multiplier seed) increment) modulus)
random (/ seed modulus)
)
)

0 Likes
Accepted solutions (1)
767 Views
2 Replies
Replies (2)
Message 2 of 3

hak_vz
Advisor
Advisor

In your lisp simply change command CIRCLE with command RECT

 

(command "_circle" (list 0 0 0) 1) ;first circle

This creates rectangle with center at point 0 0 0

(command 
"_.rectang"  
(polar '(0 0 0) (/ pi 4) (* -0.5 (sqrt 2))) 
(polar '(0 0 0) (/ pi 4) (* 0.5 (sqrt 2)))
)

 

Play with it as you like, change (sqrt 2) with adequate rectangle half diagonal value  

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 3

calderg1000
Mentor
Mentor
Accepted solution

Regards @ritagarciabrito 

Try this code with some small changes.
If I'm not mistaken in any value of the lists, it should work...

 

;lisp that makes cups but i want to change to a tower
(defun c:towerR ()
  (setq pontos2d (getvar "osmode"))
  (setq pontos3d (getvar "3dosmode"))
  (setvar "osmode" 0)
  (setvar "3dosmode" 0)
  (command "ucs" (getpoint "Insert point. ") "")
  (setq nu 0)
;;;(command "_circle" (list 0 0 0) 1) ;first circle
  (command "_rectangle" (list -1 -1 0) (list 1 1 0))
  (guardar)
;;;(command "_circle" (list 0 0 (alea 1 2)) (alea 1 4))
  (command
    "_rectangle"
    (list (* -1 (setq a (alea 1 4))) (* -1 (setq b a)) (setq c (alea 1 2)))
    (list a b c)
  )
  (guardar)
;;;(command "_circle" (list 0 0 (alea 2 7)) (alea 1 1.5))
  (command
    "_rectangle"
    (list (* -1 (setq a (alea 1 1.5))) (* -1 (setq b a)) (setq c (alea 2 7)))
    (list a b c)
  )
  (guardar)
;;;(command "_circle" (list 0 0 10) 1.5) ;last circle
  (command "_rectangle" (list -1.5 -1.5 10.) (list 1.5 1.5 10.))
  (guardar)
  (solido)
  (setq lista nil)
  (setvar "osmode" pontos2d)
  (setvar "3dosmode" pontos3d)
  (command "ucs" "")
)

(defun guardar ()
(setq lista (append lista (list (set (read (strcat "entidade" (rtos nu))) (entlast)))))
)

(defun solido ()
(command "loft" "_mo" "_su")
(foreach p lista (command p))
(command "" "")
)

(defun alea ( min max / )
(+ min (valor (- max min)))
)
(defun valor (num)
(* num (rnd))
)
(defun rnd (/ modulus multiplier increment random)
(if (not seed)
(setq seed (getvar "DATE"))
)
(setq modulus 65536
multiplier 25173
increment 13849
seed (rem (+ (* multiplier seed) increment) modulus)
random (/ seed modulus)
)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes