koletutor Posted April 3, 2012 Posted April 3, 2012 Hello, I have created this little lisp for drawing two arcs in the "young moon" shape inside picked circle. Now I need your help to teach me how to hatch or solid fill that area ... (defun c:test () ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;get info of circle (setq circleObj (car(entsel "\nSelect circle :"))) ;Get ename of circle object picked (setq e_circleObj (entget circleObj)) ;Get record of Entity Circle (setq cp (cdr (assoc 10 e_circleObj))) ;Get Center Point by dxf 10 (setq r (cdr (assoc 40 e_circleObj))) ;Get Radius by dxf 40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Calculation (setq a1 (* 2 (/ r 10))) (setq r1 (- r a1)) (setq r2 (sqrt (+ (expt a1 2) (expt r1 2)))) (setq alfa1 (- (* 2 pi) (atan (/ r1 a1)))) (setq alfa2 (atan (/ r1 a1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Draw ;Arc 1 (progn (entmakex (list (cons 0 "ARC") (cons 10 cp) (cons 40 r1) (cons 50 (* 3 (/ pi 2))) (cons 51 (/ pi 2)) );end list );end entmakex )end progn ;Arc 2 (progn (entmakex (list (cons 0 "ARC") (cons 10 (polar cp pi a1)) (cons 40 r2) (cons 50 alfa1) (cons 51 alfa2) );end list );end entmakex )end progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) ;end defun Thank you very much for you help. Quote
MSasu Posted April 3, 2012 Posted April 3, 2012 You may create a polyline from those arcs and call HATCH command on it: (command "_PEDIT" entityArc1st "" "_J" entityArc2nd "" "_HATCH" "_P" "SOLID" "_S" (entlast) "" "") Regards, Mircea Quote
koletutor Posted April 3, 2012 Author Posted April 3, 2012 Thank you Miricea for your reply. I also like your approach (I was thinking the same), but I dont know how to "call" arcs after pedit command to join them .... I tried to put your code after defining second arc and I got some error messages .... Maybe you think I should (not) do that Quote
MSasu Posted April 3, 2012 Posted April 3, 2012 The ENTMAKEX function will return the name of the entity: [color=red]; (progn[/color] [color=blue] (setq entityArc1st[/color] (entmakex (list (cons 0 "ARC") (cons 10 cp) (cons 40 r1) (cons 50 (* 3 (/ pi 2))) (cons 51 (/ pi 2)) );end list );end entmakex [color=blue] )[/color] [color=red]; )end progn[/color] Also, there is no need for those PROGN. Regards, Mircea Quote
koletutor Posted April 3, 2012 Author Posted April 3, 2012 Thank you again Mircea for help and lesson . Quote
MSasu Posted April 3, 2012 Posted April 3, 2012 You're welcome! So, did you manage to finnish your routine? Regards, Mircea Quote
koletutor Posted April 3, 2012 Author Posted April 3, 2012 Yes Mircea, with your great help I manage to finish this routine, and now it looks like this: (defun c:test () ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;get info of circle (setq circleObj (car(entsel "\nSelect circle :"))) ;Get ename of circle object picked (setq e_circleObj (entget circleObj)) ;Get record of Entity Circle (setq cp (cdr (assoc 10 e_circleObj))) ;Get Center Point by dxf 10 (setq r (cdr (assoc 40 e_circleObj))) ;Get Radius by dxf 40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Calculation (setq a1 (* 2 (/ r 10))) (setq r1 (- r a1)) (setq r2 (sqrt (+ (expt a1 2) (expt r1 2)))) (setq alfa1 (- (* 2 pi) (atan (/ r1 a1)))) (setq alfa2 (atan (/ r1 a1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Draw ;Arc 1 (setq entityArc1st (entmakex (list (cons 0 "ARC") (cons 10 cp) (cons 40 r1) (cons 50 (* 3 (/ pi 2))) (cons 51 (/ pi 2)) );end list );end entmakex );end setq ;Arc 2 (setq entityArc2nd (entmakex (list (cons 0 "ARC") (cons 10 (polar cp pi a1)) (cons 40 r2) (cons 50 alfa1) (cons 51 alfa2) );end list );end entmakex );end setq ;Draw poly (command "_PEDIT" entityArc1st "" "J" entityArc2nd "" "" "_HATCH" "SOLID" "_S" (entlast) "" ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) ;end defun Again thank you very much you taught me a lot . Quote
Recommended Posts
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.