Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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 :ouch:

Posted

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

Posted

Thank you again Mircea for help and lesson :).

Posted

You're welcome!

So, did you manage to finnish your routine?

 

Regards,

Mircea

Posted

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 :).

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...