(setq osm (getvar "osmode")) ;store osnap settings (setq clyr (getvar "clayer")) ;store current layer (setq ccol (getvar "cecolor")) ; store current layer color (setq cpat (getvar "hpname")) ; store the hatch pattern (setq hpas (getvar "hpassoc")) ; store the hatch associativity (setq hang (getvar "hpang")) ; store the hatch angle (setvar "hpname" "ANSI31") ; set hatch pattern to ANSI31 (setvar "hpassoc" 1) ; set associativity
(layer_set "hatch" "8" "Bylayer") ;create or set layer "hatch" current,
;if this would not created before, then create them ; 8 - is color index of this layer, change to you suit (setvar "osmode" 0) (setvar "cecolor" "bylayer") (setq ang (getreal "\nSpecify the hatch angle: ")) (setvar "hpang" ang) ; specify a hatch angle
(setq pts (defpoints)) ; get points
(command "pline") (apply 'command pts) ; pass the point list in to command (command "c") ; add polyline (setq ip (getpoint "\nPick internal point: ")) (command "-hatch" ip "") ; add hatch (*error* nil) ; >>> this error trapping function means the following: ;;;(setvar "cmdecho" 1); restore cmecho variable ;;;(setvar "osmode" osm); restore osnap settings ;;;(setvar "clayer" clyr); restore current layer variable ;;;(setvar "cecolor" ccol); restore current layer color variable ;;;(setvar "hpname" cpat); restore default hatch pattern variable ;;;(setvar "hpassoc" hpas); restore default hatch associativity variable (princ) ) (princ "\nStart with HTE to draw hatch") (princ)