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

Error in definition of Drawable.Bounds

2 REPLIES 2
Reply
Message 1 of 3
mleslie00
6607 Views, 2 Replies

Error in definition of Drawable.Bounds

 

I just ran into an odd problem with the Bounds method (inherited by all DBObjects).  I was attempting to us it like:

 

Dim bounds As Extents3d = txt.Bounds

 

but VB stated:

 

Error    3    Option Strict On disallows implicit conversions from 'Autodesk.AutoCAD.DatabaseServices.Extents3d?' to 'Autodesk.AutoCAD.DatabaseServices.Extents3d'. 

I looked to see where that question mark was coming from and if there was another class that I hadn't heard of.  It turns out that in the type library, it is defined as:

 

Public Overridable ReadOnly Property Bounds As Autodesk.AutoCAD.DatabaseServices.Extents3d?
     Member of Autodesk.AutoCAD.GraphicsInterface.Drawable

 

This really seems like an error in the type library, how do I ask Autodesk to fix it?

 

Dim bounds As Extents3d = DirectCast(txt.Bounds, Extents3d)

 

does not work since there is not a inheritance or implementation relationship to the typo.

 

Dim bounds As Extents3d = CType(txt.Bounds, Extents3d)

 

seems to work, but how do I get someone to fix the underlying problem?  I think it effects every entity in the database since they all inherit from Drawable.  Or did they do this on purpose for reasons that are beyond me?

 

 

 

 

 

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: mleslie00


@mleslie00 wrote:
...

 

This really seems like an error in the type library, how do I ask Autodesk to fix it?

 ...

 


There is nothing to fix in AutoCAD API. DbObject.Bounds is a Nullable<T> type, where T is Extents3d, which is not the same as type Extents3d., that is why you get error when in VB.NET you set "Strict On" and when you cannot DirectCats(...) it. if you use C#, you get the same error.

You get a Extents3d value from Extents3d? (or any Nullable<T> types) by Nullable<T>.Value, only if the Nullable<T>.HasValue is true.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
mleslie00
in reply to: norman.yuan

Ah, thank you.  I have not used nullable much myself and much of the sample code I read when it first came out used the "Nullable(Of" or Nullable<T> syntax, rather than the ? thus I did not recognise the operator.  Not surprisingly "?" does not work well in search engines.

 

I can see why it would be useful to be nullable on a Text object since if the text string is empty, there would be no bounding box.

 

I am now using the following construction in my code:

 

If txt.Bounds.HasValue Then
    bounds = txt.Bounds.Value

Else

   

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