Sie sind auf Seite 1von 2

(defun C:hte (/ *error*)

(defun *error* (msg)


(cond
((or (not msg)
(member msg
'("console break"
"function cancelled"
"quit / exit abort"
)
)
)
)
((princ (strcat "\nError: " msg)))
)
(cond (osm (setvar "osmode" osm)))
(cond (clyr (setvar "clayer" clyr)))
(cond (ccol (setvar "cecolor" ccol)))
(cond (cpat (setvar "hpname" cpat)))
(cond (hpas (setvar "hpassoc" hpas)))
(cond (hang (setvar "hpang" hang)))
(princ)
)
;; local function, return list of points, specified on screen
(defun defpoints ()
(setq lst nil)
(setq loop T)
(setq pt (getpoint "\nDigitize a first point :")
lst (cons pt lst)
)
(while
(setq pt
(getpoint "\nPick a next point or press Enter to end loop :"
pt
)
)
(if (null pt)
(setq loop nil)
)
(setq lst (cons pt lst))
)
(reverse lst)
)

;; local function, to create layer


(defun layer_set (lyr col ltp)
(setvar "cmdecho" 0)
(if (tblsearch "layer" lyr)
(command "._-layer" "t" lyr "u" lyr "on" lyr "s" lyr "")
(command "._-layer" "m" lyr "c" col lyr "lt" ltp lyr "")
)
)

;; main part

(setvar "cmdecho" 0) ; disable command line echo


(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)

Das könnte Ihnen auch gefallen