Jump to content

Recommended Posts

Posted

I've been trying to implement an error handler into the attached lisp, but i'm just too stupid to get it to work. I'm trying to get the lisp to reset the coordinate system (UCS) and Osnap setting to where they were before executing the program. If anyone could help me out with this, i would highly appreciate it. 

GEO9_RTOS_2dec.LSP

Posted
(setq turesszog 1. textmeret 0.75)
(setvar "cmdecho" 0)
(command "layer" "ma" "geod_sajat" "c" "yellow" "" "u" "geod_sajat" "")
(command "layer" "ma" "geodszov_sajat" "c" "magenta" "" "u" "geodszov_sajat" "")
(if (not (tblsearch "ltype" "DASHDOT"))
   (command "linetype" "l" "DASHDOT" "DASHDOT.lin" "")
);if
(if (not (tblsearch "ltype" "center2"))
   (command "linetype" "l" "center2" "CENTER2.lin" "")
);if

(vl-load-com)

(defun c:g ( / *error* sv_lst sv_vals );;put the rest of your local variables here
(defun *error* (msg)
   (command-s "_ucs" "_R" "Cuser");restore entry ucs	;restore the entry ucs
   (command-s "_ucs" "_D" "lof");delete old ucs
   (mapcar 'setvar sv_lst sv_vals)                      ;restore sysvars to entry state
   (command-s "undo" "end")
)
  (setq sv_lst (list 'cmdecho 'osmode 'clayer 'celtype);; list of system variables to save (entry state)
        sv_vals (mapcar 'getvar sv_lst)                ;; get the values of the above sysvars and store in a list
  )
  
  (mapcar 'setvar sv_lst '(0 0)                        ;;sets cmdecho & osmode to 0 (zero)
  
  (command "_UCS" "_S" "Cuser");save the current ucs
  
   (if (tblsearch "ucs" "lof") (command "ucs" "d" "lof"))
   (graphscr)
   (setq xlist nil ylist nil marminusz 0)
   
   ;(setvar "cmdecho" 0)  ;;this isn't needed here as it is set above
   
   ............
   ............
   ............
 
  (command "_ucs" "_R" "Cuser");restore entry ucs
  (command "_ucs" "_D" "lof");delete old ucs
  (mapcar 'setvar sv_lst sv_vals)				;;restore sysvars to entry state
  (command "undo" "end")
  (princ)
);defun

   

 

The error routine should be inside the main routine and it should be listed in the local variables. Don't use command calls (command....) inside an error routine it will error from Autocad 2015. Use command-s instead. You will also need to reset at the end of the main routine. You can use command calls here.

 

Posted

Thank you for taking the time. The program won't load after i applied these changes. I should have also mentioned this program was written 20 some years ago by someone

Posted (edited)
27 minutes ago, rombi said:

Thank you for taking the time. The program won't load after i applied these changes. I should have also mentioned this program was written 20 some years ago by someone

 

Any Error messages? Are you on Windows?

Edited by dlanorh

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...