Trapping Invalid Input error

Trapping Invalid Input error

Anonymous
Not applicable
394 Views
2 Replies
Message 1 of 3

Trapping Invalid Input error

Anonymous
Not applicable
I have been working on a VB6 app for AutoCAD 2002 that takes lines which cross an area both horizontally and vertically much like grid, and then breaks the lines at the intersections and forms regions from the lines. Occasionally the AddRegion method will generate an Invalid Input error and cause the program to halt. If I take the same set of lines that generates the Invalid Input error and manually build regions from these line entities in AutoCAD then most of the regions are created and the command line shows that X number of regions were rejected.

My question is, how can I trap the Invalid Input error and keep the app from crashing, create most of the regions, and possibly provide a message box that alerts the user that X number of regions were not created.

The statement that generates the Invalid Input error is:

reglist = ModSpace.AddRegion(regTemp1)

with regTemp1 containing anywhere from a few up to thousands of line entities.
0 Likes
395 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
generally
On error resume next
reglist = ModSpace.AddRegion(regTemp1)
If err then
err.clear
...do whatever in case of error
Debug.print regTemp1 & " created error"
...maybe
collectionOfErrorConditions.Add regTemp1
... or whatever
Else
...do in case no err
end if

Debug.print "There were " & collectionOfErrorConditions.Count & " errors"
Debug.print "The data causing errors was: "
for i = 1 to collectionOfErrorConditions.Count
Debug.Print collectionOfErrorConditions.Item(i)
next

etc....

just an idea

"SBLoe" wrote in message
news:f1a455d.-1@WebX.maYIadrTaRb...
> I have been working on a VB6 app for AutoCAD 2002 that takes lines which
cross an area both horizontally and vertically much like grid, and then
breaks the lines at the intersections and forms regions from the lines.
Occasionally the AddRegion method will generate an Invalid Input error and
cause the program to halt. If I take the same set of lines that generates
the Invalid Input error and manually build regions from these line entities
in AutoCAD then most of the regions are created and the command line shows
that X number of regions were rejected.
> My question is, how can I trap the Invalid Input error and keep the app
from crashing, create most of the regions, and possibly provide a message
box that alerts the user that X number of regions were not created.
>
> The statement that generates the Invalid Input error is:
>
> reglist = ModSpace.AddRegion(regTemp1)
>
> with regTemp1 containing anywhere from a few up to thousands of line
entities.
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks Mark,

This will keep the program from crashing which was one of my objectives. It's hard for me to tell yet but I don't think the AddRegion method is returning any regions. I'm having to wait for one of my users to submitt a drawing that generates an Invalid input condition because I can't seem to generate the condition on purpose for testing.

When creating regions within AutoCAD, the invalid loops are rejected but all the good one are created. So far it looks like when my app tries to use the AddRegion method when an Invalid input condition exists, the loops that are good are still not returned. With the large number of potential loops being generated, It would slow down the app substancially if I were to try and loop through all the entities submitted to the AddRegion method to try and issolate the bad loop.

Any ideas on how to get the AddRegion method to return the loops that are good when the Invalid input condition exists?
0 Likes