<?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 Assigning a user-defined type to a variant - an idea for better XData in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352307#M74744</link>
    <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
To set the tone:  I'm very experienced in VB, reasonably experienced in VBA,&lt;BR /&gt;
and a newbie to AutoCAD (2002).&lt;BR /&gt;
&lt;BR /&gt;
I like the idea of XData, but don't like the idea of having to remember what&lt;BR /&gt;
thing is in what element (eg woodgrain is in XData(7)).  So I had the idea&lt;BR /&gt;
of using the XDataType 1004 (Binary Data) to hold a variant that holds a&lt;BR /&gt;
user-defined type that I can structure however I like!  (Notwithstanding the&lt;BR /&gt;
127-byte limit for Binary data types.)&lt;BR /&gt;
&lt;BR /&gt;
I tried something like this (simplified for this example):&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
&lt;BR /&gt;
Private Type LineXDataType&lt;BR /&gt;
    AutoGenerated as Boolean&lt;BR /&gt;
    WoodStyle as Integer&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
Sub Whatever()&lt;BR /&gt;
    Dim LineObj(10) as AcadLine&lt;BR /&gt;
    Dim pt1(0 to 2) as Double, pt2(0 to 2) as Double&lt;BR /&gt;
    Dim XDataType(0 To 1) As Integer, XData(0 To 1) As Variant, LineXData As&lt;BR /&gt;
LineXDataType&lt;BR /&gt;
&lt;BR /&gt;
    pt1(0) = 0: pt1(1) = 0: pt1(2) = 0&lt;BR /&gt;
    pt2(0) = 3: pt2(1) = 5: pt2(2) = 0&lt;BR /&gt;
    Set LineObj(1) = ThisDrawing.ModelSpace.AddLine(pt1, pt2)&lt;BR /&gt;
    LineXData.AutoGenerated = False&lt;BR /&gt;
    LineXData.WoodStyle = 3&lt;BR /&gt;
    XDataType(0) = 1001: XData(0) = "MyProject"&lt;BR /&gt;
    XDataType(1) = 1004: XData(1) = LineXData&lt;BR /&gt;
    LineObj(1).SetXData XDataType, XData&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
However the compiler highlighted the statement "XData(1) = LineXData" and&lt;BR /&gt;
gave the following error message:&lt;BR /&gt;
&lt;BR /&gt;
    Compile error:  Only user-defined types defined in public object modules&lt;BR /&gt;
can be coerced to or from a variant or passed to late-bound functions&lt;BR /&gt;
&lt;BR /&gt;
Now I know that previously variants could not hold a user-defined type, but&lt;BR /&gt;
that is supposedly no longer the case.  Placing the cursor on the keyword&lt;BR /&gt;
"Variant" in VBA and pressing F1 gives the help topic "Variant Data Type",&lt;BR /&gt;
the second paragraph of which states:&lt;BR /&gt;
&lt;BR /&gt;
    A Variant is a special data type that can contain any kind of data&lt;BR /&gt;
except fixed-length String data. (Variant types now support user-defined&lt;BR /&gt;
types.)&lt;BR /&gt;
&lt;BR /&gt;
So why am I getting this error?  Based on the context of the error message I&lt;BR /&gt;
tried moving the Type declaration and the Dim statements for the XData&lt;BR /&gt;
variables to a module and making them Public but it didn't make any&lt;BR /&gt;
difference.&lt;BR /&gt;
&lt;BR /&gt;
If anyone can shed some insight as to what is happening here would have my&lt;BR /&gt;
sincere appreciation.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Wayne Ivory&lt;BR /&gt;
Wespine Industries Pty Ltd</description>
    <pubDate>Tue, 23 Apr 2002 22:15:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2002-04-23T22:15:09Z</dc:date>
    <item>
      <title>Assigning a user-defined type to a variant - an idea for better XData</title>
      <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352307#M74744</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
To set the tone:  I'm very experienced in VB, reasonably experienced in VBA,&lt;BR /&gt;
and a newbie to AutoCAD (2002).&lt;BR /&gt;
&lt;BR /&gt;
I like the idea of XData, but don't like the idea of having to remember what&lt;BR /&gt;
thing is in what element (eg woodgrain is in XData(7)).  So I had the idea&lt;BR /&gt;
of using the XDataType 1004 (Binary Data) to hold a variant that holds a&lt;BR /&gt;
user-defined type that I can structure however I like!  (Notwithstanding the&lt;BR /&gt;
127-byte limit for Binary data types.)&lt;BR /&gt;
&lt;BR /&gt;
I tried something like this (simplified for this example):&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
&lt;BR /&gt;
Private Type LineXDataType&lt;BR /&gt;
    AutoGenerated as Boolean&lt;BR /&gt;
    WoodStyle as Integer&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
Sub Whatever()&lt;BR /&gt;
    Dim LineObj(10) as AcadLine&lt;BR /&gt;
    Dim pt1(0 to 2) as Double, pt2(0 to 2) as Double&lt;BR /&gt;
    Dim XDataType(0 To 1) As Integer, XData(0 To 1) As Variant, LineXData As&lt;BR /&gt;
LineXDataType&lt;BR /&gt;
&lt;BR /&gt;
    pt1(0) = 0: pt1(1) = 0: pt1(2) = 0&lt;BR /&gt;
    pt2(0) = 3: pt2(1) = 5: pt2(2) = 0&lt;BR /&gt;
    Set LineObj(1) = ThisDrawing.ModelSpace.AddLine(pt1, pt2)&lt;BR /&gt;
    LineXData.AutoGenerated = False&lt;BR /&gt;
    LineXData.WoodStyle = 3&lt;BR /&gt;
    XDataType(0) = 1001: XData(0) = "MyProject"&lt;BR /&gt;
    XDataType(1) = 1004: XData(1) = LineXData&lt;BR /&gt;
    LineObj(1).SetXData XDataType, XData&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
However the compiler highlighted the statement "XData(1) = LineXData" and&lt;BR /&gt;
gave the following error message:&lt;BR /&gt;
&lt;BR /&gt;
    Compile error:  Only user-defined types defined in public object modules&lt;BR /&gt;
can be coerced to or from a variant or passed to late-bound functions&lt;BR /&gt;
&lt;BR /&gt;
Now I know that previously variants could not hold a user-defined type, but&lt;BR /&gt;
that is supposedly no longer the case.  Placing the cursor on the keyword&lt;BR /&gt;
"Variant" in VBA and pressing F1 gives the help topic "Variant Data Type",&lt;BR /&gt;
the second paragraph of which states:&lt;BR /&gt;
&lt;BR /&gt;
    A Variant is a special data type that can contain any kind of data&lt;BR /&gt;
except fixed-length String data. (Variant types now support user-defined&lt;BR /&gt;
types.)&lt;BR /&gt;
&lt;BR /&gt;
So why am I getting this error?  Based on the context of the error message I&lt;BR /&gt;
tried moving the Type declaration and the Dim statements for the XData&lt;BR /&gt;
variables to a module and making them Public but it didn't make any&lt;BR /&gt;
difference.&lt;BR /&gt;
&lt;BR /&gt;
If anyone can shed some insight as to what is happening here would have my&lt;BR /&gt;
sincere appreciation.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Wayne Ivory&lt;BR /&gt;
Wespine Industries Pty Ltd</description>
      <pubDate>Tue, 23 Apr 2002 22:15:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352307#M74744</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-04-23T22:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning a user-defined type to a variant - an idea for better XData</title>
      <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352308#M74745</link>
      <description>I'm not even sure what you're trying to do is&lt;BR /&gt;
possible, but if it is, it's not a wise thing&lt;BR /&gt;
to do.&lt;BR /&gt;
&lt;BR /&gt;
Let's suppose for a moment, that your program is&lt;BR /&gt;
written and currently in use, and at some point,&lt;BR /&gt;
it becomes necessary to add some additional data&lt;BR /&gt;
or change the format of the existing persistent&lt;BR /&gt;
data that you store in each entity's Xdata.&lt;BR /&gt;
&lt;BR /&gt;
In that case, there may be cases where a drawing&lt;BR /&gt;
will contain entities with Xdata that contain older&lt;BR /&gt;
versions of the data structure. Given that, how&lt;BR /&gt;
would you propose detecting which version of the&lt;BR /&gt;
data structure is stored in the binary data that's&lt;BR /&gt;
attached to each entity?&lt;BR /&gt;
&lt;BR /&gt;
Furthermore, if you change the structure of your&lt;BR /&gt;
user-defined data type, it will become impossible&lt;BR /&gt;
to read existing data written using older versions&lt;BR /&gt;
of the same data structure.&lt;BR /&gt;
&lt;BR /&gt;
And, here is what you will end up having to do:&lt;BR /&gt;
&lt;BR /&gt;
Private Type LineXDataType&lt;BR /&gt;
    AutoGenerated as Boolean&lt;BR /&gt;
    WoodStyle as Integer&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
' First revision of your application&lt;BR /&gt;
' adds one persistent field&lt;BR /&gt;
&lt;BR /&gt;
Private Type LineXDataType2&lt;BR /&gt;
    AutoGenerated as Boolean&lt;BR /&gt;
    WoodStyle as Integer&lt;BR /&gt;
    SomeNewField1 As SomeType&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
' Second revision of your application&lt;BR /&gt;
' adds another persistent field&lt;BR /&gt;
&lt;BR /&gt;
Private Type LineXDataType3&lt;BR /&gt;
    AutoGenerated as Boolean&lt;BR /&gt;
    WoodStyle as Integer&lt;BR /&gt;
    SomeNewField1 As SomeType&lt;BR /&gt;
    SomeNewField2 As SomeOtherType&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
Because what you are proposing to do breaks a basic&lt;BR /&gt;
rule of software engineering (data binding), you may&lt;BR /&gt;
be forced to use different user-defined types for&lt;BR /&gt;
each revision of your persistent data format, and&lt;BR /&gt;
that will in-turn, require you to revise every other&lt;BR /&gt;
part of your code that uses those types, even if the&lt;BR /&gt;
code is not directly affected by the change in the&lt;BR /&gt;
persistent data format.&lt;BR /&gt;
&lt;BR /&gt;
Can you see where this is going ?&lt;BR /&gt;
&lt;BR /&gt;
By making the format of your persistent data&lt;BR /&gt;
opaque, you also surrender the ability to easily&lt;BR /&gt;
manage and handle multiple versions of your data&lt;BR /&gt;
structure, which means that you will be setting&lt;BR /&gt;
yourself up for major problems if you must change&lt;BR /&gt;
the format of your persistent data in the future.&lt;BR /&gt;
&lt;BR /&gt;
My advice is to forget about storing your data&lt;BR /&gt;
structure in the entity in binary format. Instead,&lt;BR /&gt;
create a reader and writer function that takes an&lt;BR /&gt;
instance of your data structure, and an entity,&lt;BR /&gt;
and reads/writes data between the XData and your&lt;BR /&gt;
data structure.&lt;BR /&gt;
&lt;BR /&gt;
If you do this, then you will have only two functions&lt;BR /&gt;
that must deal with the format of the XData, and the&lt;BR /&gt;
balance of your code doesn't have to know anything&lt;BR /&gt;
about how the data is stored in the Entity.&lt;BR /&gt;
&lt;BR /&gt;
More importantly, this will allow you to revise the&lt;BR /&gt;
format of the persistent data, and deal with the&lt;BR /&gt;
change without a major upheaval of your code, since&lt;BR /&gt;
it will only require you to revise the reader function&lt;BR /&gt;
to detect and handle newer versions of the data format,&lt;BR /&gt;
and will allow you to use and revise a single user-&lt;BR /&gt;
defined type.&lt;BR /&gt;
&lt;BR /&gt;
In the writer function, include a version sentinel&lt;BR /&gt;
as the first element in the Xdata (an integer or&lt;BR /&gt;
short will do). That version sentinel can then be&lt;BR /&gt;
used by the reader function to determine the version&lt;BR /&gt;
of the data structure stored in each entity's Xdata,&lt;BR /&gt;
so that if the structure of the persistent data were&lt;BR /&gt;
to change in the future, the change can be handled&lt;BR /&gt;
in a way that is transparent to the remainder of&lt;BR /&gt;
your application.&lt;BR /&gt;
&lt;BR /&gt;
"Wayne Ivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
news:C340F5B6E1346426BB9B6C8304459922@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Hi all,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; To set the tone:  I'm very experienced in VB, reasonably experienced in&lt;BR /&gt;
VBA,&lt;BR /&gt;
&amp;gt; and a newbie to AutoCAD (2002).&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I like the idea of XData, but don't like the idea of having to remember&lt;BR /&gt;
what&lt;BR /&gt;
&amp;gt; thing is in what element (eg woodgrain is in XData(7)).  So I had the idea&lt;BR /&gt;
&amp;gt; of using the XDataType 1004 (Binary Data) to hold a variant that holds a&lt;BR /&gt;
&amp;gt; user-defined type that I can structure however I like!  (Notwithstanding&lt;BR /&gt;
the&lt;BR /&gt;
&amp;gt; 127-byte limit for Binary data types.)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I tried something like this (simplified for this example):&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Option Explicit&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Private Type LineXDataType&lt;BR /&gt;
&amp;gt;     AutoGenerated as Boolean&lt;BR /&gt;
&amp;gt;     WoodStyle as Integer&lt;BR /&gt;
&amp;gt; End Type&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Sub Whatever()&lt;BR /&gt;
&amp;gt;     Dim LineObj(10) as AcadLine&lt;BR /&gt;
&amp;gt;     Dim pt1(0 to 2) as Double, pt2(0 to 2) as Double&lt;BR /&gt;
&amp;gt;     Dim XDataType(0 To 1) As Integer, XData(0 To 1) As Variant, LineXData&lt;BR /&gt;
As&lt;BR /&gt;
&amp;gt; LineXDataType&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     pt1(0) = 0: pt1(1) = 0: pt1(2) = 0&lt;BR /&gt;
&amp;gt;     pt2(0) = 3: pt2(1) = 5: pt2(2) = 0&lt;BR /&gt;
&amp;gt;     Set LineObj(1) = ThisDrawing.ModelSpace.AddLine(pt1, pt2)&lt;BR /&gt;
&amp;gt;     LineXData.AutoGenerated = False&lt;BR /&gt;
&amp;gt;     LineXData.WoodStyle = 3&lt;BR /&gt;
&amp;gt;     XDataType(0) = 1001: XData(0) = "MyProject"&lt;BR /&gt;
&amp;gt;     XDataType(1) = 1004: XData(1) = LineXData&lt;BR /&gt;
&amp;gt;     LineObj(1).SetXData XDataType, XData&lt;BR /&gt;
&amp;gt; End Sub&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; However the compiler highlighted the statement "XData(1) = LineXData" and&lt;BR /&gt;
&amp;gt; gave the following error message:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Compile error:  Only user-defined types defined in public object&lt;BR /&gt;
modules&lt;BR /&gt;
&amp;gt; can be coerced to or from a variant or passed to late-bound functions&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Now I know that previously variants could not hold a user-defined type,&lt;BR /&gt;
but&lt;BR /&gt;
&amp;gt; that is supposedly no longer the case.  Placing the cursor on the keyword&lt;BR /&gt;
&amp;gt; "Variant" in VBA and pressing F1 gives the help topic "Variant Data Type",&lt;BR /&gt;
&amp;gt; the second paragraph of which states:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     A Variant is a special data type that can contain any kind of data&lt;BR /&gt;
&amp;gt; except fixed-length String data. (Variant types now support user-defined&lt;BR /&gt;
&amp;gt; types.)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; So why am I getting this error?  Based on the context of the error message&lt;BR /&gt;
I&lt;BR /&gt;
&amp;gt; tried moving the Type declaration and the Dim statements for the XData&lt;BR /&gt;
&amp;gt; variables to a module and making them Public but it didn't make any&lt;BR /&gt;
&amp;gt; difference.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; If anyone can shed some insight as to what is happening here would have my&lt;BR /&gt;
&amp;gt; sincere appreciation.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Thanks&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Wayne Ivory&lt;BR /&gt;
&amp;gt; Wespine Industries Pty Ltd&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/WAYNEI&gt;</description>
      <pubDate>Wed, 24 Apr 2002 03:19:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352308#M74745</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-04-24T03:19:02Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352309#M74746</link>
      <description>Thanks for your comprehensive reply Tony.  Everything you say is true,&lt;BR /&gt;
however the nature of what I'm doing is such that the points you raise are&lt;BR /&gt;
not an issue for me.  The XData that I intend to use in this code will only&lt;BR /&gt;
"live" for the duration of the code execution, ie as soon as the code&lt;BR /&gt;
finishes the drawing will be complete and the XData will no longer be&lt;BR /&gt;
needed.  I'm only using it as a means for the code to keep track of a few&lt;BR /&gt;
things while it is running.  I could (and am currently since I can't get the&lt;BR /&gt;
XData working) run parallel simple variables alongside the object variables&lt;BR /&gt;
to keep track of all the stuff but this seems inefficient when I&lt;BR /&gt;
theoretically can store stuff with it's related object.&lt;BR /&gt;
&lt;BR /&gt;
So to reiterate, if you or anyone else can explain why VBA won't let the&lt;BR /&gt;
variant receive the user-defined type in my example I'd be very&lt;BR /&gt;
appreciative.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Wayne Ivory&lt;BR /&gt;
Wespine Industries Pty Ltd&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO at="" caddzone="" dot="" com=""&gt; wrote in message&lt;BR /&gt;
news:5A0E43DBC294B663140AF3B869E33B19@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; I'm not even sure what you're trying to do is&lt;BR /&gt;
&amp;gt; possible, but if it is, it's not a wise thing&lt;BR /&gt;
&amp;gt; to do.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;/TONY.TANZILLO&gt;</description>
      <pubDate>Thu, 25 Apr 2002 22:35:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352309#M74746</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-04-25T22:35:10Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352310#M74747</link>
      <description>Wayne, I don't exactly have an answer for your XData question. It looks to&lt;BR /&gt;
me like the documentation may be incorrect. However it seems like using&lt;BR /&gt;
XData to hold data that you do not need to persist longer than code&lt;BR /&gt;
execution is unnecessary. Why not just define a class with properties for&lt;BR /&gt;
information you want to store? Just now I'm wondering if you created your&lt;BR /&gt;
type in a class and tried to coerece it into a variant as a property of the&lt;BR /&gt;
class if it would work... just a thought, but again I'd just drop the whole&lt;BR /&gt;
XData issue and go with the class.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
  Jacob Dinardi&lt;BR /&gt;
&lt;BR /&gt;
"Wayne Ivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
news:F29E36D716226A1F48B73D6B0859DA19@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Thanks for your comprehensive reply Tony.  Everything you say is true,&lt;BR /&gt;
&amp;gt; however the nature of what I'm doing is such that the points you raise are&lt;BR /&gt;
&amp;gt; not an issue for me.  The XData that I intend to use in this code will&lt;BR /&gt;
only&lt;BR /&gt;
&amp;gt; "live" for the duration of the code execution, ie as soon as the code&lt;BR /&gt;
&amp;gt; finishes the drawing will be complete and the XData will no longer be&lt;BR /&gt;
&amp;gt; needed.  I'm only using it as a means for the code to keep track of a few&lt;BR /&gt;
&amp;gt; things while it is running.  I could (and am currently since I can't get&lt;BR /&gt;
the&lt;BR /&gt;
&amp;gt; XData working) run parallel simple variables alongside the object&lt;BR /&gt;
variables&lt;BR /&gt;
&amp;gt; to keep track of all the stuff but this seems inefficient when I&lt;BR /&gt;
&amp;gt; theoretically can store stuff with it's related object.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; So to reiterate, if you or anyone else can explain why VBA won't let the&lt;BR /&gt;
&amp;gt; variant receive the user-defined type in my example I'd be very&lt;BR /&gt;
&amp;gt; appreciative.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Thanks&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Wayne Ivory&lt;BR /&gt;
&amp;gt; Wespine Industries Pty Ltd&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; "Tony Tanzillo" &lt;TONY.TANZILLO at="" caddzone="" dot="" com=""&gt; wrote in message&lt;BR /&gt;
&amp;gt; news:5A0E43DBC294B663140AF3B869E33B19@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; &amp;gt; I'm not even sure what you're trying to do is&lt;BR /&gt;
&amp;gt; &amp;gt; possible, but if it is, it's not a wise thing&lt;BR /&gt;
&amp;gt; &amp;gt; to do.&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; .&lt;BR /&gt;
&amp;gt; .&lt;BR /&gt;
&amp;gt; .&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/TONY.TANZILLO&gt;&lt;/WAYNEI&gt;</description>
      <pubDate>Fri, 26 Apr 2002 06:35:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352310#M74747</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-04-26T06:35:31Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352311#M74748</link>
      <description>"Wayne Ivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
news:F29E36D716226A1F48B73D6B0859DA19@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Thanks for your comprehensive reply Tony.  Everything you say is true,&lt;BR /&gt;
&amp;gt; however the nature of what I'm doing is such that the points you raise are&lt;BR /&gt;
&amp;gt; not an issue for me.  The XData that I intend to use in this code will&lt;BR /&gt;
only&lt;BR /&gt;
&amp;gt; "live" for the duration of the code execution, ie as soon as the code&lt;BR /&gt;
&amp;gt; finishes the drawing will be complete and the XData will no longer be&lt;BR /&gt;
&amp;gt; needed.  I'm only using it as a means for the code to keep track of a few&lt;BR /&gt;
&amp;gt; things while it is running.  I could (and am currently since I can't get&lt;BR /&gt;
the&lt;BR /&gt;
&amp;gt; XData working) run parallel simple variables alongside the object&lt;BR /&gt;
variables&lt;BR /&gt;
&amp;gt; to keep track of all the stuff but this seems inefficient when I&lt;BR /&gt;
&amp;gt; theoretically can store stuff with it's related object.&lt;BR /&gt;
&lt;BR /&gt;
On the contrary. Storing information in memory or program variables&lt;BR /&gt;
is vastly more efficient than storing it in XData.&lt;BR /&gt;
&lt;BR /&gt;
XData is stored in a drawing. Modifying it is just like modifying&lt;BR /&gt;
any other entity data, and that means that AutoCAD must store the&lt;BR /&gt;
changes made to Xdata in the undo file (because changes made to&lt;BR /&gt;
Xdata is "undoable" just like any other entity data).&lt;BR /&gt;
&lt;BR /&gt;
While you may not see all that is going on behind the scenes when&lt;BR /&gt;
you write Xdata to a drawing, trust me when I tell you that it is&lt;BR /&gt;
certainly *NOT* efficient, in contrast to doing the same using&lt;BR /&gt;
in-memory program variables.&lt;BR /&gt;
&lt;BR /&gt;
Unless you actually want your entity specific data to be 'undoable',&lt;BR /&gt;
along with other changes to the entity (which may be a legitimate&lt;BR /&gt;
requirement), then doing it in memory is far more efficient than&lt;BR /&gt;
using XData.&lt;BR /&gt;
&lt;BR /&gt;
If your data is entity specific, then consider a collection of a&lt;BR /&gt;
class that includes a data member that ties each instance of the&lt;BR /&gt;
class to a given entity (perhaps using its object id). That would&lt;BR /&gt;
be far more efficient than the use of XData.&lt;/WAYNEI&gt;</description>
      <pubDate>Fri, 26 Apr 2002 08:23:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352311#M74748</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-04-26T08:23:50Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352312#M74749</link>
      <description>Thanks Jacob and Tony.  I've been using Visual Basic since the VB3 days&lt;BR /&gt;
which was before classes.  I've managed to avoid having to teach myself&lt;BR /&gt;
about them up until now but it seems I have to pull my finger out now which&lt;BR /&gt;
is probably a good thing.  Thanks for the push in the right direction.&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Wane Ivory&lt;BR /&gt;
Wespine Industries Pty Ltd&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO at="" caddzone="" dot="" com=""&gt; wrote in message&lt;BR /&gt;
news:2F68B432D960A71652AA72364A274F1E@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; "Wayne Ivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
&amp;gt; news:F29E36D716226A1F48B73D6B0859DA19@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; &amp;gt; Thanks for your comprehensive reply Tony.  Everything you say is true,&lt;BR /&gt;
&amp;gt; &amp;gt; however the nature of what I'm doing is such that the points you raise&lt;BR /&gt;
are&lt;BR /&gt;
&amp;gt; &amp;gt; not an issue for me.  The XData that I intend to use in this code will&lt;BR /&gt;
&amp;gt; only&lt;BR /&gt;
&amp;gt; &amp;gt; "live" for the duration of the code execution, ie as soon as the code&lt;BR /&gt;
&amp;gt; &amp;gt; finishes the drawing will be complete and the XData will no longer be&lt;BR /&gt;
&amp;gt; &amp;gt; needed.  I'm only using it as a means for the code to keep track of a&lt;BR /&gt;
few&lt;BR /&gt;
&amp;gt; &amp;gt; things while it is running.  I could (and am currently since I can't get&lt;BR /&gt;
&amp;gt; the&lt;BR /&gt;
&amp;gt; &amp;gt; XData working) run parallel simple variables alongside the object&lt;BR /&gt;
&amp;gt; variables&lt;BR /&gt;
&amp;gt; &amp;gt; to keep track of all the stuff but this seems inefficient when I&lt;BR /&gt;
&amp;gt; &amp;gt; theoretically can store stuff with it's related object.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; On the contrary. Storing information in memory or program variables&lt;BR /&gt;
&amp;gt; is vastly more efficient than storing it in XData.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; XData is stored in a drawing. Modifying it is just like modifying&lt;BR /&gt;
&amp;gt; any other entity data, and that means that AutoCAD must store the&lt;BR /&gt;
&amp;gt; changes made to Xdata in the undo file (because changes made to&lt;BR /&gt;
&amp;gt; Xdata is "undoable" just like any other entity data).&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; While you may not see all that is going on behind the scenes when&lt;BR /&gt;
&amp;gt; you write Xdata to a drawing, trust me when I tell you that it is&lt;BR /&gt;
&amp;gt; certainly *NOT* efficient, in contrast to doing the same using&lt;BR /&gt;
&amp;gt; in-memory program variables.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Unless you actually want your entity specific data to be 'undoable',&lt;BR /&gt;
&amp;gt; along with other changes to the entity (which may be a legitimate&lt;BR /&gt;
&amp;gt; requirement), then doing it in memory is far more efficient than&lt;BR /&gt;
&amp;gt; using XData.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; If your data is entity specific, then consider a collection of a&lt;BR /&gt;
&amp;gt; class that includes a data member that ties each instance of the&lt;BR /&gt;
&amp;gt; class to a given entity (perhaps using its object id). That would&lt;BR /&gt;
&amp;gt; be far more efficient than the use of XData.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/WAYNEI&gt;&lt;/TONY.TANZILLO&gt;</description>
      <pubDate>Sun, 28 Apr 2002 18:31:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/assigning-a-user-defined-type-to-a-variant-an-idea-for-better/m-p/352312#M74749</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-04-28T18:31:39Z</dc:date>
    </item>
  </channel>
</rss>

