Jump to content

Recommended Posts

Posted (edited)

I am working off of this code cadpanacea.com/node/186, but when I try to run the following, the radius of the circular hatch varies based on the 'ctr' variable's distance from the origin. I would like it to depend solely on the 'ctr' and 'edge' points.

 

(defun c:test()(setvar "osmode" 0)
(setq ctr (getpoint "\nCenter of Circle: "))
(setq edge (getpoint "\nEdge of Circle: "))
(entmakex (list
 (cons 0 "HATCH")
 (cons 100 "AcDbEntity")
 (cons 8 "E-GRND")
 (cons 100 "AcDbHatch")
 (cons 10 ctr)
 (cons 210 (list 0 0 1))
 (cons 2 "SOLID")
 (cons 70 1)
 (cons 71 0)
 (cons 91 1)
 (cons 92 1)
 (cons 93 1)
 (cons 72 3)                        ;the "3" designates this is an elliptical shape, 1 for circle
 (cons 10 ctr)                      ;center point of ellipse
 (cons 11 edge)                     ;point of top quad
 (cons 40 1)                        ;ratio of width to height
 (cons 50 0.0)                      ;start angle  
 (cons 51 (* pi 2.0))               ;end angle (full ellipse)
 (cons 73 1)                        ;counterclockwise flag
 (cons 97 0)       
 (cons 75 0)
 (cons 76 1)
 (cons 98 1)
 (cons 10 (list 0 0 0))
))

Edited by plackowski
Posted

Try the following:

([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] cen ocs rad )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] cen ([color=BLUE]getpoint[/color] [color=MAROON]"\nCenter: "[/color]))
           ([color=BLUE]setq[/color] rad ([color=BLUE]getdist[/color] cen [color=MAROON]"\nRadius: "[/color]))
           ([color=BLUE]setq[/color] ocs ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color]))
       )
       ([color=BLUE]entmake[/color]
           ([color=BLUE]list[/color]
              '(000 . [color=MAROON]"HATCH"[/color])
              '(100 . [color=MAROON]"AcDbEntity"[/color])
              '(100 . [color=MAROON]"AcDbHatch"[/color])
              '(010 0.0 0.0 0.0)
               ([color=BLUE]cons[/color] 210 ocs)
              '(002 . [color=MAROON]"SOLID"[/color])
              '(070 . 1)
              '(071 . 0)
              '(091 . 1)
              '(092 . 0)
              '(093 . 1)
              '(072 . 2)
               ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] cen 1 ocs))
               ([color=BLUE]cons[/color] 040 rad)
              '(050 . 0.0)
               ([color=BLUE]cons[/color] 051 ([color=BLUE]+[/color] [color=BLUE]pi[/color] [color=BLUE]pi[/color]))
              '(073 . 1)
              '(097 . 0)
              '(075 . 0)
              '(076 . 1)
              '(098 . 1)
               ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] cen 1 ocs))
           )
       )
   )
   ([color=BLUE]princ[/color])
)

The above should also work in all UCS & Views.

Posted

Try this function:

 

To obtain circle call with (pwipeout ctr rad 30)

 

;; Polygonal Wipeout  -  Lee Mac                                              ;
;; Creates an n-sided Polygonal Wipeout with the given center (UCS) & radius  ;
;;                                                                            ;
;; Modified by ymg                                                            ;

(defun pwipeout ( cen rad n / ang inc lst )
   (setq inc (/ pi n 0.5)
         ang (* (/ pi 2) -1)
   )
   (repeat n
       (setq lst (cons (list 14 (* 0.5 (cos ang)) (* 0.5 (sin ang))) lst)
             ang (+ ang inc)
       )
   )
   (entmakex
       (append
           (list
               (cons 0 "WIPEOUT")
               (cons 100 "AcDbEntity")
               (cons 100 "AcDbWipeout")
               (cons 10 (trans (mapcar '- cen (list rad rad)) 1 0))
               (cons 11 (trans (list (+ rad rad) 0.0) 1 0 t))
               (cons 12 (trans (list 0.0 (+ rad rad)) 1 0 t))
               (cons 280 1)
               (cons 71 2)
        (cons 91 (1+ (length lst)))
           )
           (cons (last lst) lst)
       )
   )
)

Posted

Thank you both, I've got it working now!

Posted
Thank you both, I've got it working now!

 

Excellent - you're welcome plackowski!

  • 9 months later...
Posted

On Lee's test program, thread post #2, I need to make a half circle (solid hatch). But I can't make it work.

Posted (edited)

hi

...
(cons 051 [color="red"](+ pi  pi )[/color])
...

replace to

...
(cons 051 [color="red"]pi[/color] )
...

HTH , all credit to Lee Mac

 

this is an alternative solid half-circle

(defun c:test (/ p r v)
(setq v (getvar "osmode"))
 (if (and (setq p (getpoint "\nPick center: "))
   (setq r (getdist [color="red"]p[/color] "\nRadius: ")))
   (command "_pline" p "w" r r "arc" (mapcar '+ p (list 0. r 0.)))
   ) ;_ end of if
 (if (= (getvar "cmdactive") 1)
   (command)
   ) ;_ end of if
(setvar "osmode" v)
(princ)
 ) ;_ end of defun

Edited by hanhphuc
getdist p
  • 2 months later...
Posted

I can't get it. I put this on the 'back-burner' for 3months now, coming back to it occasionally. The semi-circle needs a flat vertical edge that does not go through the center point.

 

This is what I have, started from a similar hatch that works. This doesn't make anything. What is the minimum definition? And I also need the mirror image of it, will that be apparent?

 

(entmake
   '((0 . "hatch")(100 . "AcDbEntity")(8 . "0")(62 . 0)(6 . "ByBlock")
(100 . "AcDbHatch")(10 0.0 0.0 0.0)(210 0.0 0.0 1.0)(2 . "SOLID")
(70 . 1)(71 . 0)(91 . 1)(92 . 1)(93 . 4)
(72 . 1)(10 3.8301 15.3204 0.0)(11 3.8301 4.55836 0.0)
(72 . 2)(10 1.91505 9.97494 0.0)(40 . 5.74515)(50 . 5.05223)(51 . 1.23096)
(73 . 1)(97 . 0)(75 . 0)(76 . 1)(98 . 1)(10 0.0 0.0 0.0)(450 . 0)(451 . 0)
(460 . 0.0)(461 . 0.0)(452 . 0)(462 . 0.0)(453 . 0)(470 . "")))

Posted

I wasn't sure how to do that. Here's a try. It's a controlled electrical receptacle symbol. I need one with both sides shaded and one with only one side shaded. Thanks for your help,

Cont.png

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