Author Topic: how to use the fillet command to the solid entity in Lisp  (Read 4533 times)

0 Members and 1 Guest are viewing this topic.

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
how to use the fillet command to the solid entity in Lisp
« on: August 26, 2006, 08:08:44 AM »
Hi  :-D

I now need to draw this solid (in the picture), it has 6 edges and with fillet at the edge,
I use the draw pline outline-> extrude -> 3d array -> intersect to draw this one
but I  wonder to know how to use the fillet command to the solid entity in Lisp, 
I know little about the solid dxf.

Thank you very much

http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

Adesu

  • Guest
Re: how to use the fillet command to the solid entity in Lisp
« Reply #1 on: August 27, 2006, 07:58:25 PM »
Hi yuanqiu,
I'm not to explain how to fillet in solid model,I only send you a sample  to fillet an object,you should learn about it,here that code
Code: [Select]
; asbak is stand for a thing for rest of ash
;        Design by  : Adesu <Ade Suharna>
;        Email      : mteybid@yuasabattery.co.id
;        Homepage   : http://www.yuasa-battery.co.id
;        Create     : 24 March 2004
;        Program no.: 0005/03/2004
;        Edit by    : Adesu   30/07/2005  alls).
(defun c:asbak (/ ang cnt e el1 el11 el12 el13 el14 el2 el3
el4 el5 el6 hei hei1 hei2 lay loc loc1 p1 p2
p3 p4 p5 p6 p7 p8 p9 rade radi rado radv ss)
  (command "_vpoint" "r" 270 90 "")
  (command "_ucsicon" "off")
  (command "_shademode" "2d")
  (setq lay "ASBAK ROKOK")
  (if
    (not
      (tblsearch "layer" lay))                 
    (command "_layer" "m" lay "c" 1 "" ""))
  (command "_vpoint" "r" 275 20 "") 
  (setq loc '(0 0 0))
  (setq rado 6)                                               ; radius outter
  (command "_circle" loc rado)                                ; create outer circle
  (setq el1 (entlast))
  (setq hei 5)
  (command "_extrude" el1 "" hei "" "")                       ; to extrude outer circle
  (setq el2 (entlast))
  (setq p1 (polar loc 0 rado))
  (command "_fillet" "r" 1 "_fillet" p1 "" "c" "e" "")        ; to fillet bottom circle
  (setq p2 (list (car loc)(cadr loc) hei))
  (setq p3 (polar p2 0 rado))
  (command "_fillet" "r" 0.5 "_fillet" p3 "" "c" "e" "")      ; to fillet top cirle
  (setq loc1 (list (car loc)(cadr loc) 1))
  (setq radi (* rado 0.75))                                   ; radius inner
  (command "_circle" loc1 radi)                               ; create inner circle
  (setq el3 (entlast))
  (command "_extrude" el3 "" hei "" "")                       ; to extrude inner circle
  (setq el4 (entlast))
  (setq p4 (polar loc1 0 radi))
  (command "_fillet" "r" 2 "_fillet" p4 "" "c" "e" "")        ; to fillet inner circle
  (command "_subtract" el2 "" el4 "")                         ; to subtract outer by inner
  (command "_zoom" "e")
  (setq p5 (polar p2 0 radi))
  (command "_fillet" "r" 0.05 "_fillet" p5 "" "c" "e" "")     ; to fillet inner hole
  (setq rade (* rado 0.2))                                    ; radius cigarete fixer
  (command "_circle" p2 rade)                                 ; create radius
  (setq el5 (entlast))
  (command "_extrude" el5 "" rado "0" "")                     ; to extrude cigarete fixer
  (setq el6 (entlast)) 
  (if (not (member "geom3d.arx" (arx)))
    (arxload "geom3d"))
  (rotate3d el6 "y" p2 "r" 0 90)                              ; to rotate from vertical to horizontal
  (setq e (entlast))             
  (setq ss (ssadd e)) 
  (command "_array" "l" "" "p" loc 4 360 "" "")               ; to copy array
  (repeat 3
    (setq e (entnext e))
    (setq ss (ssadd e ss))
    )
  (command "union" ss "")                                                             
  (command "_subtract" el2 "" ss "")                           
  (setq radv (* rado 0.05))
  (setq hei1 (* hei 0.5))
  (setq p6 (polar loc 0 rado))
  (setq p7 (list (car p6)(cadr p6) hei1))
  (command "_circle" p7 radv)
  (setq el11 (entlast))
  (rotate3d el11 "x" p7 "r" 0 90)
  (setq el12 (entlast))
  (setq p8 (list (car loc)(cadr loc) hei1))
  (command "_circle" p8 rado)
  (setq el13 (entlast))
  (command "_extrude" el12 "" "p" el13)
  (setq el14 (entlast))
  (entdel el13)
  (command "_subtract" el2 "" el14 "")
  (setq ang 0) 
  (setq cnt 0)
  (repeat 113
    (setq p9 (polar loc ang rado))
    (command "_circle" p9 radv)
    (setq hei2 (* hei 0.3))
    (command "_extrude" "l" "" hei2 "0" "")
    (command "_subtract" el2 "" "l" "")
    (setq cnt (1+ cnt))
    (setq ang (+ ang 0.0556))
    )
  (command "_shademode" "g")
  (command "_3dorbit")
  (princ)
  )

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: how to use the fillet command to the solid entity in Lisp
« Reply #2 on: August 27, 2006, 09:43:56 PM »
Thank you very much. the solid entitis drawn by your rountine is rather cool~
Your rountine DO solve my question. thank you~~
(command "_fillet" "r" 1 "_fillet" p1 "" "c" "e" "")
is what I want to know.

May I ask one more question, it seems that the chamfer be use in the 3d solid entites
but fillet can do it, can I do the linear fillet (no curve) like chamfer at the solid edge?
or I have to use substract?

My oringinal rountine to draw a solid entities like the picture is as follow, but
after you teach me how to use fillet, I think the code will be shorten a lot.
Code: [Select]
;;; ========================================================================
;;; the following code are writen by CHEN QING JUN                         ;
;;; Civil engineering Department, South China University of Technology     ;
;;; Purpose: To draw a 3d thread                                           ;
;;; 2006.08.25                                                             ;
;;; Http://autolisper.googlepages.com                                      ;
;;; Http://qjchen.googlepages.com                                          ;
;;; ========================================================================
(defun c:3d (/ a b c d f g h i j l k copydis e3 e9 thread ringhole ring bolt bolt2hole p kword)
  (setting)
  (setq a 5.0
b 1.0
c 20.0
d 5.2
f 0.5
g 1.5
h 2.2
i 3.2
j 0.6
l 0.7
k 0.25
copydis 14.0
  )
  (3dthread)
  (3dring)
  (3dringhole)
  (3dbolt)
  (3dbolthole)
  (COMMAND "_ZOOM" "E" "zoom" ".5x")
  (moveandrotate)
  (resetting)
)

;;; ========================================================================
;;; draw 3d thread cylinder                                                ;
;;; ========================================================================
(defun 3dthread(/ e e0 e1 e2 elist blist)
  (setq e (list 0.0 0.0 0.0))
  (setq e0 (polar e (* pi 0.5) a)
e1 (polar e0 (* pi 0.25) (* b (sqrt 2)))
e2 (polar e1 0 c)
e3 (polar e2 (* pi 1.5) (+ a b))
  )
  (setq elist (list e e0 e1 e2 e3))
  (setq blist (list 0.0 (- (a2b 90.0)) 0.0 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq thread (entlast))
)

;;; ========================================================================
;;; draw 3d ring                                                           ;
;;; ========================================================================
(defun 3dring(/ e4 e5 e6 e7 e8 elist blist e)
  (setq e4 e3
e5 (polar e4 (* pi 0.5) (+ a b d))
e6 (polar e5 (* pi 0.75) (* f (sqrt 2)))
e7 (polar e6 (* pi 1.0) g)
e8 (polar e7 (* pi 1.25) (* f (sqrt 2)))
e9 (polar e8 (* pi 1.5) (+ a b d))
  )
  (setq elist (list e4 e5 e6 e7 e8 e9))
  (setq blist (list 0.0 (a2b 90.0) 0.0 (a2b 90.0) 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq ring (entlast))
)

;;; ========================================================================
;;; draw 3d ring hole                                                      ;
;;; ========================================================================
(defun 3dringhole(/ e30 e29 e28 e27 e26 e25 elist blist e hole)
  (setq e30 e3
e29 (polar e30 (* pi 0.5) (+ a b k))
e28 (polar e29 (* pi 1.25) (* k (sqrt 2)))
e27 (polar e28 (* pi 1.0) (- (+ g f f) k k))
e26 (polar e27 (* pi 0.75) (* k (sqrt 2)))
e25 e9
  )
  (setq elist (list e30 e29 e28 e27 e26 e25))
  (setq blist (list 0.0 0.0 0.0 0.0 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq hole (entlast))
  (command "_subtract" ring "" hole "")
  (setq ringhole (entlast))
)
;;; ========================================================================
;;; draw 3d bolt1                                                          ;
;;; ========================================================================
(defun 3dbolt(/ e10 e11 e12 e13 e14 e15 e16 e17 e18 elist blist ent hnew ent1 ent2)
(setq e10 e3
e11 (polar e10 (* pi 0.5) (+ a b h))
e12 (polar e11 (* pi 0.25) (* j (sqrt 2)))
e13 (polar e12 (* pi 0.0) i)
e14 (polar e13 (* pi 1.75) (* j (sqrt 2)))
e15 (polar e14 (* pi 1.5) (* 2 (+ a b h)))
e16 (polar e15 (* pi 1.25) (* j (sqrt 2)))
e17 (polar e16 (* pi 1.0) i)
e18 (polar e17 (* pi 0.75) (* j (sqrt 2))); e19 (polar e17 (* pi 0.5) (+ a b h))

  )
  (setq elist (list e10 e11 e12 e13 e14 e15 e16 e17 e18))
  (setq blist (list 0.0 (- (a2b 90.0)) 0.0 (- (a2b 90.0)) 0.0 (-
(a2b 90.0)
      ) 0.0
    (- (a2b 90.0)) 0.0
      )
  )
  (makepline elist blist);(make_pline elist)
  (setq ent (entlast))
  (setq hnew (* 5 (+ a b h)))
  (command "_extrude" ent "" hnew "" "")
  (setq ent (entlast))
  (command "_move" ent "" (list 0.0 0.0 0.0) (list 0.0 0.0 (- (* 0.5 hnew))))
  (command "_copy" ent "" (list 0.0 0.0 0.0) (list 0.0 0.0 0.0))
  (setq ent1 (entlast))
  (command "_rotate3d" ent1 "" "x" (list 0.0 0.0 0.0) 60)
  (command "_copy" ent "" (list 0.0 0.0 0.0) (list 0.0 0.0 0.0))
  (setq ent2 (entlast))
  (command "_rotate3d" ent2 "" "x" (list 0.0 0.0 0.0) 120)
  (command "_intersect" ent ent1 ent2 "")
  (setq bolt (entlast))
)


;;; ========================================================================
;;; copy bolt1 to bolt2 and draw bolt2 hole                                ;
;;; ========================================================================
(defun 3dbolthole(/ bolt2 e19 e20 e21 e22 e23 e24 elist blist e hole)
  (command "_copy" bolt "" (list 0.0 0.0 0.0) (list (- copydis) 0.0 0.0))
  (setq bolt2 (entlast))
  (setq e19 (polar e3 (* pi 1.0) copydis)
        e20 (polar e19 (* pi 0.5) (+ a b l))
e21 (polar e20 (* pi 1.75) (* l (sqrt 2)))
e22 (polar e21 (* pi 0.0) (- (+ i j j) l l))
e23 (polar e22 (* pi 0.25) (* l (sqrt 2)))
e24 (polar e19 0.0 (+ i j j))
  )
  (setq elist (list e19 e20 e21 e22 e23 e24))
  (setq blist (list 0.0 0.0 0.0 0.0 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq hole (entlast))
  (command "_subtract" bolt2 "" hole "") 
  (setq bolt2hole (entlast))
)

;;; ========================================================================
;;; move and rotate                                                        ;
;;; ========================================================================
(defun moveandrotate(/ p kword)
  (setq p (getpoint "the position"))
  (initget "x y z")
  (setq kword (getkword "\n please select the direction: x/y/z:"))
  (cond
    ((= kword "x")
      (command "_move" thread ringhole bolt bolt2hole "" (list 0.0 0.0 0.0) p)
    )
    ((= kword "y")
      (command "_move" thread ringhole bolt bolt2hole "" (list 0.0 0.0 0.0) p)
      (command "_rotate3d" "p" "" "z" p 90.0)
    )
    ((= kword "z")
      (command "_move" thread ringhole bolt bolt2hole "" (list 0.0 0.0 0.0) p)
      (command "_rotate3d" "p" "" "y" p (- 90.0))
    )
   
  )
 
)

;;; ========================================================================
;;; draw pline by ptlist and bulgelist, by el at theswamp                  ;
;;; ========================================================================
(defun makepline (plist blist)
  (entmakex (apply
      (function append)
      (cons
      (list
      '(0 . "LWPOLYLINE")
      '(100 . "AcDbEntity")
      '(67 . 0)
      '(410 . "Model")
      ;'(8 . "New_polyline")
      '(62 . 3)
      '(100 . "AcDbPolyline")
      (cons 90 (length plist))
      '(70 . 1)
      ;;'(70 . 1) = Closed
      ) ;_ list
      (mapcar
  (function list)
  (mapcar
     (function (lambda (a)
(cons 10 a)
      )
    )
    plist
  )
  (mapcar
    (function (lambda (a)
(cons 42 a)
      )
    )
    blist
  )
             ) ;_ mapcar
    ) ;_ cons
    ) ;_ apply
  ) ;_ entmakex
)
;;; ========================================================================
;;; by QJCHEN, change bulge to angle                                       ;
;;; ========================================================================
(defun a2b (a)
  (defun d2r (a)
    (* (/ a 180) pi)
  )
  (defun tan (a)
    (/ (sin (d2r a)) (cos (d2r a)))
  )
  (tan (/ a 4))
)

;;; ========================================================================
;;;   The following code taken from Mr.Tony Hotchkiss at Cadalyst          ;
;;;   To set and reset the system variable                                 ;
;;; ========================================================================
(defun err (s)
  (if (= s "Function cancelled")
    (princ "\nfunction - cancelled: ")
    (progn
      (princ "\nfunction - Error: ")
      (princ s)
      (terpri)
    )        ; _ end of progn
  )        ; _ end of if
  (resetting)
  (princ "SYSTEM VARIABLES have been reset\n")
  (princ)
)
;;; err
;;; setting and resetting the system variables
(defun setv (systvar newval / x)
  (setq x (read (strcat systvar "1")))
  (set x (getvar systvar))
  (setvar systvar newval)
)
;;; setv
(defun setting ()
(command "_undo" "_be")
  (setq oerr *error*)
  (setq *error* err)
  (setv "BLIPMODE" 0)
  (setv "CMDECHO" 0)
  (setv "OSMODE" 0)
)
;;; setting
(defun rsetv (systvar)
  (setq x (read (strcat systvar "1")))
  (setvar systvar (eval x))
)
;;; rsetv
(defun resetting ()
  (rsetv "BLIPMODE")
  (rsetv "CMDECHO")
  (rsetv "OSMODE")
  (setq *error* oerr)
  (command "_undo" "_e")
)

« Last Edit: August 27, 2006, 09:45:40 PM by yuanqiu »
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

Adesu

  • Guest
Re: how to use the fillet command to the solid entity in Lisp
« Reply #3 on: August 29, 2006, 03:12:40 AM »
Hi yuanqiu,
if I see your code,your code too complex and long,with simple trick ,I thinks it code would more simple.
now you ask about chamfer in the solid object,I forgot that file where save ,I would check and I would post here,here sample to fillet a solid object
Code: [Select]
(defun c:bolt1 (/ el1 el2 frad len loc p1 rad)
  (command "_vpoint" "r" 275 35 "")
  (setq loc '(0 0 0))
  (setq rad 3)
  (command "_circle" loc rad "")
  (setq el1 (entlast))
  (setq len 10)
  (command "_extrude" el1 "" len 0 "")
  (setq el2 (entlast))
  (setq p1 (polar loc 0 rad))
  (setq frad 0.5)
  (command "_fillet" "r" frad "_fillet" p1 "" "c" "e" "")
  (princ)
  )


Thank you very much. the solid entitis drawn by your rountine is rather cool~
Your rountine DO solve my question. thank you~~
(command "_fillet" "r" 1 "_fillet" p1 "" "c" "e" "")
is what I want to know.

May I ask one more question, it seems that the chamfer be use in the 3d solid entites
but fillet can do it, can I do the linear fillet (no curve) like chamfer at the solid edge?
or I have to use substract?

My oringinal rountine to draw a solid entities like the picture is as follow, but
after you teach me how to use fillet, I think the code will be shorten a lot.
Code: [Select]
;;; ========================================================================
;;; the following code are writen by CHEN QING JUN                         ;
;;; Civil engineering Department, South China University of Technology     ;
;;; Purpose: To draw a 3d thread                                           ;
;;; 2006.08.25                                                             ;
;;; Http://autolisper.googlepages.com                                      ;
;;; Http://qjchen.googlepages.com                                          ;
;;; ========================================================================
(defun c:3d (/ a b c d f g h i j l k copydis e3 e9 thread ringhole ring bolt bolt2hole p kword)
  (setting)
  (setq a 5.0
b 1.0
c 20.0
d 5.2
f 0.5
g 1.5
h 2.2
i 3.2
j 0.6
l 0.7
k 0.25
copydis 14.0
  )
  (3dthread)
  (3dring)
  (3dringhole)
  (3dbolt)
  (3dbolthole)
  (COMMAND "_ZOOM" "E" "zoom" ".5x")
  (moveandrotate)
  (resetting)
)

;;; ========================================================================
;;; draw 3d thread cylinder                                                ;
;;; ========================================================================
(defun 3dthread(/ e e0 e1 e2 elist blist)
  (setq e (list 0.0 0.0 0.0))
  (setq e0 (polar e (* pi 0.5) a)
e1 (polar e0 (* pi 0.25) (* b (sqrt 2)))
e2 (polar e1 0 c)
e3 (polar e2 (* pi 1.5) (+ a b))
  )
  (setq elist (list e e0 e1 e2 e3))
  (setq blist (list 0.0 (- (a2b 90.0)) 0.0 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq thread (entlast))
)

;;; ========================================================================
;;; draw 3d ring                                                           ;
;;; ========================================================================
(defun 3dring(/ e4 e5 e6 e7 e8 elist blist e)
  (setq e4 e3
e5 (polar e4 (* pi 0.5) (+ a b d))
e6 (polar e5 (* pi 0.75) (* f (sqrt 2)))
e7 (polar e6 (* pi 1.0) g)
e8 (polar e7 (* pi 1.25) (* f (sqrt 2)))
e9 (polar e8 (* pi 1.5) (+ a b d))
  )
  (setq elist (list e4 e5 e6 e7 e8 e9))
  (setq blist (list 0.0 (a2b 90.0) 0.0 (a2b 90.0) 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq ring (entlast))
)

;;; ========================================================================
;;; draw 3d ring hole                                                      ;
;;; ========================================================================
(defun 3dringhole(/ e30 e29 e28 e27 e26 e25 elist blist e hole)
  (setq e30 e3
e29 (polar e30 (* pi 0.5) (+ a b k))
e28 (polar e29 (* pi 1.25) (* k (sqrt 2)))
e27 (polar e28 (* pi 1.0) (- (+ g f f) k k))
e26 (polar e27 (* pi 0.75) (* k (sqrt 2)))
e25 e9
  )
  (setq elist (list e30 e29 e28 e27 e26 e25))
  (setq blist (list 0.0 0.0 0.0 0.0 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq hole (entlast))
  (command "_subtract" ring "" hole "")
  (setq ringhole (entlast))
)
;;; ========================================================================
;;; draw 3d bolt1                                                          ;
;;; ========================================================================
(defun 3dbolt(/ e10 e11 e12 e13 e14 e15 e16 e17 e18 elist blist ent hnew ent1 ent2)
(setq e10 e3
e11 (polar e10 (* pi 0.5) (+ a b h))
e12 (polar e11 (* pi 0.25) (* j (sqrt 2)))
e13 (polar e12 (* pi 0.0) i)
e14 (polar e13 (* pi 1.75) (* j (sqrt 2)))
e15 (polar e14 (* pi 1.5) (* 2 (+ a b h)))
e16 (polar e15 (* pi 1.25) (* j (sqrt 2)))
e17 (polar e16 (* pi 1.0) i)
e18 (polar e17 (* pi 0.75) (* j (sqrt 2))); e19 (polar e17 (* pi 0.5) (+ a b h))

  )
  (setq elist (list e10 e11 e12 e13 e14 e15 e16 e17 e18))
  (setq blist (list 0.0 (- (a2b 90.0)) 0.0 (- (a2b 90.0)) 0.0 (-
(a2b 90.0)
      ) 0.0
    (- (a2b 90.0)) 0.0
      )
  )
  (makepline elist blist);(make_pline elist)
  (setq ent (entlast))
  (setq hnew (* 5 (+ a b h)))
  (command "_extrude" ent "" hnew "" "")
  (setq ent (entlast))
  (command "_move" ent "" (list 0.0 0.0 0.0) (list 0.0 0.0 (- (* 0.5 hnew))))
  (command "_copy" ent "" (list 0.0 0.0 0.0) (list 0.0 0.0 0.0))
  (setq ent1 (entlast))
  (command "_rotate3d" ent1 "" "x" (list 0.0 0.0 0.0) 60)
  (command "_copy" ent "" (list 0.0 0.0 0.0) (list 0.0 0.0 0.0))
  (setq ent2 (entlast))
  (command "_rotate3d" ent2 "" "x" (list 0.0 0.0 0.0) 120)
  (command "_intersect" ent ent1 ent2 "")
  (setq bolt (entlast))
)


;;; ========================================================================
;;; copy bolt1 to bolt2 and draw bolt2 hole                                ;
;;; ========================================================================
(defun 3dbolthole(/ bolt2 e19 e20 e21 e22 e23 e24 elist blist e hole)
  (command "_copy" bolt "" (list 0.0 0.0 0.0) (list (- copydis) 0.0 0.0))
  (setq bolt2 (entlast))
  (setq e19 (polar e3 (* pi 1.0) copydis)
        e20 (polar e19 (* pi 0.5) (+ a b l))
e21 (polar e20 (* pi 1.75) (* l (sqrt 2)))
e22 (polar e21 (* pi 0.0) (- (+ i j j) l l))
e23 (polar e22 (* pi 0.25) (* l (sqrt 2)))
e24 (polar e19 0.0 (+ i j j))
  )
  (setq elist (list e19 e20 e21 e22 e23 e24))
  (setq blist (list 0.0 0.0 0.0 0.0 0.0 0.0))
  (makepline elist blist)
  (setq e (entlast))
  (command "_REVOLVE" e "" "x" "")
  (setq hole (entlast))
  (command "_subtract" bolt2 "" hole "") 
  (setq bolt2hole (entlast))
)

;;; ========================================================================
;;; move and rotate                                                        ;
;;; ========================================================================
(defun moveandrotate(/ p kword)
  (setq p (getpoint "the position"))
  (initget "x y z")
  (setq kword (getkword "\n please select the direction: x/y/z:"))
  (cond
    ((= kword "x")
      (command "_move" thread ringhole bolt bolt2hole "" (list 0.0 0.0 0.0) p)
    )
    ((= kword "y")
      (command "_move" thread ringhole bolt bolt2hole "" (list 0.0 0.0 0.0) p)
      (command "_rotate3d" "p" "" "z" p 90.0)
    )
    ((= kword "z")
      (command "_move" thread ringhole bolt bolt2hole "" (list 0.0 0.0 0.0) p)
      (command "_rotate3d" "p" "" "y" p (- 90.0))
    )
   
  )
 
)

;;; ========================================================================
;;; draw pline by ptlist and bulgelist, by el at theswamp                  ;
;;; ========================================================================
(defun makepline (plist blist)
  (entmakex (apply
      (function append)
      (cons
      (list
      '(0 . "LWPOLYLINE")
      '(100 . "AcDbEntity")
      '(67 . 0)
      '(410 . "Model")
      ;'(8 . "New_polyline")
      '(62 . 3)
      '(100 . "AcDbPolyline")
      (cons 90 (length plist))
      '(70 . 1)
      ;;'(70 . 1) = Closed
      ) ;_ list
      (mapcar
  (function list)
  (mapcar
     (function (lambda (a)
(cons 10 a)
      )
    )
    plist
  )
  (mapcar
    (function (lambda (a)
(cons 42 a)
      )
    )
    blist
  )
             ) ;_ mapcar
    ) ;_ cons
    ) ;_ apply
  ) ;_ entmakex
)
;;; ========================================================================
;;; by QJCHEN, change bulge to angle                                       ;
;;; ========================================================================
(defun a2b (a)
  (defun d2r (a)
    (* (/ a 180) pi)
  )
  (defun tan (a)
    (/ (sin (d2r a)) (cos (d2r a)))
  )
  (tan (/ a 4))
)

;;; ========================================================================
;;;   The following code taken from Mr.Tony Hotchkiss at Cadalyst          ;
;;;   To set and reset the system variable                                 ;
;;; ========================================================================
(defun err (s)
  (if (= s "Function cancelled")
    (princ "\nfunction - cancelled: ")
    (progn
      (princ "\nfunction - Error: ")
      (princ s)
      (terpri)
    )        ; _ end of progn
  )        ; _ end of if
  (resetting)
  (princ "SYSTEM VARIABLES have been reset\n")
  (princ)
)
;;; err
;;; setting and resetting the system variables
(defun setv (systvar newval / x)
  (setq x (read (strcat systvar "1")))
  (set x (getvar systvar))
  (setvar systvar newval)
)
;;; setv
(defun setting ()
(command "_undo" "_be")
  (setq oerr *error*)
  (setq *error* err)
  (setv "BLIPMODE" 0)
  (setv "CMDECHO" 0)
  (setv "OSMODE" 0)
)
;;; setting
(defun rsetv (systvar)
  (setq x (read (strcat systvar "1")))
  (setvar systvar (eval x))
)
;;; rsetv
(defun resetting ()
  (rsetv "BLIPMODE")
  (rsetv "CMDECHO")
  (rsetv "OSMODE")
  (setq *error* oerr)
  (command "_undo" "_e")
)



Adesu

  • Guest
Re: how to use the fillet command to the solid entity in Lisp
« Reply #4 on: August 29, 2006, 04:17:13 AM »
Hi yuanqiu,
Here a trick to chamfer and fillet an object
Code: [Select]
(defun c:bolt2 (/ el1 el2 frad len loc p1 rad)
  (command "_vpoint" "r" 275 35 "")
  (setq loc '(0 0 0))
  (setq rad 3)
  (command "_circle" loc rad "")
  (setq el1 (entlast))
  (setq len 10)
  (command "_extrude" el1 "" len 0 "")
  (setq el2 (entlast))
  (setq p1 (polar loc 0 2.5))
  (setq p2 (polar p1 (* pi 0.25) 0.7071))
  (setq p3 (polar p2 0 0.5))
  (setq p4 (polar p3 (* pi 1.5) 1))
  (setq p5 (polar p4 pi 1))
  (command "_pline" p1 p2 p3 p4 p5 "c" "")
  (setq el3 (entlast))
  (if
    (not (member "geom3d.arx" (arx)))
    (arxload "geom3d")
    )
  (rotate3d el3 "x" p1 "r" 0 90)
  (setq el4 (entlast))
  (setq p6 (list (car loc)(cadr loc) 10))
  (command "_line" loc p6 "")
  (setq el5 (entlast))
  (command "revolve" el4 "" "o" el5 "")
  (setq el6 (entlast))
  (command "_erase" el5 "")
  (command "_subtract" el2 "" el6 "")
  (command "_shademode" "g")
  (command "_3dorbit")
  (princ)
  )

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: how to use the fillet command to the solid entity in Lisp
« Reply #5 on: August 29, 2006, 09:48:30 AM »
thank you, adesu, it do the chamfer-like action

but it still seems that the chamfer is hard to directly used by solid lisp, yeah?

the substract have to be used, when the solid is more irregular, it maybe hard, or we should write a rountine to just do draw a temp object at the edge and substract it from the original object.
maybe the fillet command to solid is also wrote by substract:)

Thank you again.
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

Tramber

  • Guest
Re: how to use the fillet command to the solid entity in Lisp
« Reply #6 on: August 31, 2006, 05:34:12 AM »
I got one thing to say :

Chamfer or fillet requires a good point of view.

I'm experienced in sending those commands on solids through lisp and I ever noticed that the point of view and the zoom condition are important.
It also occured that the prog works on my machine and did not on an other one, because of the aperture setting (size of the grip).

Evrytime it was possible, I also wrote routines to substract rather than to send commands.

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: how to use the fillet command to the solid entity in Lisp
« Reply #7 on: August 31, 2006, 06:28:34 AM »
Thank you bert'
You means the 3d operation are very associated with the view, can I calculate the 3d point coordinate and then apply it in the plane view?

could I ask one more question, could the following pic be drawn by autocad?

It is a steel space joint, 7 box beam connect at one point, then complicate intersect line produced, and this entity must be solid so that it could be imported into finite element analysis.

I try to write some rountine, but fail, I think  it maybe model by SOLIDWORK or UG or PROE or CATIA. I try to model it in CATIA, but I am not family with it, so also fail.

could you tell me is it possible to draw it by autocad( include rountine)
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

Tramber

  • Guest
Re: how to use the fillet command to the solid entity in Lisp
« Reply #8 on: August 31, 2006, 11:12:14 AM »
Everything is possible, and 2007 change dramaticly my opinion again. But your part doesn't look very easy and I can not help very much from here.

Quote
You means the 3d operation are very associated with the view, can I calculate the 3d point coordinate and then apply it in the plane view?

(in my previous message I meant iso not perspective, sorry).

Well look at my picture. It is a step of a stair system. There can be an infinity of different dimensions. And still it happens that my fillets sometimes don't work. I developped an option in my programms to work on a slightly different point of view and then, the routine doesn't stop.

But let us imagine that my program works with a plane view (a top view), there would be a real ambiguity, 2 possibilities between 2 lines. To my experience, on this example, I rapidly felt that the iso view was an obligation.

Give it a try but, if I remember well, it is better to have an angle of view.

Since then it works (quite) good.


qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: how to use the fillet command to the solid entity in Lisp
« Reply #9 on: September 02, 2006, 12:54:59 AM »
Thank you bert, you have given me a bright way, I need sometime to think over about how to solve the problem.
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)