hi,
I am new here, but i want to say that i am happy to see that Blender supports scripting. I’m still figuring out, what the possibilities are. I’m used to program in the language called Processing.
i want to import vrml files to a enviroment and rotate them around a circle 360 degrees. I’m working with 851 vrml97 files and want to categorize them and view them in the game engine.
Another question i want to ask is what are the possiblities with xml databases?
I’ve found these codes
""" Registration info for Blender menus:
Name: 'VRML batch loader'
Blender: 237
Group: 'Import'
Tooltip: 'Loads all .wrl files from a user defined folder'
"""
#--------------------------------------------------------------------------
# Author Ewout - Version 1.0 - 5 Aug 05
# Using Blender file dialog: b2b revision by Ewout - Version 1.1 - 16 Aug 05
#--------------------------------------------------------------------------
# The purpose of this script is to automatically load wrl (VRML) files,
# saved out from Solidworks assemblies as individual part files, from a
# source folder.When finished loading save as .blend before continuing.
#
# Depending on the source of the VRML files, you may have some empty files,
# which results in a message from blender: "ERROR: Found no data"
# just keep your mouse moving and ignore this message :o)
#--------------------------------------------------------------------------
# Copyright 2005. Not for resale.
import Blender
import sys
import os
print "loading script"
filename = ""
def f(name): # file selector callback
global filename
filename = name
path = Blender.sys.dirname(filename)
ext = '.wrl'
print "Searching " + path
for filename in os.listdir(path):
if filename.endswith(ext): #check to make sure its a wrl file
Blender.Load(path + "/" + filename)
print "finished"
Blender.Window.FileSelector(f, "Open files in this dir")
import math
import Blender
import Blender.NMesh
cam = Blender.Object.Get("Camera")
loc = cam.loc
rot = cam.rot
obj = Blender.Object.GetSelected()[0]
me = Blender.NMesh.GetRawFromObject( obj.name )
dd = 1.0
x = loc[0] - dd * math.cos(rot[0]) * math.sin(rot[2])
y = loc[1] + dd * math.cos(rot[0]) * math.cos(rot[2])
z = loc[2] - dd * math.sin(rot[0])
obj.LocX = x
obj.LocY = y
obj.LocZ = z
me.transform( obj.matrix )
me.update()
Blender.Redraw()
t_pos = ( Blender.Mathutils.Vector(0, 0, -1) * cam.matrixWorld )
something like this:
And after that i want to automate the positions of camera’s. When pushing the left or right button it switches from position.