Archived

This topic is now archived and is closed to further replies.

Blender's export plugins

This topic is 5800 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Where are they? Seriously, I heard that there are plugins for Blender that let it export models in other formats. I''m particularly interested in OBJ, but I can only find some RIB export plugins. What about OBJ?

Share this post


Link to post
Share on other sites
I''m inept at finding them too. Perhaps I should just learn Python ? I have one for OBJ that someone posted here a while ago. It''s the only one I have though .

#
# OBJ (3.0) exporter for Blender v2.11+ (by Volker [vmx] Mische)
# Based on w3d2 jano''s script
#
# Things that can be done (i don''t need them, perhaps somebody else?):
# - Smoothing groups
# - Material output
#
# Here comes the introduction of jano''s original script:
#
# w3d2 exporter for Blender v2.11+
# Based on Flure''s w3d script; exports raw data in easy to parse format
# Press alt-p in this window and each mesh will be exported to a file
# Comment out corresponding FILE.write lines for info you don''t want/need
#

import Blender210

scene = Blender210.getCurrentScene()
for name in scene.objects:
if Blender210.isMesh(name):
print("Writing %s...\n" % name)
fileName = "%s.obj" % name
FILE = open(fileName, "w")
FILE.write("# Wavefront OBJ (3.0) exported by vmx''s Blender210 export script\n\n")
FILE.write("# Meshname: \t%s\n" % name)

object = Blender210.getObject(name)
mesh = Blender210.getMesh(object.data)
faces = mesh.faces
materials = object.materials
vertices = mesh.vertices
vnormals = mesh.normals
texcoords = mesh.texcoords
vcolors = mesh.colors

# Total vertices and faces; comment if not useful
FILE.write("# Total number of Faces: \t%s\n" % len(faces))
FILE.write("# Total number of Vertices:\t%s\n" % len(vertices))

FILE.write("\n")

# print first image map for uvcoords to use
# to be updated when we get access to other textures
if mesh.texture: FILE.write("# UV Texture: \t%s\n\n" % mesh.texture)


# Print all vertices to file
for vertice in vertices:
FILE.write("v %s %s %s\n" % (vertice[0], vertice[1], vertice[2]))

FILE.write("\n")


# Print all normals of the vertices to file
for vnormal in vnormals:
FILE.write("vn %s %s %s\n" % (vnormal[0], vnormal[1], vnormal[2]))

FILE.write("\n")


# Print all UV-coordinates to file, if there are one
if texcoords:

# Make an array with the right size,
# to put all texcoordinates in
uv = []
for i in range(len(vertices)):
uv.append(["i","i"])

# Put all texcoordinates in "uv" to get the right order
for i in range(len(faces)):
uv[faces[0]][0] = texcoords[i][0][0]
uv[faces[i][0]][1] = texcoords[i][0][1]

uv[faces[i][1]][0] = texcoords[i][1][0]
uv[faces[i][1]][1] = texcoords[i][1][1]

uv[faces[i][2]][0] = texcoords[i][2][0]
uv[faces[i][2]][1] = texcoords[i][2][1]

if faces[i][3]: # If the face is a quad
uv[faces[i][3]][0] = texcoords[i][3][0]
uv[faces[i][3]][1] = texcoords[i][3][1]

# The final output
for texcoord in uv:
FILE.write("vt %s %s\n" % (texcoord[0], texcoord[1]))


# Group name is the name of the mesh
FILE.write("\ng %s\n" % (name))


# Print the faces to file
for face in faces:

# If the face is a quad
if face[3]:
FILE.write("f %s/%s/%s %s/%s/%s %s/%s/%s %s/%s/%s\n" % (face[0]+1, face[0]+1, face[0]+1, face[1]+1, face[1]+1, face[1]+1, face[2]+1, face[2]+1, face[2]+1, face[3]+1, face[3]+1, face[3]+1))

# If the face is a triangle
else:
FILE.write("f %s/%s/%s %s/%s/%s %s/%s/%s\n" % (face[0]+1, face[0]+1, face[0]+1, face[1]+1, face[1]+1, face[1]+1, face[2]+1, face[2]+1, face[2]+1))


FILE.close()


print "finished"


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Wolfmanyoda: the link isn''t working. Where did you find it, may I ask?

NAV: (I''m dumb) What do you do with that? Do you cut-n-paste it in a text file and save it as a python script, and put in Blender''s plugin directory? Afraid I''ve never used a Blender script or plugin, so bear w/ me.

Share this post


Link to post
Share on other sites
  • Save the file somewhere (click on "reply to" to quote my post since the contents got mangled, then paste it into some text editor and save it somewhere).
  • Start Blender.
  • Click and hold the left mouse button on the "equal sign" that says "current menu type" when your mouse is over it (near bottom on left).
  • Go to the icon that looks like a sheet of paper with lines on it and release the mouse.
  • Click on the "dash" in that window and select "Open New". Find the file that you save from above and open it. Now you can export all models to the directory you ran blender from by clicking in that window and hitting ALT+P.

    Share this post


    Link to post
    Share on other sites
    quote:

    Wolfmanyoda: the link isn''t working. Where did you find it, may I ask?



    I found it on the Blender site''s forums.
    It''s not a link that I posted (I was lazy), just copy and paste it into your browser and the script will download.
    Load the script into Blender and it has instructions.
    Basically, select an object and hit Alt+P to run the script.
    You can export as well as import .obj files.
    I tried it both ways and it works wonderfully.

    Share this post


    Link to post
    Share on other sites