CAD Forums


Reply
 
spencer1971
Guest
Posts: n/a
 
      05-05-2004
I have a lisp file which works well at present using -bhatch for hatching by selecting a point inside boundary (c_sand, c_conc etc..) see below.
I am trying to add a section to ask for a "p" or "s" (yet to be written and either use the point hatch as shown or selet objects (hatch)

I have written the section s_sand (directly below c_sand) but the scaling is failing.

I presume the line:
(command "hatch" "ar-sand" "hpscale" 0 "")
is wrong, Im new to this so it may be something obvious.

Any suggestions please

full code:-

(defun MyError (strErr)
(setvar "OSMode" INOS)
(setvar "clayer" INLAYER)
(setvar "cecolor" incolor)
(princ)
)

;;;STANDARD HATCH PATTERNS
;;;
(defun layerht ()
(command "layer" "M" "HATCH" "")
(setq cur_hatccolor (getvar "cecolor")
cur_hatclayer "HATCH"
cur_hatcltype (getvar "celtype")
)
)
================================================== =========================================
================================================== ========================================
(defun c_inset ()
(setq inlayer (getvar "clayer"))
(setq incolor (getvar "cecolor"))
(setq inltype (getvar "celtype"))
(setq inort (getvar "orthomode"))
(setq inos (getvar "osmode"))
(setq inpkbx (getvar "pickbox"))
(setq inplwd (getvar "plinewid"))
)

(defun c_outset ()
(setvar "clayer" inlayer)
(setvar "cecolor" incolor)
(setvar "celtype" inltype)
(setvar "orthomode" inort)
(setvar "osmode" inos)
(setvar "pickbox" inpkbx)
(setvar "plinewid" inplwd)
)
================================================== =========================================
================================================== =========================================
;;;SAND
(defun c:c_sand ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpname" "ar-sand")
(setvar "hpang" 0)
(setvar "hpscale" (* 0.1 scale))
(princ "\nSelect area to hatch")
(command "-bhatch" pause "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

(defun c:s_sand ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpscale" (* 0.1 scale))
(command "hatch" "ar-sand" "hpscale" 0 "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

;;;DOTS
(defun c:c_dots ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpname" "dots")
(setvar "hpscale" (* 2 scale))
(setvar "hpang" 0)
(princ "\nSelect area to hatch")
(command "-bhatch" pause "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

;;;CONCRETE
(defun c:c_concrete ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpname" "ar-conc")
(setvar "hpscale" (* 0.1 scale))
(setvar "hpang" 0)
(princ "\nSelect area to hatch")
(command "-bhatch" pause "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

;;;ANSI37
(defun c:c_ansi37 ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpname" "ansi37")
(setvar "hpdouble" 1)
(setvar "hpspace" (* 2 scale))
(setvar "hpscale" (* 2 scale))
(setvar "hpang" 0)
(princ "\nSelect area to hatch")
(command "-bhatch" pause "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

;;;ANSI31
(defun c:c_ansi31 ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpname" "ansi31")
(setvar "hpdouble" 0)
(setvar "hpspace" (* 2 scale))
(setvar "hpscale" (* 2 scale))
(setvar "hpang" 0)
(princ "\nSelect area to hatch")
(command "-bhatch" pause "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

;;; BRICKWORK
(defun c:c_brkw ()
(setq *error* myerror)
(if scale (setq sc1 (rtos scale 2 2)) (setq sc1 ""))
(setq sc1 (getdist (strcat "\ninput scale <" sc1 ">: ")))
(if sc1 (setq scale sc1))
(setvar "cmdecho" 0)
(c_inset)
(layerht)
(setvar "hpname" "masonry")
(setvar "hpdouble" 0)
(setvar "hpspace" (* 18.75 scale))
(setvar "hpscale" (* 18.75 scale))
(setvar "hpang" 0)
(princ "\nSelect area to hatch")
(command "-bhatch" pause "")
(setvar "cmdecho" 1)
(c_outset)
(princ)
)

;;;Control Hatch Layer
;;;
(defun c:HO ()
(setq *error* myerror)
(setvar "cmdecho" 0)
(if(not h_on)(setq h_on 1))
(if(= h_on 1)
(progn
(setq askwhich (strcase (getstring "\nHatch layer, Freeze or Off:<O>?")))
(progn
(if(= askwhich "F")
(command "_.layer" "_f" "HATCh" "")
(command "_.layer" "_off" "HATCh" ""))
)
(setq h_on 0)
)
(progn
(command "_.layer" "_on" "HATCh" "")
(command "_.layer" "_t" "HATCh" "")
(setq h_on 1)
)
)
(setvar "cmdecho" 1)
(princ)
)
;;;
(defun c:MHATCH ()
(setq *error* myerror)
(c_inset)
(setvar "osmode" 0)
(command "layer" "m" cur_hatclayer "")
(setvar "cecolor" cur_hatccolor)
(setvar "celtype" cur_hatcltype)
(setq morehatc 1)
(while morehatc
(setq morehatc nil)
(initget 128 "None")
(setq hpt (getpoint "\nEnter/<Internal point>:"))
(if(/= hpt None)
(progn
(command "-bhatch" hpt "")
(setq morehatc 1)
)
)
(setq hpt nil)
)
(c_outset)
(princ)
)
;;;
(defun c:LO ()
(setvar "cmdecho" 0)
(if(not lb_on)(setq lb_on 1))
(if(= lb_on 1)
(progn
(setq askwhich (strcase (getstring "\nHatch layer, Freeze or Off:<O>?")))
(progn
(if(= askwhich "F")
(command "_.layer" "_f" "HATCH" "")
(command "_.layer" "_off" "HATCH_LB" ""))
)
(setq lb_on 0)
)
(progn
(command "_.layer" "_on" "S-HATC-LB" "")
(command "_.layer" "_t" "S-HATC-LB" "")
(setq lb_on 1)
)
)
(setvar "cmdecho" 1)
(princ)
)
;;;
(defun c:smh2 ()
(princ "\nWarning: Ensure That Areas to be Hatched are Closed Polylines and that ")
(princ "Hatch Entity Properties are set! ")
(setq ss (ssget)
sl (sslength ss)
index 0
)
(repeat sl
(setq en (ssname ss index))
(setq el (entget en))
(setq as (assoc 0 el))
(setq index (+ 1 index))
(if (= "LWPOLYLINE" (cdr as))
(command "-bhatch" "s" en "" "")
)
)
)
 
Reply With Quote
 
 
 
 
zeha
Guest
Posts: n/a
 
      05-05-2004
(command "hatch" "ar-sand" (* 0.1 scale) 0 pause)
 
Reply With Quote
 
 
 
 
spencer1971
Guest
Posts: n/a
 
      05-05-2004
many thanks, That works perfectly.

sorry if it was a bit obvious.

Spencer
 
Reply With Quote
 
CAB2k
Guest
Posts: n/a
 
      05-05-2004
Remove the quotes for a variable.

Code:
Wrong
(command "hatch" "ar-sand" "hpscale" 0 "")

Correct
(command "hatch" "ar-sand" hpscale 0 "")
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
quick hatch lisp ikaage AutoCAD Customization 8 10-15-2004 02:35 PM
Hatch lisp crashes? spencer1971 AutoCAD Customization 1 07-15-2004 10:21 AM
update hatch scales with lisp?? C Witt AutoCAD Customization 15 05-20-2004 12:37 PM
Lisp to turn on/off hatch patterns... Mike Weaver AutoCAD Customization 9 03-02-2004 09:54 PM
Hatch fonction in lisp MarcelGoulet AutoCAD Customization 2 02-02-2004 01:42 PM


All times are GMT. The time now is 04:19 PM.