XML Import and Export - VBA

XML Import and Export - VBA

Anonymous
Not applicable
842 Views
5 Replies
Message 1 of 6

XML Import and Export - VBA

Anonymous
Not applicable
I am starting to look into using XML in conjunction with AutoCAD, and was looking for a little feedback....

I am collecting Various Data in AutoCAD, and populating it into Custom Class Object Types. The end result will be a Object Driven, Hierarchy based file for use in another program.

I have no problem collecting my information and exporting it to a text file. But, I'm thinking that, since it is Hierarchy based in structure, that XML might be the way to go.

I need to start backwards, by reading in an XML File, and populating it into Custom Objects (helps me understand the process better...)

Example would be similar to following:


Name="xxxxx"
Weight="xxxxx"


Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"


Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"





Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"


Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"




Master Node would be the High Level of the Hierarchy, Sub Node would be its Child. The Sub Node is where all of my objects reside (that I will populate into Custom Object Types, based on Type Property….

Any of you experts out there have any insight on getting this XML Format into VBA, before I start tackling it?

Thanks in advance…..

Charles
0 Likes
843 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Apparently you can't post XML based code into the Forum....

Here is the Example again, just in a little differnt logic (not xml)... Sorry for the Re-post...

-MasterNode-
Name = "xxx"
Weight = "xxx"
etc…

-SubNode-
Name = "xxx"
Position = 0,0,0

-Object-
Type = "xxxx"
IDNum = "xxxxx"
Desc = "xxxxx"
Property1 = "xxxxx"
Property2 = "xxxxx"
-EndObject

-Object-
Type = "xxxx"
IDNum = "xxxxx"
Desc = "xxxxx"
Property1 = "xxxxx"
Property2 = "xxxxx"
-EndObject

-EndSubNode-

-SubNode-
Name = "xxx"
Position = 0,0,0

-Object-
Type = "xxxx"
IDNum = "xxxxx"
Desc = "xxxxx"
Property1 = "xxxxx"
Property2 = "xxxxx"
-EndObject

-Object-
Type = "xxxx"
IDNum = "xxxxx"
Desc = "xxxxx"
Property1 = "xxxxx"
Property2 = "xxxxx"
-EndObject

-EndSubNode-

-EndMasterNode
0 Likes
Message 3 of 6

Anonymous
Not applicable
I am also interested in this topic, however I do not have very much knowledge or experiece in this area.....I believe that using .NET (VB.NET), gives you alot more capabilities (built-in functionality)....I am looking at reading external .XML files to bring into AutoCAD to generate Parametric drawings....
0 Likes
Message 4 of 6

Anonymous
Not applicable
I have been working on a LISP program that imports/exports XML data, however, I wrote it to work very specifically with the Schema for the file I created, and is rather crude. I'm also interested in finding out more about this, so that I could perhaps change direction with what I've been working on.
I just recently starting tinkering with ObjectARX and may end up trying out that direction..
0 Likes
Message 5 of 6

Anonymous
Not applicable
You probably should consider looking at .NET
developement for persisting your data in XML.

--
http://www.caddzone.com

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

wrote in message news:4930891@discussion.autodesk.com...
I am starting to look into using XML in conjunction with AutoCAD, and was looking for a little feedback....

I am collecting Various Data in AutoCAD, and populating it into Custom Class Object Types. The end result will be a Object Driven, Hierarchy based file for use in another program.

I have no problem collecting my information and exporting it to a text file. But, I'm thinking that, since it is Hierarchy based in structure, that XML might be the way to go.

I need to start backwards, by reading in an XML File, and populating it into Custom Objects (helps me understand the process better...)

Example would be similar to following:


Name="xxxxx"
Weight="xxxxx"


Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"


Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"





Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"


Type="xxxx"
IDNum="xxxxx"
Desc="xxxxx"
Property1="xxxxx"
Property2="xxxxx"




Master Node would be the High Level of the Hierarchy, Sub Node would be its Child. The Sub Node is where all of my objects reside (that I will populate into Custom Object Types, based on Type Property….

Any of you experts out there have any insight on getting this XML Format into VBA, before I start tackling it?

Thanks in advance…..

Charles
0 Likes
Message 6 of 6

Anonymous
Not applicable
clcotton <> wrote in news:4930891@discussion.autodesk.com:

> I am starting to look into using XML in conjunction with AutoCAD, and
> was looking for a little feedback....
>
> I am collecting Various Data in AutoCAD, and populating it into Custom
> Class Object Types. The end result will be a Object Driven, Hierarchy
> based file for use in another program.
>
> I have no problem collecting my information and exporting it to a text
> file. But, I'm thinking that, since it is Hierarchy based in
> structure, that XML might be the way to go.
>
> I need to start backwards, by reading in an XML File, and populating
> it into Custom Objects (helps me understand the process better...)
>
> Example would be similar to following:
>
>
> Name="xxxxx"
> Weight="xxxxx"
>
>
> Type="xxxx"
> IDNum="xxxxx"
> Desc="xxxxx"
> Property1="xxxxx"
> Property2="xxxxx"
>

>
> Type="xxxx"
> IDNum="xxxxx"
> Desc="xxxxx"
> Property1="xxxxx"
> Property2="xxxxx"
>

>

>
>
>
> Type="xxxx"
> IDNum="xxxxx"
> Desc="xxxxx"
> Property1="xxxxx"
> Property2="xxxxx"
>

>
> Type="xxxx"
> IDNum="xxxxx"
> Desc="xxxxx"
> Property1="xxxxx"
> Property2="xxxxx"
>

>

>

>
> Master Node would be the High Level of the Hierarchy, Sub Node would
> be its Child. The Sub Node is where all of my objects reside (that I
> will populate into Custom Object Types, based on Type Property….
>
> Any of you experts out there have any insight on getting this XML
> Format into VBA, before I start tackling it?
>
> Thanks in advance…..
>
> Charles

You can read/write XML files by setting a reference to
Microsoft XML. I attached a class module that demonstrates writing an xml
file.

'****************************************
Sub MainExportXML()
On Error GoTo Proc_error
' Attributes or Nodes?
' cXML.CreateChild oParentNode, "Name", "Value"
' OR
' oParentNode.setAttribute "Type", "XXXX"
Dim cXML As clsXMLWriter
Dim oSubNode As IXMLDOMElement
Dim oObject As IXMLDOMElement
Dim I, X As Integer

Set cXML = New clsXMLWriter

With cXML
.LoadFile = False
.RootElement = "MasterNode"
.CreateChild .RootNode, "Name", "XXXX"
.CreateChild .RootNode, "Weight", "XXXX"
End With

For X = 1 To 5
Set oSubNode = cXML.CreateNode(cXML.RootNode, "SubNode")
cXML.CreateChild oSubNode, "ID", CStr(X)
cXML.CreateChild oSubNode, "Name", "X" & X
cXML.CreateChild oSubNode, "Position", "PositionX"
For I = 1 To 3
Set oObject = cXML.CreateNode(oSubNode, "Object")
cXML.CreateChild oObject, "ID", X & ":" & I
cXML.CreateChild oObject, "Type", "XXXX"
cXML.CreateChild oObject, "IDNum", "XXXX"
cXML.CreateChild oObject, "Desc", "XXXX"
cXML.CreateChild oObject, "Property1", "XXXX"
Next I
Next X
cXML.XMLDOC.Save "C:\Temp\Autocad.xml"
Proc_Exit:
If Not cXML Is Nothing Then Set cXML = Nothing
Exit Sub
Proc_error:
MsgBox Err.Description
Resume Proc_Exit
End Sub
'****************************************

- Jose
0 Likes