Hi,
Let's start with some obvious errors you do in your code, although I don't
know exactly what your problem is:
1) In your (initerr) routine you assign to the error handler a variable
which is nil (setq *error* trap), because trap is not initialized, at least
not in the attached code. In fact, all that (initerr) stuff is useless,
since you don't have an ending routine to restore all these altered
variables ("clayer" "osmode" "dimsah" "dimse2" "dimblk2"|) to their initial
values and to restore the error handler to the original value. i.e. (setq
*error* temperr). It is good practice to not leave traces and changes in the
system when you run a LISP function
2) The variable ds2 is useless, you don't do anything with it and so is ds1
3) The logic, elegant and professional approach to modifying variables is to
use (setvar ...) instead of (command ...)
4) You don't need dash prefixes in front of command names. This is required
only in macros, the prompt version of any command won't pop the dialog. In
fact, in order to have the dialog for a command, you have to use (initdia)
preceding the command call.
5) Is good practice to use the internationalized syntax for your commands
(with an underscore prefix) and command's options since you never now where
your routine might end up and also the dot, in order to make sure you use
the original command and not some redefined command by someone else's
routine
As for your error, this seems to be a hard one and certainly not generated
by a LISP function. As a general rule, when you have problems, you can
always put some traces between your code line and see which one is the last
one that was printed. This will help you to narrow and locate the source of
your problem.
(defun myfunction ()
(setvar ...)
(princ "1")
(setq ...)
(princ "2")
(command ...)
(princ "3")
(setvar ...)
(princ "n")
)
Or you can do what Martti Halminen suggested on another topic a little bit
earlier:
In VLIDE, choose:
Debug>Break On Error, and when you get the error, try either
Debug>Last Break Source or View>Trace Stack.
HTH
--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.
a écrit dans le message de news:
6246441@discussion.autodesk.com...
Hi All,
I have created a Lisp to seperate different drawings all drawn in model
space to seperate drawing files. However im getting 2 Error messages that im
not sure about;
Pick a block to set dimscale on:
INSERTION POINT
Select objects: Specify opposite corner: 113 found
Select objects:
; error: Exception occurred: 0xC0000005 (Access Violation)
Enter new drawing number123-F0-9999
; warning: unwind skipped on hard error
And the end result is nothing gets saved... I think its in the structure of
the value that is held in "new_dwg". Is there a simple way of changing the
way the slashes are returned for folder structures?
Code attached below.
Thanks,
Dooners.