"\nBriefly describe this hatch pattern: " ) ) ( setq FileName ( getfiled "Hatch Pattern File" "I:\\Acad\\Hatch\\" "pat" 1 ) ) ) ( progn ( if ( = HatchDescr "" ) ( setq HatchDescr "Custom hatch pattern" ) ) ( setq HatchName ( vl-filename-base FileName )įileLines ( cons ( strcat "*" HatchName "," HatchDescr ) ( reverse FileLines ) ) ) ( princ "\n=" ) ( princ ( strcat "\nPlease wait while the hatch file is created.\n" ) ) ( ListToFile FileLines FileName nil nil ) ( command "delay" 1500 ) delay required so file can be created and found (silly, but req.) ( if ( findfile FileName ) ( progn ( setvar "HPNAME" HatchName ) ( princ ( strcat "\nHatch pattern '" * * *" ) ) ) ) (( princ ( strcat "\n * * * Invalid entity " EntType " omitted." ) ) ) ) ) ( setvar "DIMZIN" DimZin ) ( if ( and ( strcat ( angtos AngTo 0 6 ) "," ( rtos ( car pt1 ) 2 8 ) "," ( rtos ( cadr pt1 ) 2 8 ) "," ( rtos DeltaX 2 8 ) "," ( rtos DeltaY 2 8 ) "," ( rtos Dist 2 8 ) "," ( rtos Gap 2 8 ) ) ) ( princ ( strcat "\n" FileLine )) ( setq FileLines ( cons FileLine FileLines )) ) ( princ ( strcat "\n * * * Line with invalid angle " ( angtos AngTo 0 6 ) ( chr 186 ) " omitted. ) ) ) ) ) ) ) ) ( if ( = Factor 1 ) ( setq Gap ( - Dist ( abs ( * Factor ( / 1 DeltaY )))) ( startapp "notepad" FileName ) ) ) ) ( FindFile FileName ) ) * END NESTED FUNCTIONS ( princ ( strcat "\n." "\n 0,1 - 1,1" "\n | | " "\n | Lines and | " "\n | points must | " "\n | be snapped | " "\n | to nearest | " "\n | 0.01 | " "\n | | " "\n 0,0 - 1,0" "\n." "\nNote: Lines must be drawn within 0,0 to 1,1 and lie on a 0.01 grid." ) ) ( textscr ) ( getstring "\nHit to continue." ) ( princ "\nSelect 1x1 pattern of lines and/or points for new hatch pattern." ) ( while ( not ( setq SelSet ( ssget ( list ( cons 0 "LINE,POINT" ))))) ) ( setq ssNth 0ĭimZin ( getvar "DIMZIN" ) ) ( setvar "DIMZIN" 11 ) ( if ( > SelSetSize 0 ) ( princ "\nAnalyaing entities." ) ) ( while ( Factor 1 ) ( Ang ( / pi 2 )) ( - _EH ) ( write-line TextItem File ) ) ( setq File ( close File )) ( if DoOpenWithNotepad "a" "w" ) ) ) ( progn ( foreach TextItem TextList
HOW TO ADD HATCH PATTERNS TO AUTOCAD 2015 CODE
) * BEGIN NESTED FUNCTIONS ( defun round (num ) ( if ( >= ( - num ( fix num )) 0.5 ) ( fix ( 1+ num )) ( fix num ) ) ) ( defun dxf (code EnameOrElist / VarType ) ( setq VarType ( type EnameOrElist )) ( if ( = VarType ( read "ENAME" )) ( cdr ( assoc code ( entget EnameOrElist ))) ( cdr ( assoc code EnameOrElist )) ) ) ( defun ListToFile (TextList FileName DoOpenWithNotepad ( defun C:DrawHatch ( / ) ( command "undo" "be" ) ( setq os ( getvar "OSMODE" )) ( setvar "OSMODE" 0 ) ( command "UCS" "w" ) ( command "PLINE" "0,0" "0,1" "1,1" "1,0" "c" ) ( command "zoom" "c" "0.5,0.5" 1.1 ) ( setvar "OSMODE" os ) ( setvar "SNAPMODE" 1 ) ( setvar "SNAPUNIT" ( list 0.01 0.01 )) ( command "undo" "e" ) ( alert "Draw pattern within 1x1 box using LINE or POINT entities only." ) ( princ ) ) ( defun C:SaveHatch ( / round dxf ListToFile does include a 'VL' function - should work on Acad2000 on up. CADALYST 10/: HatchMaker.lsp Hatch Maker (c) 2005 Larry Schiele * = B E G I N C O D E N O W = * HatchMaker.lsp written by Lanny Schiele at TMI Systems Design Corporation * * Tested on AutoCAD 2002 & 2006. pat file created by the SAVEHATCH command Picture below: Applying the newly created hatch Picture below: DRAWHATCH & SAVEHATCH in action pat file (hatch pattern) allows you to copy the contents and save it in your support file or even add it to your acad.pat file where all of your default patterns are stored. This will turn the polyline segments into line segments.ġ) DRAWHATCH creates a 1X1 square in which you draw your custom hatch patternĢ) SAVEHATCH lets you name your hatch Pattern and save it as a. Or use the “SEGS” LISP routine to convert the curved objects to polylines and then explode the polyline.
The only drawback that I have come across is that it will only accept line and point entities… This can be over come by drawing your curved objects and then using other LISP routines to convert arcs and circles to line entities.
HOW TO ADD HATCH PATTERNS TO AUTOCAD 2015 HOW TO
If you have ever wondered how to make a custom hatch pattern and then looked at the coding that is required, you will really appreciate this routine. This Routine has been featured on Cadalyst’s website and is very handy.