Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Drawing hatched rectangle

  1. #1
    Member
    Join Date
    2007-08
    Posts
    2
    Login to Give a bone
    0

    Default Drawing hatched rectangle

    Hello,

    I'm wondering about routine that makes it possible to:
    1. draw rectangle
    2. then pick up hatch pattern graphically that,
    3. would automatically fill up previously drawed rectangle.

    Please, help.

  2. #2
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    This will draw a rectangle to your specified width and height and also hatch according to th ealready set hatch pattern.

    Code:
    (defun recthatch ()
      (setq width (getreal "\nEnter width of rectangle: "))
      (setq height (getreal "\nEnter Height of rectangle: "))
      (setq pnt1 (getpoint "Select upper left hand corner for placement of rectangle: "))
      (command "rectangle" pnt1 (list(+(car pnt1)width)(-(cadr pnt1)height)))
      (setq ent1 (entlast))
      (command "-hatch" "S" ent1"" "")
    )
    In order to change the hatch pattern type then you will need to add
    Code:
    (command "-hatch" "S" ent1"" "P" "your hatch pattern name here" "your scale" "your angle for hatch pattern" "")
    in place of the current hatch command in the program. Of course you will need to specify the pattern, scale, and angle.

  3. #3
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    Also if you just want to draw a rectangle according to 2 selected points here is the code for it. Again the hatch code above will need to be inserted for you to define your own pattern, scale, and angle.

    Code:
    (defun recthatch ()
      (setq pnt1 (getpoint "Select upper left hand corner for placement of rectangle: "))
      (setq pnt2 (getcorner pnt1 "Select lower right hand corner for placement of rectangle: "))
      (command "rectangle" pnt1 pnt2)
      (setq ent1 (entlast))
      (command "-hatch" "S" ent1"" "")
    )

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    Quote Originally Posted by mathias2014
    Hello,

    I'm wondering about routine that makes it possible to:
    1. draw rectangle
    2. then pick up hatch pattern graphically that,
    3. would automatically fill up previously drawed rectangle.

    Please, help.
    Heres another one, I wrote this to create the image of rigid insulation, but you can modify the layer names and hatch pattern to do what ever you need.
    Code:
    ;;;;draws an end view of rigid insulation
    (defun C:RIGID (/ p1 p2 p3 p4 LR1 LR2 OSM)
    (setq lyr (getvar "clayer"))
    (setq strt_point (getpoint "Pick lower left corner"))(terpri)
    (setq len (getdist "How wide is your insulation? (horizontally)"))(terpri)
    (setq wid (getdist "How thick is your insulation? (vertically)"))(terpri)
    (setq Xp1 (car strt_point))
    (setq yp1 (cadr strt_point))
    (setq p1 (list xp1 yp1 0))
    (setq xp2 (+ xp1 len))
    (setq yp2 yp1)
    (setq p2 (list xp2 yp2 0))
    (setq xp3 xp2)
    (setq yp3 (+ yp2 wid))
    (setq osm (getvar "osmode"))
    (setq p3 (list xp3 yp3 0))
    (setq p4 (list xp1 yp3 0))
    	(SETQ LR1 (TBLSEARCH "LAYER" "S-INSL"))   
    	(SETQ LR2 (TBLSEARCH "LAYER" "S-INSL-PATT"))
    		(IF (= LR1 NIL)
    		(command "layer" "make" "S-INSL" "color" "1" "" ""))
    		(IF (= LR2 NIL)
    		(command "layer" "make" "S-INSL-PATT" "color" "10" "" ""))
    (setvar "osmode" 16384)
    (command "layer" "S" "S-INSL" "" "")
    (command "pline" p1 p2 p3 p4 "c") 
    (command "layer" "S" "S-INSL-PATT" "" "")
    (command "hatch" "ansi37" "8" "45" "last" "")
    (setvar "osmode" osm)
    (setvar "clayer" lyr)
    (princ)
    )
    Does this help?
    Lions 60 had some nice ones too.

  5. #5
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Thumbs up Re: Drawing hatched rectangle

    Quote Originally Posted by Lions60
    Also if you just want to draw a rectangle according to 2 selected points here is the code for it. Again the hatch code above will need to be inserted for you to define your own pattern, scale, and angle.

    Code:
     (defun recthatch ()
       (setq pnt1 (getpoint "Select upper left hand corner for placement of rectangle: "))
       (setq pnt2 (getcorner pnt1 "Select lower right hand corner for placement of rectangle: "))
       (command "rectangle" pnt1 pnt2)
       (setq ent1 (entlast))
       (command "-hatch" "S" ent1"" "")
     )
    Hey Lions60, I think you forgot your command prompt function (unless this is run within another program, I may be wrong).
    "(defun c:recthatch ()"
    Code:
    (defun c:recthatch ()
      (setq pnt1 (getpoint "Select upper left hand corner for placement of rectangle: "))
      (setq pnt2 (getcorner pnt1 "Select lower right hand corner for placement of rectangle: "))
      (command "rectangle" pnt1 pnt2)
      (setq ent1 (entlast))
      (command "-hatch" "S" ent1"" "P" "your pattern" "scale" "angle "")
    )
    I liked your version, much cleaner, I'll be using this for stuff for sure.
    Thanks.

  6. #6
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    You are correct i did forget. Feel free to use it however you need.

  7. #7
    Member
    Join Date
    2007-08
    Posts
    2
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    Is there any way to choose hatch pattern from a window like using bhatch function? I mean to call a window like by bhatch function, choose desired pattern, exit from window with pattern name as a parameter, countinue the program, call hatch function with from previously choosen patter as a hatch name parameter.

  8. #8
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    Give this a try.

    Code:
    (defun C:MHatch ()
        (defun *error* (MSG) ; local error handler to reset entity redraw
        (princ (strcat "\n" MSG))  ; return the error message
        (if old_osnap1 (setvar "osmode" old_osnap1))
        (if cmdecho (setvar "cmdecho" cmdecho))
      )
      (setq MHatch '("SOLID"
    		"ANGLE"
    		"ANSI31"
    		"ANSI32"
    		"ANSI33"
    		"ANSI34"
    		"ANSI35"
    		"ANSI36"
    		"ANSI37"
    		"ANSI38"
    		"AR-B816"
    		"AR-B816C"
    		"AR-B88"
    		"AR-BRELM"
    		"AR-BRSTD"
    		"AR-CONC"
    		"AR-HBONE"
    		"AR-PARQ1"
    		"AR-RROOF"
    		"AR-RSHKE"
    		"AR-SAND"
    		"BOX"
    		"BRASS"
    		"BRICK"
    		"BRSTONE"
    		"CLAY"
    		"CORK"
    		"CROSS"
    		"DASH"
    		"DOLMIT"
    		"DOTS"
    		"EARTH"
    		"ESCHER"
    		"FLEX"
    		"GRASS"
    		"GRATE"
    		"GRAVEL"
    		"HEX"
    		"HONEY"
    		"HOUND"
    		"INSUL"
    		"ACAD_ISO02W100"
    		"ACAD_ISO03W100"
    		"ACAD_ISO04W100"
    		"ACAD_ISO05W100"
    		"ACAD_ISO06W100"
    		"ACAD_ISO07W100"
    		"ACAD_ISO08W100"
    		"ACAD_ISO09W100"
    		"ACAD_ISO10W100"
    		"ACAD_ISO11W100"
    		"ACAD_ISO12W100"
    		"ACAD_ISO13W100"
    		"ACAD_ISO14W100"
    		"ACAD_ISO15W100"
    		"LINE"
    		"MUDST"
    		"NET"
    		"NET3"
    		"PLAST"
    		"PLASTI"
    		"SACNCR"
    		"SQUARE"
    		"STARS"
    		"STEEL"
    		"SWAMP"
    		"TRANS"
    		"TRIANG"
    		"ZIGZAG"
    ))
      
      (setq dcl_id (load_dialog "MHATCH.DCL"))
      (if (not (new_dialog "Hatch" dcl_id))(exit))
      (if (not *data_MHATCH*)(setq *data_MHATCH* "0"))
      (if (not *data_Scale*)(setq *data_Scale* 1.0))
      (if (not *data_ROT*)(setq *data_ROT* 0))
      
      (setq data_MHATCH *data_MHATCH*
    	data_Scale *data_Scale*
    	data_ROT *data_ROT*)
      
      (start_list "MHATCH")
      (mapcar 'add_list MHATCH)
      (end_list)
      (set_tile "MHATCH" data_MHATCH)
    
      (set_tile "Scale" (rtos data_Scale 2 4))
    
      (set_tile "ROT" (rtos data_ROT 2 4))
      
      (action_tile "accept"
        (strcat
          "(get:dcl_MHATCH)""(done_dialog 1))"))
      (action_tile "cancel" "(done_dialog 0)")
      (setq ans (start_dialog))
      (unload_dialog dcl_id)
      (if (= ans 1)
        (progn
          (setq old_osnap1 (getvar "osmode")
                cmdecho (getvar "cmdecho")
          )
          (setvar "osmode" 0)
          (setvar "cmdecho" 0)
        (setq HatchType (nth(atoi *data_MHATCH*)MHATCH))
          (setq Scale (rtos *data_Scale* 2 4))
          (setq ROT (rtos *data_ROT* 2 4))
    
      (setq pnt1 (getpoint "\nSelect upper left hand corner for placement of rectangle: "))
      (setq pnt2 (getcorner pnt1 "\nSelect lower right hand corner for placement of rectangle: "))
      (command "rectangle" pnt1 pnt2)
      (setq ent1 (entlast))
      (command "-hatch" "S" ent1"" "p" HatchType Scale ROT "")
           (setvar "osmode" old_osnap1)
          (setvar "cmdecho" cmdecho)
    (princ)
    );; end of prgn
    );; end of if
    );; end of defun
    
    (defun get:dcl_MHATCH ()
       (setq data_MHATCH (get_tile "MHATCH")
    	 data_Scale (atof(get_tile "Scale"))
    	 data_ROT (atof(get_tile "ROT"))
    	 *data_MHATCH* data_MHATCH
    	 *data_Scale* data_Scale
    	 *data_ROT* data_ROT
       )
    )
    
    (prompt "\n*********** Type \"MHATCH\" to Start Program ***********")
    also attached is the dcl for this program make sure the dcl is saved as MHATCH.dcl in your support directory for autocad.
    Attached Files Attached Files

  9. #9
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    very cool routine, but how do I set it to assoc? or move insertion point so it picks mid point?

  10. #10
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331
    Login to Give a bone
    0

    Default Re: Drawing hatched rectangle

    nevermind, I changed to hatch a closed pline and it is associative

    Code:
    (defun c:plh (/ ent1)
      (command "pline" )
      (while (= 1 (logand (getvar "CMDACTIVE") 1 )) (command PAUSE ) )
      (setq ent1 (entlast))
      (command "-hatch" "P" "dots" 25 "0" "S" ent1"" "")
    )

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 2011-04-25, 07:55 PM
  2. Replies: 3
    Last Post: 2009-04-15, 07:30 PM
  3. Drawing Customised Rectangle
    By david.brissenden in forum VBA/COM Interop
    Replies: 3
    Last Post: 2008-08-18, 10:13 AM
  4. Hatched symbols
    By schrodingerscat in forum Revit MEP - Families
    Replies: 4
    Last Post: 2008-06-23, 11:18 PM
  5. rotate when drawing a rectangle
    By GuyR in forum Revit Architecture - Wish List
    Replies: 6
    Last Post: 2005-08-16, 06:33 AM

Posting Permissions

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