Ed.SelectAll Crashing AutoCAD

Ed.SelectAll Crashing AutoCAD

WonkaPet
Advocate Advocate
1,416 Views
3 Replies
Message 1 of 4

Ed.SelectAll Crashing AutoCAD

WonkaPet
Advocate
Advocate

 Hi there,


I've searched the forums but I can't seem to find a resolution to my problem.
I'm using the Ed.SelectAll(SelectionFilter) to select LWPOLYLINEs on a layer.

It will work during my first run through of the code but when I attempt to run the code a second time it will crash giving the error " Attempted to read or write protected memory". This is a full AutoCAD crash and I'm unable to find the exact problem.

 

Does anyone know what types of things would cause this? The layer that I am using the SelectAll() is newly created and I'm beginning to think that maybe the layer it is searching through has issues from when it was created?

 

Thanks and let me know if I can provide anything else to help with troubleshooting.

0 Likes
Accepted solutions (1)
1,417 Views
3 Replies
Replies (3)
Message 2 of 4

r.robert.bell
Advocate
Advocate

Are you releasing the new Layer object after you are done creating it?

Set myLayer = Nothing
R. Robert Bell
BIM Manager
Stantec
0 Likes
Message 3 of 4

norman.yuan
Mentor
Mentor

Firstly, it seems you are talking about AutoCAD .NET API programming, which is the topic for another forum. This forum is for AutoCAD VB/COM API.

 

Secondly, since your code works at least once, and crashes at second run (but you did not say how you do "second run"), it is quite obvious it is the code that causes the issue. There is no way for anyone to guess what is wrong without seeing all the relevant code, though. You need to post your code.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 4

WonkaPet
Advocate
Advocate
Accepted solution

Sorry I couldn't provide more details I didn't really know how to go about simplifying my code since it was in many nested functions and classes.

 

Basically I forgot that I moved some transactions around in a prior update. This ended up with me having two transactions intertwined. One transaction was attempting to delete a RXClass while the other transaction was open and I don't think it liked that so the item wasn't actually being erased. I just had to make it so the transactions never overlapped and my problems were fixed.

 

Thanks Norman and Robert.

0 Likes