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.
|
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.
This will draw a rectangle to your specified width and height and also hatch according to th ealready set hatch pattern.
In order to change the hatch pattern type then you will need to addCode:(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 place of the current hatch command in the program. Of course you will need to specify the pattern, scale, and angle.Code:(command "-hatch" "S" ent1"" "P" "your hatch pattern name here" "your scale" "your angle for hatch pattern" "")
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"" "") )
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.Originally Posted by mathias2014
Does this help?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) )
Lions 60 had some nice ones too.
Hey Lions60, I think you forgot your command prompt function (unless this is run within another program, I may be wrong).Originally Posted by Lions60
"(defun c:recthatch ()"
I liked your version, much cleaner, I'll be using this for stuff for sure.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 "") )
Thanks.
You are correct i did forget. Feel free to use it however you need.
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.
Give this a try.
also attached is the dcl for this program make sure the dcl is saved as MHATCH.dcl in your support directory for autocad.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 ***********")
very cool routine, but how do I set it to assoc? or move insertion point so it picks mid point?
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"" "") )