Jump to content

Block Import Lisp


woodman78

Recommended Posts

I am trying to create a lisp to import a series of blocks thru a dialog box. I keep getting errors when I try to run it. Could someone have a look?

 

Thanks.

 

I include some of the blocks to help.

 

 
mhblock : dialog {                                   //*dialog name
        label = "Drainage - Manholes";           //*give it a label
: row {                                    //*define row
             : paragraph {                          //*define paragraph
              : text_part {                        //*define more text
                label = "Existing Storm Sewer";           //*some more text
              }                                    //*end text
              : text_part {                        //*define more text
                label = " ";           //*some more text
              }                                    //*end text
            }                                      //*end paragraph
        }                                          //*end row
        : row {                                    //*define row
          : boxed_column {                         //*define boxex_column
            label = "Choose a Manhole Type:";               //*give it a label 
            : popup_list {                         //*define popup_list
              key = "S1";                          //*give it a name
              label = "Size";                      //*give it a label 
              edit_width=25;                        //*edit_width
              alignment = right;                   //*alignment
            }                                      //*end popup_list
            : spacer {                             //*define spacer
              height = 0;                          //*height
            }                                      //*end spacer
          }                                        //*end boxed_column
        }                                          //*end row
        : row {                                    //*define row
          : column {                               //*define column
            ok_cancel ;                            //*predifined OK/Cancel
            : paragraph {                          //*define paragraph
               : text_part {                        //*define more text
                label = "CCC NNRDO     v1.0.24.07.2009";           //*some more text
              }                                    //*end text
            }                                      //*end paragraph
          }                                        //*end column
        }                                          //*end row
      }                                            //*end dialog

 

 
;//////////////////////////////////////////////////////////////////////////
;
; Start-Up Function
;
(defun C:mhblock ()
 (POPUP_MF)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Main Function
;
(defun POPUP_MF (/ SIZE$ SIZE SUCE  SUOM  SUSM SUAB SUAD MIDPT PLEN
                  PT01  PT02 a b Color INPT)
 (setq SUCE (getvar "cmdecho"))
 (setq SUOM (getvar "orthomode"))
 (setq SUSM (getvar "osmode"))
 (setq SUAB (getvar "angbase"))
 (setq SUAD (getvar "angdir"))
 (setq SUCL (getvar "clayer"))
 (setq SUCR (getvar "cecolor"))
 (setq temperr *error*)
 (setq *error* ETRAP)
 (setq S1_list
  '("Existing Storm Sewer Manhole" "Existing Storm Sewer Manhole to be Replaced"
    "Existing Storm Sewer Manhole to be Removed" "Existing Foul Sewer Manhole"
     "Existing Foul Sewer Manhole to be Removed"  "Proposed Storm Sewer"
     "Proposed Foul Sewer" 
   )
 )
 (setq dcl_id (load_dialog "mhblock.dcl"))
 (if
   (not
     (new_dialog "mhblock" dcl_id)
   )
   (progn
     (ALERT "Can not find your dcl file")
     (exit)
   )
 )
 (start_list "S1")
 (mapcar 'add_list S1_list)
 (end_list)
 (if SIZE:DEF
   (set_tile "S1" (itoa SIZE:DEF))
 )
 (action_tile "cancel"
  "(done_dialog)(setq userclick nil)"
 )
 (action_tile "accept"
   (strcat
    "(progn
     (setq S:IZE (atoi (get_tile \"S1\")) SIZE:DEF S:IZE)"
    "(done_dialog)(setq userclick T))"
   )
 )
 (start_dialog)
 (unload_dialog dcl_id)
 (if userclick
   (VARIABLE)
 )
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Variable Function
;
(defun VARIABLE ()
 (progn 
   (setq SIZE$ (fix S:IZE))
   (setq SIZE$ (nth S:IZE S1_list))
   (cond
     ((= SIZE$ "Existing Storm Sewer Manhole")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Existing Storm Sewer Manhole to be Replaced")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_To_Be_Replaced_Plant")(setq Color "100,55,35")))
     ((= SIZE$ "Existing Storm Sewer Manhole to be Removed")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_To_Be_Removed_Plant")(setq Color "31,9,235")))
     ((= SIZE$ "Existing Foul Sewer Manhole")(setq SIZE$ "EXISTING_Drainage_Foul_Sewer_Plant")(setq Color "31,127,0")))
     ((= SIZE$ "Existing Foul Sewer Manhole to be Removed")(setq SIZE$  "EXISTING_Drainage_Foul_Sewer_To_Be_Removed_Plant")(setq Color "31,127,0")))
     ((= SIZE$ "Proposed Storm Sewer")(setq SIZE$  "PROPOSED_Drainage_Storm_Sewer_Plant")(setq Color "31,127,0")))
     ((= SIZE$ "Proposed Foul Sewer")(setq SIZE$  "PROPOSED_Drainage_Foul_Sewer_Plant")(setq Color "31,127,0")))
   )
 )
 (setq SIZE SIZE$) 
 (OUTPUT)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Output Function
;
(defun OUTPUT ()
       b (strcat "CCC_SERVICES_"SIZE)
 )
 (command "_.-layer" "_N" b "_M" b "_L" a b "_C" "_T" Color b "_LW" "0.3" b "" )
 (command "_-color"  "bylayer")
 (command "._-linetype"  "s"  "bylayer" "")
 (setq INPT (getpoint "\Get insertion point:"))
 (command "_.insert" SIZE INPT "1" "1" "0")
 (setvar "angbase" 0.0000)
 (setvar "angdir"  0)
 (setvar "orthomode" 0)
 (setvar "osmode"    16383)
 (setq PT01 (getpoint "\nEnter the line start point:"))
 (while
   (/= nil
     (setq PT02 (getpoint pt01 "\nEnter the line end point:"))
   )
   (setvar "osmode" 0)
   ;(command "_.pline" PT01 PT02 "")
   ;(setq PT01 PT02)
   (setvar "osmode" 16383)
 )
 (setq *error* temperr)
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "clayer"    SUCL)
 (setvar "cecolor"    SUCR)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Error Trap Function
;
(defun ETRAP (errmsg)
 (command nil nil nil)
 (if
   (not
     (member errmsg '("console break" "Function Cancelled"))
   )
   (princ (strcat "\nError:" errmsg))
 )
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (princ "\nError, Restoring Variables.")
 (terpri)
 (setq *error* temperr)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////

Existing_Drainage_Foul_Sewer_Plant.dwg

Existing_Drainage_Storm_Sewer_Plant.dwg

Link to comment
Share on other sites

Hey woodman78

 

You had addition right parenthesis in all your variable function conditionals.

The dialog now shows up.

 

Also I had to complete this line for you.

(setq b (strcat "CCC_SERVICES_"SIZE))

 

Your layer command is looking for variable a which I do not know and you did not supply linetypes as well.

I am not sure in the first place if you want to set linetypes.

Please try to finish it off with the missing info then repost if you still have a problem.

Try not to get too far ahead of yourself. Spend some time in each section of code to verify what you want to do.

 

;//////////////////////////////////////////////////////////////////////////
;
; Start-Up Function
;
(defun C:mhblock ()
 (POPUP_MF)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Main Function
;
(defun POPUP_MF (/ SIZE$ SIZE SUCE  SUOM  SUSM SUAB SUAD MIDPT PLEN
                  PT01  PT02 a b Color INPT)
 (setq SUCE (getvar "cmdecho"))
 (setq SUOM (getvar "orthomode"))
 (setq SUSM (getvar "osmode"))
 (setq SUAB (getvar "angbase"))
 (setq SUAD (getvar "angdir"))
 (setq SUCL (getvar "clayer"))
 (setq SUCR (getvar "cecolor"))
 (setq temperr *error*)
 (setq *error* ETRAP)
 (setq S1_list
  '("Existing Storm Sewer Manhole" "Existing Storm Sewer Manhole to be Replaced"
    "Existing Storm Sewer Manhole to be Removed" "Existing Foul Sewer Manhole"
     "Existing Foul Sewer Manhole to be Removed"  "Proposed Storm Sewer"
     "Proposed Foul Sewer" 
   )
 )
 (setq dcl_id (load_dialog "mhblock.dcl"))
 (if
   (not
     (new_dialog "mhblock" dcl_id)
   )
   (progn
     (ALERT "Can not find your dcl file")
     (exit)
   )
 )
 (start_list "S1")
 (mapcar 'add_list S1_list)
 (end_list)
 (if SIZE:DEF
   (set_tile "S1" (itoa SIZE:DEF))
 )
 (action_tile "cancel"
  "(done_dialog)(setq userclick nil)"
 )
 (action_tile "accept"
   (strcat
    "(progn
     (setq S:IZE (atoi (get_tile \"S1\")) SIZE:DEF S:IZE)"
    "(done_dialog)(setq userclick T))"
   )
 )
 (start_dialog)
 (unload_dialog dcl_id)
 (if userclick
   (VARIABLE)
 )
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Variable Function
;
(defun VARIABLE ()
 (progn 
   (setq SIZE$ (fix S:IZE))
   (setq SIZE$ (nth S:IZE S1_list))
   (cond
     ((= SIZE$ "Existing Storm Sewer Manhole")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Existing Storm Sewer Manhole to be Replaced")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_To_Be_Replaced_Plant")(setq Color "100,55,35"))
     ((= SIZE$ "Existing Storm Sewer Manhole to be Removed")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_To_Be_Removed_Plant")(setq Color "31,9,235"))
     ((= SIZE$ "Existing Foul Sewer Manhole")(setq SIZE$ "EXISTING_Drainage_Foul_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Existing Foul Sewer Manhole to be Removed")(setq SIZE$  "EXISTING_Drainage_Foul_Sewer_To_Be_Removed_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Proposed Storm Sewer")(setq SIZE$  "PROPOSED_Drainage_Storm_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Proposed Foul Sewer")(setq SIZE$  "PROPOSED_Drainage_Foul_Sewer_Plant")(setq Color "31,127,0"))
   )
 )
 (setq SIZE SIZE$) 
 (OUTPUT)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Output Function
;
(defun OUTPUT ()
       (setq b (strcat "CCC_SERVICES_"SIZE))
 (command "_.-layer" "_M" b "_L" a b "_C" "_T" Color b "_LW" "0.3" b "" )
 (command "_-color"  "bylayer")
 (command "._-linetype"  "s"  "bylayer" "")
 (setq INPT (getpoint "\Get insertion point:"))
 (command "_.insert" SIZE INPT "1" "1" "0")
 (setvar "angbase" 0.0000)
 (setvar "angdir"  0)
 (setvar "orthomode" 0)
 (setvar "osmode"    16383)
 (setq PT01 (getpoint "\nEnter the line start point:"))
 (while
   (/= nil
     (setq PT02 (getpoint pt01 "\nEnter the line end point:"))
   )
   (setvar "osmode" 0)
   (setvar "osmode" 16383)
 )
 (setq *error* temperr)
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "clayer"    SUCL)
 (setvar "cecolor"   SUCR)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Error Trap Function
;
(defun ETRAP (errmsg)
 (command nil nil nil)
 (if
   (not
     (member errmsg '("console break" "Function Cancelled"))
   )
   (princ (strcat "\nError:" errmsg))
 )
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (princ "\nError, Restoring Variables.")
 (terpri)
 (setq *error* temperr)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////

 

I also want to point out in you layer command you are using New & Make in the same command. This is not needed. Just use Make.

Link to comment
Share on other sites

Thanks for the pointers Buzzard. I got it working. It must have been tiredness that I didn't spot the get points for the line command.

 

 
;//////////////////////////////////////////////////////////////////////////
;
; Start-Up Function
;
(defun C:mhblock ()
 (POPUP_MF)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Main Function
;
(defun POPUP_MF (/ SIZE$ SIZE SUCE  SUOM  SUSM SUAB SUAD MIDPT PLEN
                  PT01  PT02 a b Color INPT)
 (setq SUCE (getvar "cmdecho"))
 (setq SUOM (getvar "orthomode"))
 (setq SUSM (getvar "osmode"))
 (setq SUAB (getvar "angbase"))
 (setq SUAD (getvar "angdir"))
 (setq SUCL (getvar "clayer"))
 (setq SUCR (getvar "cecolor"))
 (setq temperr *error*)
 (setq *error* ETRAP)
 (setq S1_list
  '("Existing Storm Sewer Manhole" "Existing Storm Sewer Manhole to be Replaced"
    "Existing Storm Sewer Manhole to be Removed" "Existing Foul Sewer Manhole"
     "Existing Foul Sewer Manhole to be Removed"  "Proposed Storm Sewer"
     "Proposed Foul Sewer" 
   )
 )
 (setq dcl_id (load_dialog "mhblock.dcl"))
 (if
   (not
     (new_dialog "mhblock" dcl_id)
   )
   (progn
     (ALERT "Can not find your dcl file")
     (exit)
   )
 )
 (start_list "S1")
 (mapcar 'add_list S1_list)
 (end_list)
 (if SIZE:DEF
   (set_tile "S1" (itoa SIZE:DEF))
 )
 (action_tile "cancel"
  "(done_dialog)(setq userclick nil)"
 )
 (action_tile "accept"
   (strcat
    "(progn
     (setq S:IZE (atoi (get_tile \"S1\")) SIZE:DEF S:IZE)"
    "(done_dialog)(setq userclick T))"
   )
 )
 (start_dialog)
 (unload_dialog dcl_id)
 (if userclick
   (VARIABLE)
 )
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Variable Function
;
(defun VARIABLE ()
 (progn 
   (setq SIZE$ (fix S:IZE))
   (setq SIZE$ (nth S:IZE S1_list))
   (cond
     ((= SIZE$ "Existing Storm Sewer Manhole")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Existing Storm Sewer Manhole to be Replaced")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_To_Be_Replaced_Plant")(setq Color "100,55,35"))
     ((= SIZE$ "Existing Storm Sewer Manhole to be Removed")(setq SIZE$ "EXISTING_Drainage_Storm_Sewer_To_Be_Removed_Plant")(setq Color "31,9,235"))
     ((= SIZE$ "Existing Foul Sewer Manhole")(setq SIZE$ "EXISTING_Drainage_Foul_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Existing Foul Sewer Manhole to be Removed")(setq SIZE$  "EXISTING_Drainage_Foul_Sewer_To_Be_Removed_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Proposed Storm Sewer")(setq SIZE$  "PROPOSED_Drainage_Storm_Sewer_Plant")(setq Color "31,127,0"))
     ((= SIZE$ "Proposed Foul Sewer")(setq SIZE$  "PROPOSED_Drainage_Foul_Sewer_Plant")(setq Color "31,127,0"))
   )
 )
 (setq SIZE SIZE$) 
 (OUTPUT)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Output Function
;
(defun OUTPUT ()
       (setq b (strcat "CCC_SERVICES_"SIZE))
 (command "_.-layer" "_M" b "_C" "_T" Color b "_LW" "0.3" b "" )
 (command "_-color"  "bylayer")
 (command "._-linetype"  "s"  "bylayer" "")
 (setq INPT (getpoint "\Get insertion point:"))
 (command "_.insert" SIZE INPT "1" "1" "0")
 (setvar "angbase" 0.0000)
 (setvar "angdir"  0)
 (setvar "orthomode" 0)
 (setvar "osmode"    16383)
   (setvar "osmode" 0)
   (setvar "osmode" 16383)
 )
 (setq *error* temperr)
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "clayer"    SUCL)
 (setvar "cecolor"   SUCR)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////
;
; Error Trap Function
;
(defun ETRAP (errmsg)
 (command nil nil nil)
 (if
   (not
     (member errmsg '("console break" "Function Cancelled"))
   )
   (princ (strcat "\nError:" errmsg))
 )
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (princ "\nError, Restoring Variables.")
 (terpri)
 (setq *error* temperr)
 (princ)
)
;
;//////////////////////////////////////////////////////////////////////////

Link to comment
Share on other sites

Ok,

 

But the extra brackets in the variable function did not help either.

Slow down my friend. You will get it done.

Keep coding.

 

The Buzzard

Link to comment
Share on other sites

  • 6 years later...

Hi all,

 

Happy new year to everyone!

 

The Buzzard helped me with this block import lisp back in 2009. When I run it it doesn't reset the variables on completion. Can anyone help?

What am I missing?

 

Thanks.

Link to comment
Share on other sites

I got one of them sorted but for some reason I am stuck on variable restoration with this lisp. Can anyone help please?

 

(defun c:drlegend (/ *error* DCHANDLE INPT OV PT RTN S1_LIST VL SUCE SUCL SUOM  SUSM SUAB SUAD)

 ;(setq SUCE (getvar "cmdecho"))
 ;(setq SUOM (getvar "orthomode"))
 ;(setq SUSM (getvar "osmode"))
 ;(setq SUAB (getvar "angbase"))
 ;(setq SUAD (getvar "angdir"))
 ;(setq SUCL (getvar "clayer"))
 ;(setq SUCR (getvar "cecolor"))

 (defun *error* (msg)
   (and dcHandle (unload_dialog dcHandle))
   ;(and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq S1_list
  '("*** Existing ***" 								;0
    "Existing Storm Sewer" 								;1
    "Existing Storm Sewer PVC" 							;2
    "Existing Storm Sewer to be removed"						;3
    "Existing Concrete Storm Sewer to be Replaced Type 1" 					;4
    "Existing Concrete Storm Sewer to be Replaced Type 2" 					;5
    "Existing Concrete Storm Sewer to be Replaced Type 3" 					;6
    "Existing Concrete Storm Sewer to be Replaced Type 4" 					;7
    "Existing PVC Storm Sewer to be Replaced with Concrete Type 1"				;8
    "Existing PVC Storm Sewer to be Replaced with Concrete Type 2"				;9
    "Existing PVC Storm Sewer to be Replaced with Concrete Type 3"				;10
    "Existing PVC Storm Sewer to be Replaced with Concrete Type 4"				;11
    "Existing Filter Drain" 								;12
    "Existing Foul Sewer"								;13
    "Existing Foul Sewer to be removed" 						;14
    "Existing Foul Sewer PVC"								;15
    "Existing Foul Sewer Pumped PVC"							;16
    "--------------------------------------"							;17
    "*** Proposed ***"     								;18
    "Proposed Concrete Storm Sewer Type 1"						;19
    "Proposed Concrete Storm Sewer Type 2"						;20
    "Proposed Concrete Storm Sewer Type 3"						;21
    "Proposed Concrete Storm Sewer Type 4"						;22
    "Proposed Thermoplastic Integrally Socketed Carrier Drain Type 1"				;23
    "Proposed Thermoplastic Integrally Socketed Carrier Drain Type 2"				;24
    "Proposed Thermoplastic Integrally Socketed Carrier Drain Type 3"				;25
    "Proposed Thermoplastic Integrally Socketed Carrier Drain Type 4"				;26
    "Proposed Half Perf Thermoplastic Filter Drain with Geotextile to Top Face Type A" 		;27
    "Proposed Half Perf Thermoplastic Filter Drain with Geotextile to Top Face Type B" 		;28
    "Proposed Half Perf Thermoplastic Filter Drain with Geotextile to Top Face Type C" 		;29
    "Proposed Half Perf Thermoplastic Filter Drain with Geotextile to Top Face Type D" 		;30
    "Proposed Half Perforated Thermoplastic Filter Drain Type 1" 				;31
    "Proposed Half Perforated Thermoplastic Filter Drain Type 2" 				;32
    "Proposed Half Perforated Thermoplastic Filter Drain Type 3" 				;33
    "Proposed Half Perforated Thermoplastic Filter Drain Type 4" 				;34
    "Proposed Ductile Iron Storm Sewer Type 1"						;35
    "Proposed Ductile Iron Storm Sewer Type 2"						;36
    "Proposed Ductile Iron Storm Sewer Type 3"						;37
    "Proposed Ductile Iron Storm Sewer Type 4"						;38
    "Proposed Foul Sewer Type 1"							;39
    "Proposed Foul Sewer Type 2"							;40
    "Proposed Foul Sewer Type 3"							;41
    "Proposed Foul Sewer Type 4"							;42
     )
 )

 (setq vl '("CMDECHO" "CLAYER" "OSMODE") ov (mapcar 'getvar vl))
 (setvar "attdia" 1)
 (cond (  (<= (setq dcHandle (load_dialog "drlegend.dcl")) 0)

          (princ "\n** Dialog file not Found **"))

       (  (not (new_dialog "drlegend" dcHandle))

          (princ "\n** Dialog Definition Not Found **"))

       (t

          (start_list "S1")
          (mapcar (function add_list) S1_list)
          (end_list)

          (set_tile "S1" (setq *def* (cond (*def*) ("1"))))

          (action_tile "S1"     "(setq *def* $value)")
        
          (action_tile "accept" "(cond ((member (atoi *def*) '(0 17 18)) (alert \"Invalid Item\"))
                                       ((done_dialog 1)))")
        
          (action_tile "cancel" "(done_dialog 0)")

          (setq rtn (start_dialog))

          (setq dcHandle (unload_dialog dcHandle))

          (if (= 1 rtn)
            (progn

              (or (tblsearch "LAYER" "CCC_SHEET_LAYOUT_Legend")
                  (entmake (list (cons 0 "LAYER")
                                 (cons 100 "AcDbSymbolTableRecord")
                                 (cons 100 "AcDbLayerTableRecord")
                                 (cons 2 "CCC_SHEET_LAYOUT_Legend")
                                 (cons 70 0)
                                 (cons 62 7)
                                 (cons 370 30))))

              (mapcar 'setvar vl '(0 "CCC_SHEET_LAYOUT_Legend" 0))

              (foreach block (mapcar
                               (function
                                 (lambda (x) (nth x S1_list)))

                               (read (strcat "(" *def* ")")))
                (setvar "osmode" 1)
(command "_.-INSERT" block "_s" "1" "_r" "0" "\\")))
	 	

   ;         (princ "\n*Cancel*")
)))
 ;(setvar "cmdecho"   SUCE)
 ;(setvar "orthomode" SUOM)
 ;(setvar "osmode"    SUSM)
 ;(setvar "angbase"   SUAB)
 ;(setvar "angdir"    SUAD)
 ;(setvar "clayer"    SUCL)
 ;(setvar "cecolor"    SUCR)
 ;(setvar "attdia" 0)
 (mapcar 'setvar vl ov)

(princ))

Link to comment
Share on other sites

Looks like you ran my chkbrk.lsp ;23 etc handy when looking for mismatched pairs.

 

Original variables its probably easier to make 2 library routines save original variables and restore variables, you can have a error trap so run restore if lisp falls over. (oldvariables) (redovariables)

Link to comment
Share on other sites

Make this part of your code defun that is saved in one of your autoload lsp say acaddoc.lsp etc then have the opposite putorgvars, you can have a error trap and it will run (putorgvars) as these are global defuns so will still exist even if your lisp fails. In your code at start (getorgvars) at end (putorgvars) even a manual fix we have FD for filedialog back on.

 

(defun getorgvars ()
(setq SUCE (getvar "cmdecho"))
(setq SUOM (getvar "orthomode"))
(setq SUSM (getvar "osmode"))
(setq SUAB (getvar "angbase"))
(setq SUAD (getvar "angdir"))
(setq SUCL (getvar "clayer"))
(setq SUCR (getvar "cecolor"))
)

 

(defun civ_units ()
(SETQ ANGBASEE (GETVAR "ANGBASE"))
(SETQ ANGDIRR (GETVAR "ANGDIR"))
(SETQ LUNITSS (GETVAR "LUNITS"))
(SETQ LUPRECC (GETVAR "LUPREC"))
(SETQ AUNITSS (GETVAR "AUNITS"))
(SETQ AUPRECC (GETVAR "AUPREC"))

(SETVAR "LUNITS" 2)
(SETVAR "ANGBASE" 0.0)
(SETVAR "ANGDIR" 0)
(SETVAR "LUPREC" 0)
(SETVAR "AUNITS" 0)
(SETVAR "AUPREC" 0)
)

(defun old_civ_units ()
(SETVAR "LUNITS" lunitss)
(SETVAR "ANGBASE" angbasee)
(SETVAR "ANGDIR" angdirr)
(SETVAR "LUPREC" luprecc)
(SETVAR "AUNITS" aunitss)
(SETVAR "AUPREC" auprecc)
)

Link to comment
Share on other sites

  • 2 weeks later...

I have all my default settings in a library defun its autoloaded so at the end of code just need 1 line (alansdefaults) add this also your "on error". Is the problem your getting errors or its just not resetting, rem out your on error to test I know the guys here press esc and it stops the lisp but most dont have a on error to clean it up properly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...