.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RasterImageDef and GetReactor method

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
974 Views, 14 Replies

RasterImageDef and GetReactor method

I think to get the information I want I have to use the GetReactor method on the RasterImageDef object. The problems is when I get the DBObjectCollection returned, it won't let me look at any of the objects within the collection. It errors out with
"Attempted to read or wirte protected menory. This is ofter an indication that other memory is corrupt."

What I'm trying to do is get the RasterImage object from the RasterImageDef object. I don't want to have to look through the whole drawing to find out where the RasterImage is inserted. I can do this with lisp by looking at what the RasterImageDefReactor is associated with, but I can't seem to access the RasterImageDefReactor with .Net.

Any help why, or where to look to get this information would be great, as I've read the Arx help files, and can't seem to find what I'm looking for.

Thanks in advacne.

Tim
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
Message 3 of 15
Anonymous
in reply to: Anonymous

Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
Message 4 of 15
Anonymous
in reply to: Anonymous

Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj == null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 5 of 15
Anonymous
in reply to: Anonymous

Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach loop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j < dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj == null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 6 of 15
Anonymous
in reply to: Anonymous

Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the top of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach loop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j < dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj == null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 7 of 15
Anonymous
in reply to: Anonymous

I can post the whole code, not a problem, I just didn't know if anyone
wanted to see the whole thing.

I don't see a method for GetPersistentReactorIds(), but in Reflector I do
see the GetReactors() method. It says the GetReactors() method is inherited
from the DBObject class. I just added a line to check to see if the
RasterImageDef has a persistent reactor, and it showed false.

Thanks for your help here Tony, I really appreciate it.

--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5653052@discussion.autodesk.com...
Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the top of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach loop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j < dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj == null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 8 of 15
Anonymous
in reply to: Anonymous

Tim - You saw GetReactors() in reflector.

Did you see what it returns?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5653143@discussion.autodesk.com...
I can post the whole code, not a problem, I just didn't know if anyone
wanted to see the whole thing.

I don't see a method for GetPersistentReactorIds(), but in Reflector I do
see the GetReactors() method. It says the GetReactors() method is inherited
from the DBObject class. I just added a line to check to see if the
RasterImageDef has a persistent reactor, and it showed false.

Thanks for your help here Tony, I really appreciate it.

--

Tim
"A blind man lets nothing
block his vision."


"Tony Tanzillo" wrote in message
news:5653052@discussion.autodesk.com...
Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the t
op of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach l
oop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj
== null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
h
ttp://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim

"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 9 of 15
Anonymous
in reply to: Anonymous

Tony,

In reflector, under RasterImageDef this appears

GetReactors() : DBObjectCollection {
Autodesk.AutoCAD.DatabaseSerices.DBObject }

I thought that meant that a DBObjectCollection was returned. I have
reflector setup to show all methods and properties that can be used with
that class, not just the ones assigned to the class, but the ones inherited
also.

--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5653400@discussion.autodesk.com...
Tim - You saw GetReactors() in reflector.

Did you see what it returns?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5653143@discussion.autodesk.com...
I can post the whole code, not a problem, I just didn't know if anyone
wanted to see the whole thing.

I don't see a method for GetPersistentReactorIds(), but in Reflector I do
see the GetReactors() method. It says the GetReactors() method is inherited
from the DBObject class. I just added a line to check to see if the
RasterImageDef has a persistent reactor, and it showed false.

Thanks for your help here Tony, I really appreciate it.

--

Tim
"A blind man lets nothing
block his vision."


"Tony Tanzillo" wrote in message
news:5653052@discussion.autodesk.com...
Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the t
op of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach l
oop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj
== null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
h
ttp://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim

"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 10 of 15
Anonymous
in reply to: Anonymous

When I put this code it
MessageBox.Show(rid.GetReactors().GetType().ToString());

It returns Autodesk.AutoCAD.DatabaseServices.DBObjectCollection
--

Tim
"A blind man lets nothing block his vision."



"Tony Tanzillo" wrote in message
news:5653400@discussion.autodesk.com...
Tim - You saw GetReactors() in reflector.

Did you see what it returns?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5653143@discussion.autodesk.com...
I can post the whole code, not a problem, I just didn't know if anyone
wanted to see the whole thing.

I don't see a method for GetPersistentReactorIds(), but in Reflector I do
see the GetReactors() method. It says the GetReactors() method is inherited
from the DBObject class. I just added a line to check to see if the
RasterImageDef has a persistent reactor, and it showed false.

Thanks for your help here Tony, I really appreciate it.

--

Tim
"A blind man lets nothing
block his vision."


"Tony Tanzillo" wrote in message
news:5653052@discussion.autodesk.com...
Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the t
op of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach l
oop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj
== null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
h
ttp://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim

"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 11 of 15
Anonymous
in reply to: Anonymous

Tim - I didn't notice that GetReactors() has changed
in AutoCAD 2008. In AutoCAD 2007 it does return a
DBObjectCollection, and that's the problem. Not all
reactors are DBObjects, so that code isn't going to
work. In AutoCAD 2008, GetReactors() returns a list
of RXObjects which is what it should do.

Nonetheless, the method you should be calling is not
GetReactors(), you should call GetPersistentReactorIds().

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5653143@discussion.autodesk.com...
I can post the whole code, not a problem, I just didn't know if anyone
wanted to see the whole thing.

I don't see a method for GetPersistentReactorIds(), but in Reflector I do
see the GetReactors() method. It says the GetReactors() method is inherited
from the DBObject class. I just added a line to check to see if the
RasterImageDef has a persistent reactor, and it showed false.

Thanks for your help here Tony, I really appreciate it.

--

Tim
"A blind man lets nothing
block his vision."


"Tony Tanzillo" wrote in message
news:5653052@discussion.autodesk.com...
Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the t
op of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach l
oop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj
== null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
h
ttp://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim

"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 12 of 15
Anonymous
in reply to: Anonymous

Tony,

If that is the only way, then it looks like I can't do what I want in '06
with .Net, as there is no method GetPersistentReactorIds() method for the
RasterImageDef class.

Maybe I can figure out another way to do it.

Thanks for your time and effort, it is appreciated.

--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5654798@discussion.autodesk.com...
Tim - I didn't notice that GetReactors() has changed
in AutoCAD 2008. In AutoCAD 2007 it does return a
DBObjectCollection, and that's the problem. Not all
reactors are DBObjects, so that code isn't going to
work. In AutoCAD 2008, GetReactors() returns a list
of RXObjects which is what it should do.

Nonetheless, the method you should be calling is not
GetReactors(), you should call GetPersistentReactorIds().

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5653143@discussion.autodesk.com...
I can post the whole code, not a problem, I just didn't know if anyone
wanted to see the whole thing.

I don't see a method for GetPersistentReactorIds(), but in Reflector I do
see the GetReactors() method. It says the GetReactors() method is inherited
from the DBObject class. I just added a line to check to see if the
RasterImageDef has a persistent reactor, and it showed false.

Thanks for your help here Tony, I really appreciate it.

--

Tim
"A blind man lets nothing
block his vision."


"Tony Tanzillo" wrote in message
news:5653052@discussion.autodesk.com...
Hi Tim.

You're describing a problem you're having, but you're
not showing me the code where the problem is.

There's no 'GetReactor' method, so I assumed you meant
the 'GetReactors' method, but the problem there is that
GetReactors() doesn't return a DBObjectCollection.

I can help if you post the relevant code, rather than
little bits and pieces.

Off the t
op of my head, you should be calling the
GetPersistentReactorIds() method, not GetReactors(),
since the reactors you want are persistent.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5652480@discussion.autodesk.com...
Hi Tony,

I can't seem to get it to work even with the way you say to go. I get the
same error message after I loop through with the foreach l
oop. Here is the
code I tried, with all the variations I tired. Am I doing something wrong?
Thanks for your help.

//try {

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null) throw new InvalidOperationException("null DBObject");

//}

//catch {}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject dbo = dboc as DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--

Tim
"A blind man lets nothing block his vision."


"Tony Tanzillo" wrote in message
news:5652251@discussion.autodesk.com...
Hi Tim.

Not long ago on this newsgroup, a bug was discovered
in the indexer for DBObjectCollection.

You can't use it without first doing this:

foreach( DBObject obj in yourDBObjectCollection )
if( obj
== null )
throw new InvalidOperationException("null dbobject");

By calling foreach() on the collection it forces the
creation of all DBObject wrappers. If you try to use
the indexer without doing that first, it gets confused
and kaboom.

So, just iterate over the collection using something
like the above first, then you can access the elements
via the indexer.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
h
ttp://www.acadxtabs.com

wrote in message news:5651219@discussion.autodesk.com...
Thanks Tony. Here is the routine I did to find the information I want. I
don't think the formatting will show correctly, so I'll post a file that has
the routine in it.

The problem is this part.

try { DBObject dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) { MessageBox.Show(ex.Message); }


--

Tim

"A blind man lets nothing block his vision."


"Tony Tanzillo" HE_URL_BELOW.com> wrote in message
news:5649956@discussion.autodesk.com...
>> The problems is when I get the DBObjectCollection returned, it
>> won't let me look at any of the objects within the collection.
>> It errors out with "Attempted to read or wirte protected menory.

Tim - Can't really guess about what your code is doing, so if you
can post the relevant part, then maybe we can spot something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through 2008
http://www.acadxtabs.com
Message 13 of 15
Anonymous
in reply to: Anonymous


Hi Tim.  For things like this where you don't have
an

API function in the release you're using, you can
drop

down to the legacy solution (the ObjectARX
equivalent

of the LISP (entget) function).  In the code below,
you

need to change the name of the library (to
acdb16.dll)

in order to use this on AutoCAD 2006.

 

Call this function on the objectid of the object that has

the reactors on it, and it returns a
resultbuffer that is

the managed equvialent of the association list
that's

returned by the LISP (entget) function. You should
be

able to figure out what to do from there 🙂

 

[code]
public static class SafeNativeMethods
{
   [DllImport( "acdb17.dll", CallingConvention = CallingConvention.Cdecl,
       EntryPoint = "
?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z" )]
   extern static public ErrorStatus acdbGetAdsName( out Int64 entres, ObjectId id );
   [DllImport( "acad.exe", CallingConvention = CallingConvention.Cdecl )]
   extern static IntPtr acdbEntGet( out Int64 e );
   public static ResultBuffer EntGet( ObjectId id )
   {
      Int64 e;
      if( acdbGetAdsName( out e, id ) == ErrorStatus.OK )
      {
         IntPtr res = acdbEntGet( out e );
         if( res != IntPtr.Zero )
            return ResultBuffer.Create( res, true );
      }
      return null;
   }
}

[/code]


 

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting
AutoCAD 2000 through 2008

size=1>http://www.acadxtabs.com


Tony,

If that is the only way, then
it looks like I can't do what I want in '06
with .Net, as there is no method
GetPersistentReactorIds() method for the
RasterImageDef class.

Maybe
I can figure out another way to do it.

Thanks for your time and effort,
it is appreciated.

--

Tim
"A blind man lets nothing block his
vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@THE_URL_BELOW.com">
size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5654798@discussion.autodesk.com
...
Tim -
I didn't notice that GetReactors() has changed
in AutoCAD 2008. In AutoCAD
2007 it does return a
DBObjectCollection, and that's the problem. Not
all
reactors are DBObjects, so that code isn't going to
work. In AutoCAD
2008, GetReactors() returns a list
of RXObjects which is what it should
do.

Nonetheless, the method you should be calling is
not
GetReactors(), you should call GetPersistentReactorIds().

--


size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008

size=1>http://www.acadxtabs.com


<T.Willey>
wrote in message

size=1>news:5653143@discussion.autodesk.com
...
I can
post the whole code, not a problem, I just didn't know if anyone
wanted to
see the whole thing.

I don't see a method for GetPersistentReactorIds(),
but in Reflector I do
see the GetReactors() method.  It says the
GetReactors() method is inherited
from the DBObject class.  I just added
a line to check to see if the
RasterImageDef has a persistent reactor, and it
showed false.

Thanks for your help here Tony, I really appreciate
it.

--

Tim
"A blind man lets nothing
 block his
vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@THE_URL_BELOW.com">
size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5653052@discussion.autodesk.com
...
Hi
Tim.

You're describing a problem you're having, but you're
not showing
me the code where the problem is.

There's no 'GetReactor' method, so I
assumed you meant
the 'GetReactors' method, but the problem there is
that
GetReactors() doesn't return a DBObjectCollection.

I can help if
you post the relevant code, rather than
little bits and pieces.

Off
the t
op of my head, you should be calling the
GetPersistentReactorIds()
method, not GetReactors(),
since the reactors you want are
persistent.

--

size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008

size=1>http://www.acadxtabs.com


<T.Willey>
wrote in message

size=1>news:5652480@discussion.autodesk.com
...
Hi
Tony,

  I can't seem to get it to work even with the way you say to
go.  I get the
same error message after I loop through with the foreach
l
oop.  Here is the
code I tried, with all the variations I
tired.  Am I doing something wrong?
Thanks for your help.

//try
{

foreach (DBObject dbo in dboc) {

//try {

if (dbo == null)
throw new InvalidOperationException("null DBObject");

//}

//catch
{}

}

//}

//catch (Autodesk.AutoCAD.Runtime.Exception
AcadEr) {
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception
ex) { MessageBox.Show(ex.Message); }

MessageBox.Show("Done with
foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject
dbo = dboc as
DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--


Tim
"A blind man lets nothing block his vision."


"Tony
Tanzillo" <

size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5652251@discussion.autodesk.com
...
Hi
Tim.

Not long ago on this newsgroup, a bug was discovered
in the
indexer for DBObjectCollection.

You can't use it without first doing
this:

  foreach( DBObject obj in yourDBObjectCollection
)
     if( obj
== null
)
         throw new
InvalidOperationException("null dbobject");

By calling foreach() on the
collection it forces the
creation of all DBObject wrappers. If you try to
use
the indexer without doing that first, it gets confused
and
kaboom.

So, just iterate over the collection usin something
like the
above first, then you can access the elements
via the indexer.

--


size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008
h
ttp://www.acadxtabs.com

<T.Willey> wrote in message

size=1>news:5651219@discussion.autodesk.com
...
Thanks
Tony.  Here is the routine I did to find the information I want. 
I
don't think the formatting will show correctly, so I'll post a file that
has
the routine in it.

The problem is this part.

try { DBObject
dbo = dboc[0]; }

catch (Autodesk.AutoCAD.Runtime.Exception AcadEr)
{
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) {
MessageBox.Show(ex.Message); }


--

Tim

"A blind man
lets nothing block his vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@T">tony.tanzillo@T


size=1>HE_URL_BELOW.com> wrote in message

href="news:5649956@discussion.autodesk.com">
size=1>news:5649956@discussion.autodesk.com

size=1>...
>> The problems is when I get the DBObjectCollection
returned, it
>> won't let me look at any of the objects within the
collection.
>> It errors out with "Attempted to read or wirte protected
menory.

Tim - Can't really guess about what your code is doing, so if
you
can post the relevant part, then maybe we can spot something.

--

htt
p://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
2008
Supporting A
utoCAD 2000 through 2008

href="http://www.acadxtabs.com">http://www.acadxtabs.com

Message 14 of 15
Anonymous
in reply to: Anonymous


WOW!  Thanks Tony (you are one smart programmer)!  I
had no idea how to do it this way.  I will see what I can come up
with.


--

Tim
"A blind man lets nothing block his vision."

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Hi Tim.  For things like this where you don't have
an

API function in the release you're using, you can
drop

down to the legacy solution (the ObjectARX
equivalent

of the LISP (entget) function).  In the code below,
you

need to change the name of the library (to
acdb16.dll)

in order to use this on AutoCAD 2006.

 

Call this function on the objectid of the object that has

the reactors on it, and it returns a
resultbuffer that is

the managed equvialent of the association list
that's

returned by the LISP (entget) function. You should
be

able to figure out what to do from there 🙂

 

[code]
public static class SafeNativeMethods
{
   [DllImport( "acdb17.dll", CallingConvention = CallingConvention.Cdecl,
       EntryPoint = "
?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z" )]
   extern static public ErrorStatus acdbGetAdsName( out Int64 entres, ObjectId id );
   [DllImport( "acad.exe", CallingConvention = CallingConvention.Cdecl )]
   extern static IntPtr acdbEntGet( out Int64 e );
   public static ResultBuffer EntGet( ObjectId id )
   {
      Int64 e;
      if( acdbGetAdsName( out e, id ) == ErrorStatus.OK )
      {
         IntPtr res = acdbEntGet( out e );
         if( res != IntPtr.Zero )
            return ResultBuffer.Create( res, true );
      }
      return null;
   }
}

[/code]


 

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting
AutoCAD 2000 through 2008

size=1>http://www.acadxtabs.com


Tony,

If that is the only way, then
it looks like I can't do what I want in '06
with .Net, as there is no
method GetPersistentReactorIds() method for the
RasterImageDef
class.

Maybe I can figure out another way to do it.

Thanks for
your time and effort, it is appreciated.

--

Tim
"A blind man
lets nothing block his vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@THE_URL_BELOW.com">
size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5654798@discussion.autodesk.com
...
Tim
- I didn't notice that GetReactors() has changed
in AutoCAD 2008. In
AutoCAD 2007 it does return a
DBObjectCollection, and that's the problem.
Not all
reactors are DBObjects, so that code isn't going to
work. In
AutoCAD 2008, GetReactors() returns a list
of RXObjects which is what it
should do.

Nonetheless, the method you should be calling is
not
GetReactors(), you should call GetPersistentReactorIds().

--


size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008

size=1>http://www.acadxtabs.com



size=1><T.Willey> wrote in message

href="news:5653143@discussion.autodesk.com">
size=1>news:5653143@discussion.autodesk.com
...
I
can post the whole code, not a problem, I just didn't know if anyone
wanted
to see the whole thing.

I don't see a method for
GetPersistentReactorIds(), but in Reflector I do
see the GetReactors()
method.  It says the GetReactors() method is inherited
from the
DBObject class.  I just added a line to check to see if
the
RasterImageDef has a persistent reactor, and it showed
false.

Thanks for your help here Tony, I really appreciate
it.

--

Tim
"A blind man lets nothing
 block his
vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@THE_URL_BELOW.com">
size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5653052@discussion.autodesk.com
...
Hi
Tim.

You're describing a problem you're having, but you're
not
showing me the code where the problem is.

There's no 'GetReactor'
method, so I assumed you meant
the 'GetReactors' method, but the problem
there is that
GetReactors() doesn't return a DBObjectCollection.

I
can help if you post the relevant code, rather than
little bits and
pieces.

Off the t
op of my head, you should be calling
the
GetPersistentReactorIds() method, not GetReactors(),
since the
reactors you want are persistent.

--

href="http://www.caddzone.com">
size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008

size=1>http://www.acadxtabs.com



size=1><T.Willey> wrote in message

href="news:5652480@discussion.autodesk.com">
size=1>news:5652480@discussion.autodesk.com
...
Hi
Tony,

  I can't seem to get it to work even with the way you say
to go.  I get the
same error message after I loop through with the
foreach l
oop.  Here is the
code I tried, with all the variations I
tired.  Am I doing something wrong?
Thanks for your help.

//try
{

foreach (DBObject dbo in dboc) {

//try {

if (dbo ==
null) throw new InvalidOperationException("null
DBObject");

//}

//catch {}

}

//}

//catch
(Autodesk.AutoCAD.Runtime.Exception AcadEr)
{
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) {
MessageBox.Show(ex.Message); }

MessageBox.Show("Done with
foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject
dbo = dboc as
DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--


Tim
"A blind man lets nothing block his vision."


"Tony
Tanzillo" <

size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5652251@discussion.autodesk.com
...
Hi
Tim.

Not long ago on this newsgroup, a bug was discovered
in the
indexer for DBObjectCollection.

You can't use it without first doing
this:

  foreach( DBObject obj in yourDBObjectCollection
)
     if( obj
== null
)
         throw new
InvalidOperationException("null dbobject");

By calling foreach() on the
collection it forces the
creation of all DBObject wrappers. If you try to
use
the indexer without doing that first, it gets confused
and
kaboom.

So, just iterate over the collection usin something
like the
above first, then you can access the elements
via the indexer.

--


size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008
h
ttp://www.acadxtabs.com

<T.Willey> wrote in message

size=1>news:5651219@discussion.autodesk.com

size=1>...
Thanks Tony.  Here is the routine I did to find the
information I want.  I
don't think the formatting will show correctly,
so I'll post a file that has
the routine in it.

The problem is this
part.

try { DBObject dbo = dboc[0]; }

catch
(Autodesk.AutoCAD.Runtime.Exception AcadEr)
{
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) {
MessageBox.Show(ex.Message); }


--

Tim

"A blind man
lets nothing block his vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@T">tony.tanzillo@T


size=1>HE_URL_BELOW.com> wrote in message

href="news:5649956@discussion.autodesk.com">
size=1>news:5649956@discussion.autodesk.com

size=1>...
>> The problems is when I get the DBObjectCollection
returned, it
>> won't let me look at any of the objects within the
collection.
>> It errors out with "Attempted to read or wirte
protected menory.

Tim - Can't really guess about what your code is
doing, so if you
can post the relevant part, then maybe we can spot
something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through
2008

size=1>http://www.acadxtabs.com
Message 15 of 15
Anonymous
in reply to: Anonymous


Tony,

 

  I got it to work the way I wanted it to.  Thanks
again!  I wouldn't have been able to do it without your help.


--

Tim
"A blind man lets nothing block his vision."

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Hi Tim.  For things like this where you don't have
an

API function in the release you're using, you can
drop

down to the legacy solution (the ObjectARX
equivalent

of the LISP (entget) function).  In the code below,
you

need to change the name of the library (to
acdb16.dll)

in order to use this on AutoCAD 2006.

 

Call this function on the objectid of the object that has

the reactors on it, and it returns a
resultbuffer that is

the managed equvialent of the association list
that's

returned by the LISP (entget) function. You should
be

able to figure out what to do from there 🙂

 

[code]
public static class SafeNativeMethods
{
   [DllImport( "acdb17.dll", CallingConvention = CallingConvention.Cdecl,
       EntryPoint = "
?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z" )]
   extern static public ErrorStatus acdbGetAdsName( out Int64 entres, ObjectId id );
   [DllImport( "acad.exe", CallingConvention = CallingConvention.Cdecl )]
   extern static IntPtr acdbEntGet( out Int64 e );
   public static ResultBuffer EntGet( ObjectId id )
   {
      Int64 e;
      if( acdbGetAdsName( out e, id ) == ErrorStatus.OK )
      {
         IntPtr res = acdbEntGet( out e );
         if( res != IntPtr.Zero )
            return ResultBuffer.Create( res, true );
      }
      return null;
   }
}

[/code]


 

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting
AutoCAD 2000 through 2008

size=1>http://www.acadxtabs.com


Tony,

If that is the only way, then
it looks like I can't do what I want in '06
with .Net, as there is no
method GetPersistentReactorIds() method for the
RasterImageDef
class.

Maybe I can figure out another way to do it.

Thanks for
your time and effort, it is appreciated.

--

Tim
"A blind man
lets nothing block his vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@THE_URL_BELOW.com">
size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5654798@discussion.autodesk.com
...
Tim
- I didn't notice that GetReactors() has changed
in AutoCAD 2008. In
AutoCAD 2007 it does return a
DBObjectCollection, and that's the problem.
Not all
reactors are DBObjects, so that code isn't going to
work. In
AutoCAD 2008, GetReactors() returns a list
of RXObjects which is what it
should do.

Nonetheless, the method you should be calling is
not
GetReactors(), you should call GetPersistentReactorIds().

--


size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008

size=1>http://www.acadxtabs.com



size=1><T.Willey> wrote in message

href="news:5653143@discussion.autodesk.com">
size=1>news:5653143@discussion.autodesk.com
...
I
can post the whole code, not a problem, I just didn't know if anyone
wanted
to see the whole thing.

I don't see a method for
GetPersistentReactorIds(), but in Reflector I do
see the GetReactors()
method.  It says the GetReactors() method is inherited
from the
DBObject class.  I just added a line to check to see if
the
RasterImageDef has a persistent reactor, and it showed
false.

Thanks for your help here Tony, I really appreciate
it.

--

Tim
"A blind man lets nothing
 block his
vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@THE_URL_BELOW.com">
size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5653052@discussion.autodesk.com
...
Hi
Tim.

You're describing a problem you're having, but you're
not
showing me the code where the problem is.

There's no 'GetReactor'
method, so I assumed you meant
the 'GetReactors' method, but the problem
there is that
GetReactors() doesn't return a DBObjectCollection.

I
can help if you post the relevant code, rather than
little bits and
pieces.

Off the t
op of my head, you should be calling
the
GetPersistentReactorIds() method, not GetReactors(),
since the
reactors you want are persistent.

--

href="http://www.caddzone.com">
size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008

size=1>http://www.acadxtabs.com



size=1><T.Willey> wrote in message

href="news:5652480@discussion.autodesk.com">
size=1>news:5652480@discussion.autodesk.com
...
Hi
Tony,

  I can't seem to get it to work even with the way you say
to go.  I get the
same error message after I loop through with the
foreach l
oop.  Here is the
code I tried, with all the variations I
tired.  Am I doing something wrong?
Thanks for your help.

//try
{

foreach (DBObject dbo in dboc) {

//try {

if (dbo ==
null) throw new InvalidOperationException("null
DBObject");

//}

//catch {}

}

//}

//catch
(Autodesk.AutoCAD.Runtime.Exception AcadEr)
{
MessageBox.Show(AcadEr.Message); }

//catch (System.Exception ex) {
MessageBox.Show(ex.Message); }

MessageBox.Show("Done with
foreach");

for (int j = 0; j
< dboc.Count; ++j) {

DBObject
dbo = dboc as
DBObject;

MessageBox.Show(dbo.GetType().ToString());

}


--


Tim
"A blind man lets nothing block his vision."


"Tony
Tanzillo" <

size=1>tony.tanzillo@THE_URL_BELOW.com
> wrote in
message

size=1>news:5652251@discussion.autodesk.com
...
Hi
Tim.

Not long ago on this newsgroup, a bug was discovered
in the
indexer for DBObjectCollection.

You can't use it without first doing
this:

  foreach( DBObject obj in yourDBObjectCollection
)
     if( obj
== null
)
         throw new
InvalidOperationException("null dbobject");

By calling foreach() on the
collection it forces the
creation of all DBObject wrappers. If you try to
use
the indexer without doing that first, it gets confused
and
kaboom.

So, just iterate over the collection usin something
like the
above first, then you can access the elements
via the indexer.

--


size=1>http://www.caddzone.com


AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through
2008
h
ttp://www.acadxtabs.com

<T.Willey> wrote in message

size=1>news:5651219@discussion.autodesk.com

size=1>...
Thanks Tony.  Here is the routine I did to find the
information I want.  I
don't think the formatting will show correctly,
so I'll post a file that has
the routine in it.

The problem is this
part.

try { DBObject dbo = dboc[0]; }

catch
(Autodesk.AutoCAD.Runtime.Exception AcadEr)
{
MessageBox.Show(AcadEr.Message); }

catch (System.Exception ex) {
MessageBox.Show(ex.Message); }


--

Tim

"A blind man
lets nothing block his vision."


"Tony Tanzillo" <

href="mailto:tony.tanzillo@T">tony.tanzillo@T


size=1>HE_URL_BELOW.com> wrote in message

href="news:5649956@discussion.autodesk.com">
size=1>news:5649956@discussion.autodesk.com

size=1>...
>> The problems is when I get the DBObjectCollection
returned, it
>> won't let me look at any of the objects within the
collection.
>> It errors out with "Attempted to read or wirte
protected menory.

Tim - Can't really guess about what your code is
doing, so if you
can post the relevant part, then maybe we can spot
something.

--
htt
p://www.caddzone.com

AcadXTabs: MDI
Document Tabs for AutoCAD 2008
Supporting A
utoCAD 2000 through
2008

size=1>http://www.acadxtabs.com

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost