Object was open for read error

Object was open for read error

Anonymous
Not applicable
915 Views
4 Replies
Message 1 of 5

Object was open for read error

Anonymous
Not applicable
One of my VB6 applications replaces about 200 blocks on a Drawing with a different block type, and copies across the colour to the new block.

In the process of Get Colour of OldBlockX, Get Location of OldBlockX, Get Rotation of OldBlockX, Delete OldBlockX, Place NewBlockX at Location and Rotation, Set Colour of NewBlockX, 200 times in a loop, the following error sometimes (but rarely) appears, at the point of Set Colour:

"Run time error: -2145386418 - Object was open for read"

Does anyone have an idea why this should happen and how to avoid it?
0 Likes
916 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Are you using the SendCommand() function anywhere?

If not, I can't tell you much from your description alone.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5228362@discussion.autodesk.com...
One of my VB6 applications replaces about 200 blocks on a Drawing with a different block type, and copies across the colour to the new block.

In the process of Get Colour of OldBlockX, Get Location of OldBlockX, Get Rotation of OldBlockX, Delete OldBlockX, Place NewBlockX at Location and Rotation, Set Colour of NewBlockX, 200 times in a loop, the following error sometimes (but rarely) appears, at the point of Set Colour:

"Run time error: -2145386418 - Object was open for read"

Does anyone have an idea why this should happen and how to avoid it?
0 Likes
Message 3 of 5

Anonymous
Not applicable
Here is the offending code. It works by itself of course, but do this fast enough and often enough and it errors on the colour set line. I don't think the problem is in the arguments.

Dim thisBlock As AcadBlockReference

Set thisBlock = thisDWG.ModelSpace.InsertBlock(vInsert, _
strBlockName, _
dLength, _
dWidth, _
1, _
dRotation)

thisBlock.Color = lngColour

Any thoughts would be much appreciated.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Nothing is wrong with this code, as is. I see this is written in VB6. Are
you running out of process, or in process via an ActiveX .dll?

Because it happens rarely, I'm thinking it might be running into an
auto-save, especially if you are out of process. Perhaps you should query
IsQuiescent before changing the color.

You may also want to revise your code to use the TrueColor object.

--
R. Robert Bell


wrote in message news:5228576@discussion.autodesk.com...
Here is the offending code. It works by itself of course, but do this fast
enough and often enough and it errors on the colour set line. I don't think
the problem is in the arguments.

Dim thisBlock As AcadBlockReference

Set thisBlock = thisDWG.ModelSpace.InsertBlock(vInsert, _
strBlockName, _
dLength, _
dWidth, _
1, _
dRotation)

thisBlock.Color = lngColour

Any thoughts would be much appreciated.
0 Likes
Message 5 of 5

Anonymous
Not applicable
It's quite possible that out of process automation
requests may return before AutoCAD has returned
to a quiescent state, and is able service the next
automation request. Out-of-process automation
has always been quirky in that regards, and is why
many try to avoid it whenever possible.

Inserting a line of code that checks the IsQuiescent
property of the AcadState object (a member of the
Application object) may help.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5228576@discussion.autodesk.com...
Here is the offending code. It works by itself of course, but do this fast enough and often enough and it errors on the colour set line. I don't think the problem is in the arguments.

Dim thisBlock As AcadBlockReference

Set thisBlock = thisDWG.ModelSpace.InsertBlock(vInsert, _
strBlockName, _
dLength, _
dWidth, _
1, _
dRotation)

thisBlock.Color = lngColour

Any thoughts would be much appreciated.
0 Likes