XML import, positions and rotations

(lynchon) #1


I have a very small challenge for anyone good with python, i’m trying to import some points from a xml file with this structure:

<Sector id=“S_128” lodValue="" rampValue=“Ramp02”>
<Seat name=“S_128-14-1” prefab=“M-Seat-01-255” px=“22.627” py=“4.35” pz="-25.021" rx=“0” ry=“0” rz=“0” />
<Seat name=“S_128-14-2” prefab=“M-Seat-01-255” px=“23.155” py=“4.35” pz="-25.021" rx=“0” ry=“0” rz=“0” />
<Seat name=“S_128-14-3” prefab=“M-Seat-01-255” px=“23.684” py=“4.35” pz="-25.021" rx=“0” ry=“0” rz=“0” />
<Seat name=“S_128-14-4” prefab=“M-Seat-01-255” px=“24.212” py=“4.35” pz="-25.021" rx=“0” ry=“0” rz=“0” />

What i need is to import the px,py,pz,rx,ry,and rz atributes as position and rotation values in order to place instanced objects on them.

I’m not sure if its better to use particles or dupli vertex or any other solution so if anyone has the time to give some advice or helping with the script i would really apreciate it.

I must say i’m an experienced user in blender but never had the time for coding so please excuse me if i’m not making myself clear.

Thanks in advance

(nBurn) #2

Not sure about that example XML data. Python has a built in XML library that might be able to do the job, but I don’t have any experience with it:

Another option might be Python’s CSV parser or the regular expression library.

I’m not familiar with doing instantiated objects or assigning rotations, but I don’t think it would be too different from assigning location values to regular objects. For the location data you would be looking at something like:

bpy.context.scene.objects[0].location = Vector((px, py, pz))

(lynchon) #3

yes seems pretty easy if you know how to code.

I’ll keep the link as i am starting a course on Python, this has to end i need to be able to talk to developers in some way. Once i get to some point i’ll write back.

Thanks for the info.