Login

View Full Version : hatch dialog box



opeenna
2008-03-01, 01:02 PM
Hi,
I am trying to make a custom hatch command that switches to a particular layer i want the hatch to be drawn on, then displays the hatch dialog, lets me make the hatch, and after it is complete it reactivates the layer that was current before the command was invoked.
but even though i start the hatch command without the dash (command "hatch") it activates the command line version of the hatch command. what am i doing wrong?

here is the full code:



(defun c:chatch ()
(setq cmdsave (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq lyrsave (getvar "clayer"))

(setq currentfloorhatchlayer (strcat currentfloor "_DB10-hatch"))
(command "-layer" "t" currentfloorhatchlayer "")
(command "-layer" "s" currentfloorhatchlayer "")
(setvar "cmdecho" 1)
(command "hatch")


;restore original current layer
(command "-layer" "s" lyrsave "")

(setvar "cmdecho" cmdsave)
(princ)
)

opeenna
2008-03-01, 03:26 PM
ok nevermind i found the solution: (initdia) shows the dialog box for the next command, and a while loop keeps paused for user input while cmdactive is not 0 (meaning for as long as there is a command active).



(defun c:chatch ()
(setq cmdsave (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq lyrsave (getvar "clayer"))

(setq currentfloorhatchlayer (strcat currentfloor "_DB10-hatch"))
(command "-layer" "t" currentfloorhatchlayer "")
(command "-layer" "s" currentfloorhatchlayer "")
(setvar "cmdecho" 1)
(initdia)
(command "_.bhatch")
(while (/= 0 (getvar "CMDACTIVE"))
(command pause)
)


;restore original current layer
(command "-layer" "s" lyrsave "")

(setvar "cmdecho" cmdsave)
(princ)
)

d_m_hopper
2008-03-02, 04:53 AM
not sure if this will help you or not, I use this routine for creating a hatch drawn with a pline

I am new to writing code and most likely took the long road to achieving this result but it works for me....still taking baby steps :)


;created by Dennis Hopper Sept 2007
;revision 3-08
;use to make duct work above ceiling
;draw pline
;pline set to GE layer standard
;hatch added **pline must be closed**
;user selects hatch to change its properties to GE layer standard<--option removed
;^^^selected in routine


(defun c:acd ()
(initget "English Metric") ;ASK USER FOR INPUT
(setq Inp (getkword "\nWhat are the units of measure? [English/Metric] <English>: "))
(or Inp (setq Inp "English") ;DEFAULT ENGLISH UNITS
)
(vl-load-com);ADDED FOR 2008


(command "pline" )
(while (= 1 (logand (getvar "CMDACTIVE") 1 )) (command PAUSE ) )
(setq ent1 (entlast))

(if (= Inp "Metric")
(command "-hatch" "P" "ansi31" 762 "0" "S" ent1"" ""
) ;DO THIS IF METRIC
(command "-hatch" "P" "ansi31" 30 "0" "S" ent1"" ""
) ;ELSE DO THIS IF ENGLISH
)


(while (= 1 (logand (getvar "CMDACTIVE") 1 )) (command PAUSE ) )
(command "_.chprop" ent1"" "la" "epdjc" "c" "green" "lt" "dashed" "")

(while (= 1 (logand (getvar "CMDACTIVE") 1 )) (command PAUSE ) )
(setq hatch (entlast))

(command "_.chprop" hatch"" "la" "epdjc" "c" "red" "")

)