<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: casting from TypedValue with Type = (int)DxfCode.Bool in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109061#M76498</link>
    <description>You can't cast from an object to an int.&lt;BR /&gt;
&lt;BR /&gt;
You can use Convert.ToInt32(), etc. &lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;RLARXMAN2&gt; wrote in message news:5768864@discussion.autodesk.com...&lt;BR /&gt;
Hello,&lt;BR /&gt;
    I have successfully stored a boolean value into an Xrec using a TypedValue with Type of (int)DxfCode.Bool. &lt;BR /&gt;
   When I retrieve it the value is a 1 or 0 according to whether I had input True of False. So far, so good. The problem is that I am so far unable to cast this TypedValue.Value of 1 or 0 to either a bool or a Boolean or even an int or a long. How do I get that TypedValue.Value that is returned into another variable?&lt;BR /&gt;
   In the attached file what I am referring to is in&lt;BR /&gt;
 the method&lt;BR /&gt;
       public bool getBoolVar(string VarName)&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your advice.&lt;/RLARXMAN2&gt;</description>
    <pubDate>Mon, 05 Nov 2007 09:37:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-11-05T09:37:42Z</dc:date>
    <item>
      <title>casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109060#M76497</link>
      <description>Hello,&lt;BR /&gt;
    I have successfully stored a boolean value into an Xrec using a TypedValue with Type of (int)DxfCode.Bool. &lt;BR /&gt;
   When I retrieve it the value is a 1 or 0 according to whether I had input True of False. So far, so good. The problem is that I am so far unable to cast this TypedValue.Value of 1 or 0 to either a bool or a Boolean or even an int or a long. How do I get that TypedValue.Value that is returned into another variable?&lt;BR /&gt;
   In the attached file what I am referring to is in the method&lt;BR /&gt;
       public bool getBoolVar(string VarName)&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your advice.</description>
      <pubDate>Sun, 04 Nov 2007 17:15:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109060#M76497</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-04T17:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109061#M76498</link>
      <description>You can't cast from an object to an int.&lt;BR /&gt;
&lt;BR /&gt;
You can use Convert.ToInt32(), etc. &lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;RLARXMAN2&gt; wrote in message news:5768864@discussion.autodesk.com...&lt;BR /&gt;
Hello,&lt;BR /&gt;
    I have successfully stored a boolean value into an Xrec using a TypedValue with Type of (int)DxfCode.Bool. &lt;BR /&gt;
   When I retrieve it the value is a 1 or 0 according to whether I had input True of False. So far, so good. The problem is that I am so far unable to cast this TypedValue.Value of 1 or 0 to either a bool or a Boolean or even an int or a long. How do I get that TypedValue.Value that is returned into another variable?&lt;BR /&gt;
   In the attached file what I am referring to is in&lt;BR /&gt;
 the method&lt;BR /&gt;
       public bool getBoolVar(string VarName)&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your advice.&lt;/RLARXMAN2&gt;</description>
      <pubDate>Mon, 05 Nov 2007 09:37:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109061#M76498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-05T09:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109062#M76499</link>
      <description>Hello, thanks for your reply. Well, I did figure out another way in the meantime. I am not sure why it works, but here it is:&lt;BR /&gt;
&lt;BR /&gt;
I take the TypedValue.Value (which is an object), and set it equal to an Object variable. Then I did an explicit cast from there to Int16. Then I did an if-else to see if it was a 1 or 0 and set it True of False accordingly. Seems like a long way around, but I only have to write the code once, and I have.</description>
      <pubDate>Mon, 05 Nov 2007 15:23:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109062#M76499</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-05T15:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109063#M76500</link>
      <description>If result is a boolean, and TypedValue.Value is an object:&lt;BR /&gt;
&lt;BR /&gt;
result = Convert.ToInt32(TypedValue.Value) &amp;lt;&amp;gt; 0&lt;BR /&gt;
&lt;BR /&gt;
Note that the method will throw an exception if the object can't be converted to an integer (it needs to implement IConvertible.ToInt32).</description>
      <pubDate>Tue, 06 Nov 2007 15:44:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/2109063#M76500</guid>
      <dc:creator>jbooth</dc:creator>
      <dc:date>2007-11-06T15:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/6416986#M76501</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;I am in the same issue with DxfCode.Bool, so finally what is the best solution for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am surfing on internet and I don´t find any thread related to this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 14:25:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/6416986#M76501</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2016-07-03T14:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/6417005#M76502</link>
      <description>&lt;P&gt;TypedValue[] tv = xrec.Data.AsArray();&lt;BR /&gt; returnValue = Convert.ToBoolean(tv[0].Value);&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 14:59:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/6417005#M76502</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2016-07-03T14:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: casting from TypedValue with Type = (int)DxfCode.Bool</title>
      <link>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/6417042#M76503</link>
      <description>&lt;P&gt;OK.&lt;/P&gt;
&lt;P&gt;Although I have a bidimensional array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TypedValue tdv2 = variables_globales.matriz[registro, 8]; //bool_BySubentity&lt;BR /&gt; int Bool_BySubentity =Convert.ToInt32(tdv2.Value);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I would have to do at least something to convert it to a single array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With "Convert.ToInt32( )" it seems that it works..&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 16:10:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/casting-from-typedvalue-with-type-int-dxfcode-bool/m-p/6417042#M76503</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2016-07-03T16:10:03Z</dc:date>
    </item>
  </channel>
</rss>

