Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error explanation and code help

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
398 Views, 4 Replies

Error explanation and code help

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.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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.
Message 3 of 5
Anonymous
in reply to: Anonymous

It appears that your problem is generated by the (dos_getdir ...) call,
although I don't see why, because I've pasted your code in my AutoCAD and it
works. There should be no problem with the slashes, both of the separators
(forward slashes and double backslashes) work for me and should work
everywhere, because both are LISP standards.

What AutoCAD are you using ? Did you load the proper doslib library ?

--
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.
Message 4 of 5
Anonymous
in reply to: Anonymous

Hi Some Buddy,

Firstly thanks very much for the guidence. I appreciate the comments. I had actually not copied all the code and missing was the initerr routine, my mistake, should have looked over the lsp posted a bit closer. The 2 useless variables are exactly that yes. They had been left over from another routine i had in setting additional for the titleblock. Now cleared out.

I have had trouble with using setvar for some reason in the past and found that command ... did not return this problem. I recall it was when you did a routine that gathered the "clayer" variable as soon as a drawing was opened. I will look into a bit further.

Explanation on using the princ for debugging and also on the use of dash prefixes very helpful.

So the problem. Nothing gets saved with the wblock command. It looks like it all works but when i go to the directory there is no file in there??? Am interested to see how you got this to work?

Cad2009. Usin Doslib 7.5.

Appreciate the help,
Dooners.
Message 5 of 5
Anonymous
in reply to: Anonymous

Ah scrap that have found the error.

(command "wblock" new_dwg "" DIP Drawing "") was missing last "".
So simple.....
Dooners

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report