Skip to main content
deleted 38 characters in body
Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59

The notion ofBy "level" is somewhat unclear here. It, it sounds like you mean you don't want the geometry in your "level"level file, only where objects are located. A more clear term for that is "placement editor" (ie. use Blender to place objects around the scene)

I've written a Python script to do just that; it saves custom properties in addition to regular position/rotation/etc, and you can save the data as either XML or JSON.

(and then just for kicks I ported the script to Maya)

The notion of "level" is somewhat unclear here. It sounds like you mean you don't want the geometry in your "level" file, only where objects are located. A more clear term for that is "placement editor" (ie. use Blender to place objects around the scene)

I've written a Python script to do just that; it saves custom properties in addition to regular position/rotation/etc, and you can save the data as either XML or JSON.

(and then just for kicks I ported the script to Maya)

By "level", it sounds like you mean you don't want the geometry in your level file, only where objects are located. A more clear term for that is "placement editor" (ie. use Blender to place objects around the scene)

I've written a Python script to do just that; it saves custom properties in addition to regular position/rotation/etc, and you can save the data as either XML or JSON.

(and then just for kicks I ported the script to Maya)

deleted 1224 characters in body
Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59

The notion of "level" is somewhat unclear here. It sounds like you mean you don't want the geometry in your "level" file, only where objects are located. A more clear term for what I'm talking aboutthat is "placement editor" (ie. use Blender to place objects around the scene)

I've written a scripta Python script to do just that; it saves custom properties in addition to do that using Pythonregular position/rotation/etc, it was pretty easy:and you can save the data as either XML or JSON.

#!BPY

"""
by Joseph Hocking 5/1/2010
Name: 'Dropper'
Blender: 2.49
Group: 'Export'
Tooltip: 'Saves object info to text file'
"""

import Blender
import bpy

def write(filename):
    out = file(filename,"w")
    out.write("<ENTITIES>\n")
    
    for obj in bpy.data.objects:
        if obj.sel:
            out.write("<ENTITY ")
            
            out.write("PX=\"" + str(round(obj.LocX,4)) + "\" ")
            out.write("PY=\"" + str(round(obj.LocY,4)) + "\" ")
            out.write("PZ=\"" + str(round(obj.LocZ,4)) + "\" ")
            
            out.write("RX=\"" + str(round(obj.RotX,4)) + "\" ")
            out.write("RY=\"" + str(round(obj.RotY,4)) + "\" ")
            out.write("RZ=\"" + str(round(obj.RotZ,4)) + "\">")
            
            out.write(obj.name)
            
            #optionally assign string property "tag" under "Logic" panel
            try:
                prop = obj.getProperty("tag")
                if prop.getType() == "STRING":
                    out.write("<TAG>" + prop.getData() + "</TAG>")
            except: pass
            
            out.write("</ENTITY>\n")
    
    out.write("</ENTITIES>")
    out.close()


Blender.Window.FileSelector(write,"Export")

(I'm not sure this works in the latest version of Blender. You can see in the comments that I wrote this script a couple years ago, andand then just for kicks I haven't upgraded Blender recently.ported the script to Maya)

The notion of "level" is somewhat unclear here. It sounds like you mean you don't want the geometry in your "level" file, only where objects are located. A more clear term for what I'm talking about is "placement editor" (ie. use Blender to place objects around the scene)

I've written a script to do that using Python, it was pretty easy:

#!BPY

"""
by Joseph Hocking 5/1/2010
Name: 'Dropper'
Blender: 2.49
Group: 'Export'
Tooltip: 'Saves object info to text file'
"""

import Blender
import bpy

def write(filename):
    out = file(filename,"w")
    out.write("<ENTITIES>\n")
    
    for obj in bpy.data.objects:
        if obj.sel:
            out.write("<ENTITY ")
            
            out.write("PX=\"" + str(round(obj.LocX,4)) + "\" ")
            out.write("PY=\"" + str(round(obj.LocY,4)) + "\" ")
            out.write("PZ=\"" + str(round(obj.LocZ,4)) + "\" ")
            
            out.write("RX=\"" + str(round(obj.RotX,4)) + "\" ")
            out.write("RY=\"" + str(round(obj.RotY,4)) + "\" ")
            out.write("RZ=\"" + str(round(obj.RotZ,4)) + "\">")
            
            out.write(obj.name)
            
            #optionally assign string property "tag" under "Logic" panel
            try:
                prop = obj.getProperty("tag")
                if prop.getType() == "STRING":
                    out.write("<TAG>" + prop.getData() + "</TAG>")
            except: pass
            
            out.write("</ENTITY>\n")
    
    out.write("</ENTITIES>")
    out.close()


Blender.Window.FileSelector(write,"Export")

(I'm not sure this works in the latest version of Blender. You can see in the comments that I wrote this script a couple years ago, and I haven't upgraded Blender recently.)

The notion of "level" is somewhat unclear here. It sounds like you mean you don't want the geometry in your "level" file, only where objects are located. A more clear term for that is "placement editor" (ie. use Blender to place objects around the scene)

I've written a Python script to do just that; it saves custom properties in addition to regular position/rotation/etc, and you can save the data as either XML or JSON.

(and then just for kicks I ported the script to Maya)

added 1328 characters in body
Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59

I've written a script to do that using Python, it was pretty easy. I'm:

#!BPY

"""
by Joseph Hocking 5/1/2010
Name: 'Dropper'
Blender: 2.49
Group: 'Export'
Tooltip: 'Saves object info to text file'
"""

import Blender
import bpy

def write(filename):
    out = file(filename,"w")
    out.write("<ENTITIES>\n")
    
    for obj in bpy.data.objects:
        if obj.sel:
            out.write("<ENTITY ")
            
            out.write("PX=\"" + str(round(obj.LocX,4)) + "\" ")
            out.write("PY=\"" + str(round(obj.LocY,4)) + "\" ")
            out.write("PZ=\"" + str(round(obj.LocZ,4)) + "\" ")
            
            out.write("RX=\"" + str(round(obj.RotX,4)) + "\" ")
            out.write("RY=\"" + str(round(obj.RotY,4)) + "\" ")
            out.write("RZ=\"" + str(round(obj.RotZ,4)) + "\">")
            
            out.write(obj.name)
            
            #optionally assign string property "tag" under "Logic" panel
            try:
                prop = obj.getProperty("tag")
                if prop.getType() == "STRING":
                    out.write("<TAG>" + prop.getData() + "</TAG>")
            except: pass
            
            out.write("</ENTITY>\n")
    
    out.write("</ENTITIES>")
    out.close()


Blender.Window.FileSelector(write,"Export")

(I'm not at home right now or I'd just copy-pastesure this works in the script intolatest version of Blender. You can see in the comments that I wrote this postscript a couple years ago, and I haven't upgraded Blender recently.)

I've written a script to do that using Python, it was pretty easy. I'm not at home right now or I'd just copy-paste the script into this post.

I've written a script to do that using Python, it was pretty easy:

#!BPY

"""
by Joseph Hocking 5/1/2010
Name: 'Dropper'
Blender: 2.49
Group: 'Export'
Tooltip: 'Saves object info to text file'
"""

import Blender
import bpy

def write(filename):
    out = file(filename,"w")
    out.write("<ENTITIES>\n")
    
    for obj in bpy.data.objects:
        if obj.sel:
            out.write("<ENTITY ")
            
            out.write("PX=\"" + str(round(obj.LocX,4)) + "\" ")
            out.write("PY=\"" + str(round(obj.LocY,4)) + "\" ")
            out.write("PZ=\"" + str(round(obj.LocZ,4)) + "\" ")
            
            out.write("RX=\"" + str(round(obj.RotX,4)) + "\" ")
            out.write("RY=\"" + str(round(obj.RotY,4)) + "\" ")
            out.write("RZ=\"" + str(round(obj.RotZ,4)) + "\">")
            
            out.write(obj.name)
            
            #optionally assign string property "tag" under "Logic" panel
            try:
                prop = obj.getProperty("tag")
                if prop.getType() == "STRING":
                    out.write("<TAG>" + prop.getData() + "</TAG>")
            except: pass
            
            out.write("</ENTITY>\n")
    
    out.write("</ENTITIES>")
    out.close()


Blender.Window.FileSelector(write,"Export")

(I'm not sure this works in the latest version of Blender. You can see in the comments that I wrote this script a couple years ago, and I haven't upgraded Blender recently.)

Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59
Loading