Need help for autolisp

Need help for autolisp

Anonymous
Not applicable
779 Views
3 Replies
Message 1 of 4

Need help for autolisp

Anonymous
Not applicable

Hello 

I am new to autolisp and I need to draw a 3d object, I tried to write the code but unfortunately I couldnt achieve drawing the arcs and the lines to make the base of the object.

Could anyone help me about how to do it?

 

Thank you 🙂part12.jpgproject-figs (2).jpg

 

0 Likes
780 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant

Well, it's easy.

; line
(command "_.line" pt1 pt2 "")
; arc
(command "_.arc" pt3 pt4 pt5)

 

Or are you saying, that we should do the math for you?

0 Likes
Message 3 of 4

Anonymous
Not applicable

I tried to develop the code for the part but I couldnt find how to connect to circles at the bottom with 2 lines tangent to them and then extrude them. 

Can someone help me about it?

 

Thank you

 

 

(defun L1 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght1 (atoi deg))
(set_tile "L1slider" deg)
) ))

(defun L1slider (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght1 (atoi deg))
(set_tile "L1" deg)
) ))


(defun D1 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq diameter1 (atoi deg))
(set_tile "D1slider" deg)
) ))

(defun D1slider (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq diameter1 (atoi deg))
(set_tile "D1" deg)
) ))

(defun L3 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght3 (atoi deg))
(set_tile "L3slider" deg)
) ))

 

(defun L4 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght4 (atoi deg))
(set_tile "L4slider" deg)
) ))

(defun L4slider (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght4 (atoi deg))
(set_tile "L4" deg)
) ))


(defun L6 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght6 (atoi deg))
(set_tile "L6slider" deg)
) ))

(defun L6slider (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght6 (atoi deg))
(set_tile "L6" deg)
) ))


(defun D2 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq diameter2 (atoi deg))
(set_tile "D2slider" deg)
) ))

(defun D2slider (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq diameter2 (atoi deg))
(set_tile "D2" deg)
) ))
(defun L7 (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght7 (atoi deg))
(set_tile "L7slider" deg)
) ))

(defun L7slider (deg ned)
(if (or (= ned 2) (= ned 1) )
(progn
(setq lenght7 (atoi deg))
(set_tile "L7" deg)
) ))

 

 

 



(set_tile "L1" (rtos lenght1 2 0) )
(set_tile "L1slider" (rtos lenght1 2 0) )
(set_tile "D2" (rtos lenght2 2 0) )
(set_tile "D2slider" (rtos diameter2 2 0) )
(set_tile "L4" (rtos lenght4 2 0) )
(set_tile "L4slider" (rtos lenght4 2 0) )
(set_tile "L6" (rtos lenght6 2 0) )
(set_tile "L6slider" (rtos lenght6 2 0) )
(set_tile "D1" (rtos diameter1 2 0) )
(set_tile "D1slider" (rtos diameter1 2 0) )

 

(action_tile "accept" "done_dialog")


(action_tile "L1" "(L1 $value $reason)" )
(action_tile "L1slider" "(L1slider $value $reason)" )
(action_tile "D2" "(L2 $value $reason)" )
(action_tile "D2slider" "(D2slider $value $reason)" )
(action_tile "L4" "(L4 $value $reason)" )
(action_tile "L4slider" "(L4slider $value $reason)" )
(action_tile "L6" "(L6 $value $reason)" )
(action_tile "L6slider" "(L6slider $value $reason)" )
(action_tile "D1" "(D1 $value $reason)" )
(action_tile "D1slider" "(D1slider $value $reason)" )
(action_tile "L7" "(L6 $value $reason)" )
(action_tile "L7slider" "(L6slider $value $reason)" )


(mode_tile "A" 2)
(action_tile "cancel" "(exit)")
(start_dialog)
(unload_dialog dcl_id)


;----------------------


;Cylinder

(setq pt3 (list 0 0 ))
(command "circle" pt3 (/ lenght2 2) "")
(setq circle1 (ssget "L"))
(command "extrude" circle1 "" (+ 0 lenght6))
(setq part1 (ssget "L"))


;----------------------
;Bottom
(command "color" 30 " " )

(setq pt1 (list 0 (length1 ))
(command "circle" pt1 (/ lenght7 2) "")
(setq circle2 (ssget "L"))
(command "extrude" circle2 "" (+ 0 lenght4))
(setq part2 (ssget "L"))
(command "union" part1 part2 "")
(setq part3 (ssget "L"))
;----------------------

;Cylinder cut

(setq pt4 (list 0 0 ))
(command "circle" pt4 (/ diameter1 2) "")
(setq circle2 (ssget "L"))
(command "extrude" circle2 "" (+ 0 lenght6))
(setq part4 (ssget "L"))
(command "subtract" part1 "" part4 "")
(setq part5 (ssget "L"))

 

;(command "ucs" "y" -180)

(command "vscurrent" "R")
(command "view" "seiso")
(command "grid" "off")
(command "zoom" "a")


)

0 Likes
Message 4 of 4

Anonymous
Not applicable

 

A little hint

(setq circle2 (ssget "L"))
(command "extrude" circle2 "" (+ 0 lenght6))


(command "extrude" (entlast) "" (+ 0 lenght6))

0 Likes