+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Dec 2013
    Posts
    26

    Default Help shading a circular area with entmake hatch

    Registered forum members do not see this ad.

    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.

    Code:
    (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))
    ))
    Last edited by plackowski; 27th Dec 2013 at 04:58 pm.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Try the following:
    Code:
    (defun c:test ( / cen ocs rad )
        (if
            (and
                (setq cen (getpoint "\nCenter: "))
                (setq rad (getdist cen "\nRadius: "))
                (setq ocs (trans '(0.0 0.0 1.0) 1 0 t))
            )
            (entmake
                (list
                   '(000 . "HATCH")
                   '(100 . "AcDbEntity")
                   '(100 . "AcDbHatch")
                   '(010 0.0 0.0 0.0)
                    (cons 210 ocs)
                   '(002 . "SOLID")
                   '(070 . 1)
                   '(071 . 0)
                   '(091 . 1)
                   '(092 . 0)
                   '(093 . 1)
                   '(072 . 2)
                    (cons 010 (trans cen 1 ocs))
                    (cons 040 rad)
                   '(050 . 0.0)
                    (cons 051 (+ pi pi))
                   '(073 . 1)
                   '(097 . 0)
                   '(075 . 0)
                   '(076 . 1)
                   '(098 . 1)
                    (cons 010 (trans cen 1 ocs))
                )
            )
        )
        (princ)
    )
    The above should also work in all UCS & Views.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Senior Member ymg3's Avatar
    Using
    not applicable
    Join Date
    May 2011
    Posts
    414

    Default

    Try this function:

    To obtain circle call with (pwipeout ctr rad 30)

    Code:
    ;; 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)
            )
        )
    )

  4. #4
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Dec 2013
    Posts
    26

    Default

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

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Quote Originally Posted by plackowski View Post
    Thank you both, I've got it working now!
    Excellent - you're welcome plackowski!
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  6. #6
    Junior Member
    Discipline
    Construction
    Quest for Peace's Discipline Details
    Occupation
    Engineer, VP
    Discipline
    Construction
    Details
    Electrical
    Using
    AutoCAD 2015
    Join Date
    Sep 2011
    Location
    Sacramento, CA
    Posts
    24

    Default

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

  7. #7
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    565

    Default

    hi
    Code:
    ...
    (cons 051 (+ pi  pi ))
    ...
    replace to
    Code:
    ...
    (cons 051 pi )
    ...
    HTH , all credit to Lee Mac

    this is an alternative solid half-circle
    Code:
    (defun c:test (/ p r v)
    (setq v (getvar "osmode"))
      (if (and (setq p (getpoint "\nPick center: "))
    	   (setq r (getdist p "\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
    Last edited by hanhphuc; 26th Oct 2014 at 01:44 pm. Reason: getdist p
    lambda not optimized.. ( apply '= "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

  8. #8
    Junior Member
    Discipline
    Construction
    Quest for Peace's Discipline Details
    Occupation
    Engineer, VP
    Discipline
    Construction
    Details
    Electrical
    Using
    AutoCAD 2015
    Join Date
    Sep 2011
    Location
    Sacramento, CA
    Posts
    24

    Default

    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?

    Code:
    (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 . "")))

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Please post a drawing showing the intended result.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  10. #10
    Junior Member
    Discipline
    Construction
    Quest for Peace's Discipline Details
    Occupation
    Engineer, VP
    Discipline
    Construction
    Details
    Electrical
    Using
    AutoCAD 2015
    Join Date
    Sep 2011
    Location
    Sacramento, CA
    Posts
    24

    Default

    Registered forum members do not see this ad.

    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,
    Attached Images

Similar Threads

  1. Entmake of a Hatch
    By Quest for Peace in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 2nd Nov 2011, 02:28 pm
  2. Entmake HATCH entity
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 1
    Last Post: 14th Oct 2010, 10:01 am
  3. Selecting Circular Area
    By vlsf1980 in forum AutoCAD General
    Replies: 13
    Last Post: 19th May 2009, 10:02 am
  4. Entmake Hatch
    By Lee Mac in forum AutoLISP, Visual LISP & DCL
    Replies: 38
    Last Post: 21st Apr 2009, 09:06 pm
  5. circular hatch?
    By Rebel in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 18th Apr 2005, 10:04 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts