aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--Virtools/3dxml.py45
2 files changed, 43 insertions, 9 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7686e2e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+Random thingies, reinvented wheels and other stuff.
+
+These fall into the "works for me" category. Even though they may have been out
+of maintenance, they _at least_ worked for me **once**.
+
+No warranty or support is provided for the files stored in this repository
+whatsoever, unless otherwise stated elsewhere.
diff --git a/Virtools/3dxml.py b/Virtools/3dxml.py
index 5846497..149d9c6 100644
--- a/Virtools/3dxml.py
+++ b/Virtools/3dxml.py
@@ -1,14 +1,39 @@
-#Chris Xiong 2018
-#Expat (MIT) License
+# Chris Xiong 2018
+# Expat (MIT) License
bl_info={
- "name":"3DXML (3.0) import",
- "description":"Import 3DXML 3.0",
+ "name":"3D XML (3.0) import",
+ "description":"Import 3D XML 3.0",
"author":"Chris Xiong",
"version":(0,1),
"blender":(2,79,0),
"category":"Import-Export",
"support":"TESTING"
}
+################################################################
+# This addon enables blender to import 3D XML 3.0 documents.
+# It partially implemented the 3D XML specification 3.0 from
+# Dassault Systèmes. Testing was done with files exported
+# from 3DVIA Virtools 5.0.
+#
+# The development took place solely on Linux. It may experience
+# problems on other platforms.
+#
+# This addon started off as a fork of this script:
+# https://www.blender.org/forum/viewtopic.php?t=18299
+# Later it was rewritten from scratch to better reflect the
+# specification.
+#
+# To report bugs, mail me a minimal 3D XML file that can
+# reproduce the issue together with the details of the bug.
+#
+# References:
+# 1) 3D XML Reference Documentation 3.0:
+# http://media.3ds.com/3dxml/3dxmldoc/Reference_Guide/3DXML_Reference_Guide.html
+# 2) 3D XML 3.0 XSD schema:
+# http://media.3ds.com/3dxml/3dxmldoc/3DXML.xsd
+# 3) 3D XML User's Guide 3.0:
+# http://media.3ds.com/3dxml/3dxmldoc/3DXML_User_Guide.pdf
+################################################################
import bpy,bmesh,bpy_extras,mathutils
import xml.etree.ElementTree as etree
import pathlib,zipfile,time,os,tempfile
@@ -109,10 +134,10 @@ def load_objects(tree):
obj.select=True
bpy.ops.object.shade_smooth()
-def create_mesh(verts,faces,facemat,uvs,objidx):
+def create_mesh(verts,faces,facemat,uvs,meshidx):
if len(uvs)>len(verts):
uvs.append([uvs[0]]*(len(verts)-len(uvs)))
- objname=f"Mesh_{objidx}"
+ meshname=f"Mesh_{meshidx}"
mesh=bmesh.new()
for i in verts:
mesh.verts.new(i)
@@ -129,10 +154,10 @@ def create_mesh(verts,faces,facemat,uvs,objidx):
for face in mesh.faces:
for lp in face.loops:
lp[uv].uv=mathutils.Vector(uvs[lp.vert.index])
- msh=bpy.data.meshes.new(objname)
+ msh=bpy.data.meshes.new(meshname)
mesh.to_mesh(msh)
msh.use_auto_smooth=True
- meshes[objidx]=msh
+ meshes[meshidx]=msh
mesh.free()
def unflatten(seq,func,step,fac=1):
@@ -149,7 +174,7 @@ def read(filename):
try:
member=zf.namelist().index("Root.3dxml")
except ValueError:
- print("not a 3DXML 3.0 file!")
+ raise RuntimeError("not a 3D XML 3.0 file!")
filename=zf.open("Root.3dxml")
for im in zf.namelist():
if im.endswith(".tga"):
@@ -158,6 +183,8 @@ def read(filename):
tf.flush()
texturefiles[im]=tf.name
tf.close()
+ else:
+ print("Warning: the file will be treated as a bare XML document.")
tree=etree.parse(filename)
load_textures(tree)
load_materials(tree)