hatch lisp

Discussion in 'AutoCAD' started by spencer1971, May 5, 2004.

  1. spencer1971

    spencer1971 Guest

    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 "" "")
    )
    )
    )
     
    spencer1971, May 5, 2004
    #1
    1. Advertisements

  2. spencer1971

    zeha Guest

    (command "hatch" "ar-sand" (* 0.1 scale) 0 pause)
     
    zeha, May 5, 2004
    #2
    1. Advertisements

  3. spencer1971

    spencer1971 Guest

    many thanks, That works perfectly.

    sorry if it was a bit obvious.

    Spencer
     
    spencer1971, May 5, 2004
    #3
  4. spencer1971

    CAB2k Guest

    Remove the quotes for a variable.

    Code:
    Wrong
    (command "hatch" "ar-sand" "hpscale" 0 "")
    
    Correct
    (command "hatch" "ar-sand" hpscale 0 "")
     
    CAB2k, May 5, 2004
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. MarcelGoulet

    Hatch fonction in lisp

    MarcelGoulet, Feb 2, 2004, in forum: AutoCAD
    Replies:
    2
    Views:
    371
    MarcelGoulet
    Feb 2, 2004
  2. Roderic Potter
    Replies:
    0
    Views:
    312
    Roderic Potter
    Feb 4, 2004
  3. Mike Weaver

    Lisp to turn on/off hatch patterns...

    Mike Weaver, Mar 2, 2004, in forum: AutoCAD
    Replies:
    9
    Views:
    457
    R. Robert Bell
    Mar 2, 2004
  4. C Witt

    update hatch scales with lisp??

    C Witt, May 19, 2004, in forum: AutoCAD
    Replies:
    15
    Views:
    1,141
    Kent Cooper, AIA
    May 20, 2004
  5. spencer1971

    Hatch lisp crashes?

    spencer1971, Jul 15, 2004, in forum: AutoCAD
    Replies:
    1
    Views:
    268
    spencer1971
    Jul 15, 2004
  6. Jack G
    Replies:
    2
    Views:
    349
    Jack G
    Sep 12, 2004
  7. ikaage

    quick hatch lisp

    ikaage, Oct 14, 2004, in forum: AutoCAD
    Replies:
    8
    Views:
    335
    CJ Follmer
    Oct 15, 2004
  8. JamieLandmark
    Replies:
    22
    Views:
    1,006
    Walt Engle
    Mar 31, 2005
Loading...