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

Extract Properties from AcadEntity

6 REPLIES 6
Reply
Message 1 of 7
SuperFly
707 Views, 6 Replies

Extract Properties from AcadEntity

I'm trying to populate textboxes in a Windows App. with properties of a 3DSolid. I got the app to open a document with the solid and I can assign the solid to a variable - but I get an exception when I try to assign the 3DSolid's properties to variables. I can see the correct value in the Watch window though. For instance: Assume MySS is a selection set with 1 element being the solid.

Dim MySolid as Acad3DSolid
MySolid = MySS.Item(0)

Dim MyVolume as Double = MySolid.Volume

Last line is no good ==> Unhandled exception "System.EngineExecutionException"

but when I break and enter MySolid.MyVolume in the Watch window - it shows the correct value and says it's type "Double"

Could there be something wrong with my refs?

I've got AutoCad 2006 Type Library and AutoCAD/ObjectDBX Common 16.0 Type Library referenced.

Please help - this is driving me nuts.
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: SuperFly

If it is VB6, your code

Dim MySolid as Acad3DSolid
MySolid = MySS.Item(0)

looks fine. I am not sure, though, in VB.NET, implicit type conversion is
still OK. Since MySS.Item(0) returns an object, if you use C#, you
definitely need to cast it into Acad3DSolid:

MySolid=(Acad3DSolid)MySS.Item[0];

So, just try this in your VB.NET:

MySolid=CType(MySS.Item(0), Acad3DSolid)

wrote in message news:4964775@discussion.autodesk.com...
I'm trying to populate textboxes in a Windows App. with properties of a
3DSolid. I got the app to open a document with the solid and I can assign
the solid to a variable - but I get an exception when I try to assign the
3DSolid's properties to variables. I can see the correct value in the Watch
window though. For instance: Assume MySS is a selection set with 1 element
being the solid.

Dim MySolid as Acad3DSolid
MySolid = MySS.Item(0)

Dim MyVolume as Double = MySolid.Volume

Last line is no good ==> Unhandled exception
"System.EngineExecutionException"

but when I break and enter MySolid.MyVolume in the Watch window - it shows
the correct value and says it's type "Double"

Could there be something wrong with my refs?

I've got AutoCad 2006 Type Library and AutoCAD/ObjectDBX Common 16.0 Type
Library referenced.

Please help - this is driving me nuts.
Message 3 of 7
SuperFly
in reply to: SuperFly

Yeah, I'm in .NET - I tried the conversion, but still no good. The line:

Dim MyVolume as Double = MySolid.Volume

gives this exception:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in MyProgram.exe

Additional information: Invalid argument color in IAcadEntity::put_Color

Could this be a bug? Anyone try to do this before?
Message 4 of 7
Anonymous
in reply to: SuperFly

Is your code changing the color of the object somewhere?

--
http://www.caddzone.com

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

wrote in message news:4965236@discussion.autodesk.com...
Yeah, I'm in .NET - I tried the conversion, but still no good. The line:

Dim MyVolume as Double = MySolid.Volume

gives this exception:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in MyProgram.exe

Additional information: Invalid argument color in IAcadEntity::put_Color

Could this be a bug? Anyone try to do this before?
Message 5 of 7
SuperFly
in reply to: SuperFly

No - I'm not altering the entity at all. I open a file with a pre-existing solid, assign it to a variable using a selection set, and then just try to grab the volume. The color thing is very confusing. By the way - the file is .DXF - could this have anything to do with it? I'll try to save it as a dwg and try again.
Message 6 of 7
SuperFly
in reply to: SuperFly

Update: I tried changing to a DWG file to no avail. However, I also tried creating the solid from scratch entirely through my .NET app - in this case, the resulting solid properties were assignable. This however is not an option because of speed constraints - wondering if this enlightens anyone to what's going on in my pre-existing solid case.
Message 7 of 7
fantum
in reply to: SuperFly

Sounds like your existing solid may have nothing in it. Where did you get it?

Never mind. I see where you managed to get a volume in the watch window. Message was edited by: fantum

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