Importing XML / text as geometry

The structural analysis program Dr. Frame 2D exports the model geometry as an “.XML” which reads as a .txt in windows explorer. I want to use GH/Pancake to read the XML and generate the geometry from Dr. Frame.

Here’s the output…

<?xml version="1.0" ?>
<DrFrameGeometry1a>
	<Units>
	<LengthUnit>ft</LengthUnit>
	</Units>
	<JointList>
		<Joint>
			<xyzLoc>12 24</xyzLoc>
			<ID>1</ID>
		</Joint>
		<Joint>
			<xyzLoc>0 12</xyzLoc>
			<ID>2</ID>
		</Joint>
		<Joint>
			<xyzLoc>12 12</xyzLoc>
			<ID>3</ID>
		</Joint>
		<Joint>
			<xyzLoc>12 0</xyzLoc>
			<ID>4</ID>
		</Joint>
		<Joint>
			<xyzLoc>0 0</xyzLoc>
			<ID>5</ID>
		</Joint>
	</JointList>
	<MemberList>
		<Member>
			<EndJoints>3 1</EndJoints>
			<EndFixity>fixed-fixed</EndFixity>
		</Member>
		<Member>
			<EndJoints>2 1</EndJoints>
			<EndFixity>fixed-fixed</EndFixity>
		</Member>
		<Member>
			<EndJoints>5 3</EndJoints>
			<EndFixity>fixed-fixed</EndFixity>
		</Member>
		<Member>
			<EndJoints>4 3</EndJoints>
			<EndFixity>fixed-fixed</EndFixity>
		</Member>
		<Member>
			<EndJoints>2 3</EndJoints>
			<EndFixity>fixed-fixed</EndFixity>
		</Member>
		<Member>
			<EndJoints>5 2</EndJoints>
			<EndFixity>fixed-fixed</EndFixity>
		</Member>
	</MemberList>
	<SupportList>
		<Support>
			<atJoint>4</atJoint>
			<Fixity>pinned</Fixity>
		</Support>
		<Support>
			<atJoint>5</atJoint>
			<Fixity>pinned</Fixity>
		</Support>
	</SupportList>
</DrFrameGeometry1a>

Is this possible? I consulted the pancake documentation but there is not a lot of information about XML import specifically. Does anybody have an idea as to the extent of additional scripting required to realize this import scheme?

Thanks

Do you have a picture what kind of structure this xml represents?

It’s completely possible to read in the xml and parse the information into geometry. But there seems to be very limited amount of data in the file.

the text file I posted is the export from this model

Hi @ct.rhino ,
Here is a python component which reads the previously shown .xml file.
Current limitation: your Rhino units must be the same as the units in the .xml file. But this can also be fixed.
I tested it on Rhino 6.

Dr_Frame_xml_reader.gh (11.4 KB)
Dr_Frame_truss.xml (1.2 KB)

3 Likes

some notes: Pancake can import XML data associations but it’s leaving you to parse the imported data.

1 Like

pancake_xml.gh (16.1 KB)

2 Likes

What would need to be changed so this runs in the new editor with Python 3?

Dr_Frame_xml_reader_8.gh (13.7 KB)

getchildren is deprecated in 3.9. You may use iteration.

1 Like