Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2005-03-21 08:26:52 +0300
committerWillian Padovani Germano <wpgermano@gmail.com>2005-03-21 08:26:52 +0300
commit62147bba3030ed79dd37a7d7f63d031ff263570e (patch)
tree6926313e7f15798337aa925752eb9e50ecd75721
parent12107e6af2eeeee8a993eca3963ef7bae3eeffe9 (diff)
Scripts (making some changes to the scripts dir):
- moved bpydata/ to scripts/bpydata/ and added a config/ subdir to it; - created scripts/bpymodules for py modules (also got rid of those "mod_"'s appended to the files); - updated scripts accordingly. This will require you to "reinstall" (just copy the scripts/ dir over your older one) if you have a .blender/scripts/ dir somewhere. Otherwise some scripts won't work. You can use the updated "Help->System->System Information" script here to check all is fine. An installer script yet to be written will help users with these issues, specially to make the user defined dir have the same structure expected from the default scripts dir, so the basic facilities (module search; saved config data; scripts: installer, help browser, config editor) are also available for a user's own collection of written and downloaded scripts. BPython: - slikdigit's crash was because he had no <home or blender exe location>/.blender/: proper check added and also now if all else fails the <cvsblender>/release/scripts/ dir is also searched for scripts. All this registration dirs stuff is a little messy (installation!), so please report any troubles (I only tested on linux). - slight change in error report in BPY_interface.c's BPY_menu_do_python; remembering to set globaldict pointer to NULL there, too. - moved bpy_gethome() to EXPP_interface.[ch] - "//" as user defined python dir is ignored while looking for scripts, considering it's only a default some users use, not really meant for a scripts dir.
-rw-r--r--release/scripts/bpydata/KUlang.txt121
-rw-r--r--release/scripts/bpydata/config/readme.txt10
-rw-r--r--release/scripts/bpydata/readme.txt9
-rw-r--r--release/scripts/bpymodules/BPyBlender.py (renamed from release/scripts/mod_blender.py)6
-rw-r--r--release/scripts/bpymodules/ai2obj.py (renamed from release/scripts/mod_ai2obj.py)0
-rw-r--r--release/scripts/bpymodules/eps2obj.py (renamed from release/scripts/mod_eps2obj.py)0
-rw-r--r--release/scripts/bpymodules/gimp2obj.py (renamed from release/scripts/mod_gimp2obj.py)0
-rw-r--r--release/scripts/bpymodules/meshtools.py (renamed from release/scripts/mod_meshtools.py)2
-rw-r--r--release/scripts/bpymodules/svg2obj.py (renamed from release/scripts/mod_svg2obj.py)0
-rw-r--r--release/scripts/lightwave_export.py60
-rw-r--r--release/scripts/lightwave_import.py14
-rw-r--r--release/scripts/nendo_export.py10
-rw-r--r--release/scripts/nendo_import.py18
-rw-r--r--release/scripts/off_export.py8
-rw-r--r--release/scripts/off_import.py10
-rw-r--r--release/scripts/paths_import.py10
-rw-r--r--release/scripts/radiosity_export.py14
-rw-r--r--release/scripts/radiosity_import.py10
-rw-r--r--release/scripts/raw_export.py4
-rw-r--r--release/scripts/raw_import.py6
-rw-r--r--release/scripts/slp_import.py6
-rw-r--r--release/scripts/sysinfo.py206
-rw-r--r--release/scripts/truespace_export.py16
-rw-r--r--release/scripts/truespace_import.py16
-rw-r--r--release/scripts/videoscape_export.py22
-rw-r--r--release/scripts/wings_export.py18
-rw-r--r--release/scripts/wings_import.py12
-rw-r--r--source/blender/python/BPY_extern.h1
-rw-r--r--source/blender/python/BPY_interface.c112
-rw-r--r--source/blender/python/BPY_menus.c226
-rw-r--r--source/blender/python/BPY_menus.h6
-rw-r--r--source/blender/python/api2_2x/Blender.c17
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.c68
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.h6
34 files changed, 697 insertions, 347 deletions
diff --git a/release/scripts/bpydata/KUlang.txt b/release/scripts/bpydata/KUlang.txt
new file mode 100644
index 00000000000..38605d69c9f
--- /dev/null
+++ b/release/scripts/bpydata/KUlang.txt
@@ -0,0 +1,121 @@
+Version 3.233-2004
+******************
+Espanol
+Sale del programa
+Utilidades de...%t|Alinea objetos%x1|Creacion%x2|Edita mallas%x3|Edita objetos%x4
+11
+Mov
+Esc
+Encaja
+Abarca
+Separa
+Alinea
+Rota
+Incr.
+Crea nuevos objetos
+Es+
+Es*
+Separar entre:%t|Origenes%x1|Centros geometricos%x2|Minimos%x3|Maximos%x4|Baricentro%x5|Objetos%x6
+Crear%t|Arco (3 ptos.)%x1|Arco (interactivo)%x2|Circunferencia (3 ptos.)%x3
+12
+Puntos
+Centro
+Orden
+Objeto
+AngIni:
+AngFin:
+Angulo:
+Radio:
+Puntos:
+Centro
+Nombre:
+Puntos
+Modifica vertices%t|Subdivide%x1|Envia a un plano%x2|Aplica LocRotSize%x3
+Partes
+Proyectar en el plano:%t|Coordenado global...%x1|Coordenado local...%x2
+Actuar sobre el plano%t|Yz%x1|Zx%x2|Xy%x3
+En la dirección%t|X%x1|Y%x2|Z%x3|Ortogonal al plano%x4
+Captura
+Buffer%t|Copia vector diferencia%x1|Copia distancia%x2|Copia diferencia de rotacion%x3|Copia media LocRotSiz%x4|Ver buffer en consola%x5
+Transformar LocRotSize%t|Hacia el obj. activo%x1|Aleatoriamente%x2
+Poner a distancia fija%x1|Sumar (desp. absoluto)%x2|Multiplicar (desp. relativo)%x3
+********************
+English
+Exit program
+Utils about:%t|Align Objects%x1|Create%x2|Edit Meshes%x3|Edit Objects%x4
+11
+Mov
+Sca
+Fit
+Embrace
+Separate
+Align
+Rota
+Incr.
+Create new objects
+Sc+
+Sc*
+Separate between:%t|Origins%x1|Geometric centers%x2|Minimum%x3|Maximum%x4|Baricenter%x5|Objects%x6
+Create what%t|Arc (3 pts.)%x1|Arc (interactive)%x2|Circunference (3 pts.)%x3
+12
+Points
+Centre
+Sort
+Object
+AngIni:
+AngEnd:
+Angle:
+Radius:
+Points:
+Centre
+ObjName:
+Points
+Modify vertices%t|Subdivide edges%x1|Send to a plane%x2|Set LocRotSize%x3
+Parts
+Project onto the plane:%t|Global coordinated...%x1|Local coordinated...%x2
+Act on plane%t|Yz%x1|Zx%x2|Xy%x3
+In direction%t|X%x1|Y%x2|Z%x3|Ortogonal to plane%x4
+Get
+Buffer%t|Copy diference vector%x1|Copy distance%x2|Copy rot diference%x3|Copy LocRotSiz average%x4|Show Buffer in Console%x5
+Transform LocRotSize%t|Close to active%x1|Randomly%x2
+Set at fixed distance%x1|Add (absolute displ.)%x2|Multiply (relative displ.)%x3
+********************
+Catala
+Surt del programa
+Utilitats de...%t|Alinea objectes%x1|Creacio%x2|Edita malles%x3|Edita objetes%x4
+11
+Mov
+Esc
+Encaixa
+Abarca
+Separa
+Alinea
+Rotacio
+Incr.
+Crea objectes nous
+Es+
+Es*
+Separa entra:%t|Origens%x1|Centres geometrics%x2|Minims%x3|Maxims%x4|Baricentre%x5|Objectes%x6
+Crear%t|Arc (3 pts.)%x1|Arc (interactiu)%x2|Circumferencia (3 pts.)%x3
+12
+Punts
+Centre
+Ordre
+Objecte
+AngIni:
+AngFi:
+Angle:
+Radi:
+Punts:
+Centre
+Nom:
+Punts
+Modifica vertex%t|Subdivideix%x1|Envia a un pla%x2|Aplica LocRotSize%x3
+Parts
+Projectar en el pla:%t|Coordenacio global...%x1|Coordenacio local...%x2
+Actuar sobre el pla%t|Yz%x1|Zx%x2|Xy%x3
+En la direccio%t|X%x1|Y%x2|Z%x3|Ortogonal al pla%x4
+Captura
+Buffer%t|Copia vector diferencia%x1|Copia distancia%x2|Copia diferencia de rotacio%x3|Copia mitjana LocRotSiz%x4|Veure buffer en consola%x5
+Transformar LocRotSize%t|Cap al obj. actiu%x1|Aleatoriamente%x2
+Posar a distancia fixa%x1|Sumar (desp. absolut)%x2|Multiplicar (desp. relatiu)%x3
diff --git a/release/scripts/bpydata/config/readme.txt b/release/scripts/bpydata/config/readme.txt
new file mode 100644
index 00000000000..099ade0f3e5
--- /dev/null
+++ b/release/scripts/bpydata/config/readme.txt
@@ -0,0 +1,10 @@
+This folder is for automatically saved scripts configuration data.
+This data is loaded when Blender starts and saved whenever a .blend file is
+saved.
+
+To use this feature scripts just need to set a Blender.Registry key with the
+extension ".cfg" (for example, "myscript.cfg").
+
+Please check the API Reference doc or the documentation for the
+"Scripts Config Editor" script with the Help menu-> "Scripts Help Browser"
+script in Blender.
diff --git a/release/scripts/bpydata/readme.txt b/release/scripts/bpydata/readme.txt
new file mode 100644
index 00000000000..3e640e27c4b
--- /dev/null
+++ b/release/scripts/bpydata/readme.txt
@@ -0,0 +1,9 @@
+This directory is the default place for scripts to put their data,
+like internal files needed by the script and its saved configuration.
+
+Scripts can find the path to this dir using Blender.Get("datadir").
+Ex:
+
+import Blender
+print Blender.Get("datadir")
+
diff --git a/release/scripts/mod_blender.py b/release/scripts/bpymodules/BPyBlender.py
index a4e4419381d..dda491e3af9 100644
--- a/release/scripts/mod_blender.py
+++ b/release/scripts/bpymodules/BPyBlender.py
@@ -1,7 +1,7 @@
# $Id$
#
# --------------------------------------------------------------------------
-# mod_blender.py version 0.2 Jul 26, 2004
+# BPyBlender.py version 0.3 Mar 20, 2005
# --------------------------------------------------------------------------
# helper functions to be used by other scripts
# --------------------------------------------------------------------------
@@ -32,6 +32,6 @@ basic_modules = [
'Blender',
'chunk','colorsys','copy','copy_reg','gzip','os','random','repr','stat',
'string','StringIO','types','UserDict','webbrowser','whrandom',
-'zlib',
-'math'
+'zlib', 'math',
+'BPyBlender'
]
diff --git a/release/scripts/mod_ai2obj.py b/release/scripts/bpymodules/ai2obj.py
index 8be6c5e18eb..8be6c5e18eb 100644
--- a/release/scripts/mod_ai2obj.py
+++ b/release/scripts/bpymodules/ai2obj.py
diff --git a/release/scripts/mod_eps2obj.py b/release/scripts/bpymodules/eps2obj.py
index 8db89892fc6..8db89892fc6 100644
--- a/release/scripts/mod_eps2obj.py
+++ b/release/scripts/bpymodules/eps2obj.py
diff --git a/release/scripts/mod_gimp2obj.py b/release/scripts/bpymodules/gimp2obj.py
index 7128107cfcd..7128107cfcd 100644
--- a/release/scripts/mod_gimp2obj.py
+++ b/release/scripts/bpymodules/gimp2obj.py
diff --git a/release/scripts/mod_meshtools.py b/release/scripts/bpymodules/meshtools.py
index 772b7549a11..4ddf6035e59 100644
--- a/release/scripts/mod_meshtools.py
+++ b/release/scripts/bpymodules/meshtools.py
@@ -25,7 +25,7 @@ try:
import operator
except:
msg = "Error: you need a full Python install to run this script."
- mod_meshtools.print_boxed(msg)
+ meshtools.print_boxed(msg)
Blender.Draw.PupMenu("ERROR%t|"+msg)
# =================================
diff --git a/release/scripts/mod_svg2obj.py b/release/scripts/bpymodules/svg2obj.py
index 7445b13a4a7..7445b13a4a7 100644
--- a/release/scripts/mod_svg2obj.py
+++ b/release/scripts/bpymodules/svg2obj.py
diff --git a/release/scripts/lightwave_export.py b/release/scripts/lightwave_export.py
index 99d7deab440..dc14d036503 100644
--- a/release/scripts/lightwave_export.py
+++ b/release/scripts/lightwave_export.py
@@ -52,7 +52,7 @@ v5.5 format.
# | Read and write LightWave Object File Format (*.lwo) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, chunk, os, cStringIO, time, operator
# ==============================
@@ -65,11 +65,11 @@ def write(filename):
objects = Blender.Object.GetSelected()
objects.sort(lambda a,b: cmp(a.name, b.name))
if not objects:
- mod_meshtools.print_boxed("No mesh objects are selected.")
+ meshtools.print_boxed("No mesh objects are selected.")
return
- if len(objects) > 20 and mod_meshtools.show_progress:
- mod_meshtools.show_progress = 0
+ if len(objects) > 20 and meshtools.show_progress:
+ meshtools.show_progress = 0
text = generate_text()
desc = generate_desc()
@@ -99,8 +99,8 @@ def write(filename):
if mesh.hasFaceUV():
vmad_uv = generate_vmad_uv(mesh) # per face
- if mod_meshtools.has_vertex_colors(mesh):
- if mod_meshtools.average_vcols:
+ if meshtools.has_vertex_colors(mesh):
+ if meshtools.average_vcols:
vmap_vc = generate_vmap_vc(mesh) # per vert
else:
vmad_vc = generate_vmad_vc(mesh) # per face
@@ -115,8 +115,8 @@ def write(filename):
write_chunk(meshdata, "VMAD", vmad_uv)
chunks.append(vmad_uv)
- if mod_meshtools.has_vertex_colors(mesh):
- if mod_meshtools.average_vcols:
+ if meshtools.has_vertex_colors(mesh):
+ if meshtools.average_vcols:
write_chunk(meshdata, "VMAP", vmap_vc)
chunks.append(vmap_vc)
else:
@@ -142,7 +142,7 @@ def write(filename):
end = time.clock()
seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + os.path.basename(filename) + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
# =======================================
# === Generate Null-Terminated String ===
@@ -164,17 +164,17 @@ def get_used_material_names(objects):
meshname = object.data.name
mesh = Blender.NMesh.GetRaw(meshname)
if not mesh: continue
- if (not mesh.materials) and (mod_meshtools.has_vertex_colors(mesh)):
+ if (not mesh.materials) and (meshtools.has_vertex_colors(mesh)):
# vcols only
- if mod_meshtools.average_vcols:
+ if meshtools.average_vcols:
matnames["\251 Per-Vert Vertex Colors"] = None
else:
matnames["\251 Per-Face Vertex Colors"] = None
- elif (mesh.materials) and (not mod_meshtools.has_vertex_colors(mesh)):
+ elif (mesh.materials) and (not meshtools.has_vertex_colors(mesh)):
# materials only
for material in mesh.materials:
matnames[material.name] = None
- elif (not mesh.materials) and (not mod_meshtools.has_vertex_colors(mesh)):
+ elif (not mesh.materials) and (not meshtools.has_vertex_colors(mesh)):
# neither
matnames["\251 Blender Default"] = None
else:
@@ -228,9 +228,9 @@ def generate_layr(name, idx):
def generate_pnts(mesh, matrix):
data = cStringIO.StringIO()
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Writing Verts")
- x, y, z = mod_meshtools.apply_transform(mesh.verts[i].co, matrix)
+ x, y, z = meshtools.apply_transform(mesh.verts[i].co, matrix)
data.write(struct.pack(">fff", x, z, y))
return data.getvalue()
@@ -255,7 +255,7 @@ def average_vertexcolors(mesh):
vcolor_add = lambda u, v: [u[0]+v[0], u[1]+v[1], u[2]+v[2], u[3]+v[3]]
vcolor_div = lambda u, s: [u[0]/s, u[1]/s, u[2]/s, u[3]/s]
for i in range(len(mesh.faces)): # get all vcolors that share this vertex
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Finding Shared VColors")
for j in range(len(mesh.faces[i].v)):
index = mesh.faces[i].v[j].index
@@ -263,7 +263,7 @@ def average_vertexcolors(mesh):
r,g,b,a = color.r, color.g, color.b, color.a
vertexcolors.setdefault(index, []).append([r,g,b,a])
for i in range(len(vertexcolors)): # average them
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
vcolor = [0,0,0,0] # rgba
for j in range(len(vertexcolors[i])):
@@ -296,7 +296,7 @@ def generate_vmad_vc(mesh):
data.write(struct.pack(">H", 3)) # dimension
data.write(generate_nstring("Blender's Vertex Colors")) # name
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Vertex Colors")
numfaceverts = len(mesh.faces[i].v)
for j in range(numfaceverts-1, -1, -1): # Reverse order
@@ -318,7 +318,7 @@ def generate_vmad_uv(mesh):
data.write(struct.pack(">H", 2)) # dimension
data.write(generate_nstring("Blender's UV Coordinates")) # name
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing UV Coordinates")
numfaceverts = len(mesh.faces[i].v)
for j in range(numfaceverts-1, -1, -1): # Reverse order
@@ -346,7 +346,7 @@ def generate_pols(mesh):
data = cStringIO.StringIO()
data.write("FACE") # polygon type
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Faces")
data.write(struct.pack(">H", len(mesh.faces[i].v))) # numfaceverts
numfaceverts = len(mesh.faces[i].v)
@@ -362,18 +362,18 @@ def generate_ptag(mesh, material_names):
data = cStringIO.StringIO()
data.write("SURF") # polygon tag type
for i in range(len(mesh.faces)): # numfaces
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Surface Indices")
data.write(generate_vx(i))
- if (not mesh.materials) and (mod_meshtools.has_vertex_colors(mesh)): # vcols only
- if mod_meshtools.average_vcols:
+ if (not mesh.materials) and (meshtools.has_vertex_colors(mesh)): # vcols only
+ if meshtools.average_vcols:
name = "\251 Per-Vert Vertex Colors"
else:
name = "\251 Per-Face Vertex Colors"
- elif (mesh.materials) and (not mod_meshtools.has_vertex_colors(mesh)): # materials only
+ elif (mesh.materials) and (not meshtools.has_vertex_colors(mesh)): # materials only
idx = mesh.faces[i].mat #erialIndex
name = mesh.materials[idx].name
- elif (not mesh.materials) and (not mod_meshtools.has_vertex_colors(mesh)): # neither
+ elif (not mesh.materials) and (not meshtools.has_vertex_colors(mesh)): # neither
name = "\251 Blender Default"
else: # both
idx = mesh.faces[i].mat
@@ -388,7 +388,7 @@ def generate_ptag(mesh, material_names):
# ===================================================
def generate_vcol_surf(mesh):
data = cStringIO.StringIO()
- if mod_meshtools.average_vcols and mod_meshtools.has_vertex_colors(mesh):
+ if meshtools.average_vcols and meshtools.has_vertex_colors(mesh):
surface_name = generate_nstring("\251 Per-Vert Vertex Colors")
else:
surface_name = generate_nstring("\251 Per-Face Vertex Colors")
@@ -413,7 +413,7 @@ def generate_vcol_surf(mesh):
data.write(generate_nstring("Blender's Vertex Colors")) # name
data.write("CMNT") # material comment
- comment = "Vertex Colors: Exported from Blender\256 " + mod_meshtools.blender_version_str
+ comment = "Vertex Colors: Exported from Blender\256 " + meshtools.blender_version_str
comment = generate_nstring(comment)
data.write(struct.pack(">H", len(comment)))
data.write(comment)
@@ -452,7 +452,7 @@ def generate_surf(material_name):
data.write(struct.pack(">fH", gloss, 0))
data.write("CMNT") # material comment
- comment = material_name + ": Exported from Blender\256 " + mod_meshtools.blender_version_str
+ comment = material_name + ": Exported from Blender\256 " + meshtools.blender_version_str
comment = generate_nstring(comment)
data.write(struct.pack(">H", len(comment)))
data.write(comment)
@@ -490,7 +490,7 @@ def generate_default_surf():
data.write(struct.pack(">fH", gloss, 0))
data.write("CMNT") # material comment
- comment = material_name + ": Exported from Blender\256 " + mod_meshtools.blender_version_str
+ comment = material_name + ": Exported from Blender\256 " + meshtools.blender_version_str
# vals = map(chr, range(164,255,1))
# keys = range(164,255,1)
@@ -509,7 +509,7 @@ def generate_default_surf():
# ============================================
def generate_text():
comment = "Lightwave Export Script for Blender "
- comment += mod_meshtools.blender_version_str + "\n"
+ comment += meshtools.blender_version_str + "\n"
comment += "by Anthony D'Agostino\n"
comment += "scorpius@netzero.com\n"
comment += "http://ourworld.compuserve.com/homepages/scorpius\n"
diff --git a/release/scripts/lightwave_import.py b/release/scripts/lightwave_import.py
index c795358c734..7e479536678 100644
--- a/release/scripts/lightwave_import.py
+++ b/release/scripts/lightwave_import.py
@@ -52,7 +52,7 @@ Notes:<br>
# | Read and write LightWave Object File Format (*.lwo) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, chunk, os, cStringIO, time, operator
# =============================
@@ -81,10 +81,10 @@ def read(filename):
verts = read_verts(lwochunk)
elif lwochunk.chunkname == "POLS" and form_type == "LWO2": # Faces v6.0
faces = read_faces_6(lwochunk)
- mod_meshtools.create_mesh(verts, faces, objname)
+ meshtools.create_mesh(verts, faces, objname)
elif lwochunk.chunkname == "POLS" and form_type == "LWOB": # Faces v5.5
faces = read_faces_5(lwochunk)
- mod_meshtools.create_mesh(verts, faces, objname)
+ meshtools.create_mesh(verts, faces, objname)
else: # Misc Chunks
lwochunk.skip()
@@ -95,7 +95,7 @@ def read(filename):
if form_type == "LWO2": fmt = " (v6.0 Format)"
if form_type == "LWOB": fmt = " (v5.5 Format)"
message = "Successfully imported " + os.path.basename(filename) + fmt + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
# ==================
# === Read Verts ===
@@ -106,7 +106,7 @@ def read_verts(lwochunk):
#$verts = []
verts = [None] * numverts
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
x, y, z = struct.unpack(">fff", data.read(12))
#$verts.append((x, z, y))
@@ -143,7 +143,7 @@ def read_faces_5(lwochunk):
faces = []
i = 0
while i < lwochunk.chunksize:
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/lwochunk.chunksize, "Reading Faces")
facev = []
numfaceverts, = struct.unpack(">H", data.read(2))
@@ -186,7 +186,7 @@ def read_faces_6(lwochunk):
return ""
i = 0
while(i < lwochunk.chunksize-4):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/lwochunk.chunksize, "Reading Faces")
facev = []
numfaceverts, = struct.unpack(">H", data.read(2))
diff --git a/release/scripts/nendo_export.py b/release/scripts/nendo_export.py
index 1dd84bb6d81..830c4303f56 100644
--- a/release/scripts/nendo_export.py
+++ b/release/scripts/nendo_export.py
@@ -59,7 +59,7 @@ field.
# | Read and write Nendo File Format (*.nendo) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, time, sys, os
# ==============================
@@ -82,15 +82,15 @@ def write(filename):
Blender.Draw.PupMenu("Nendo Export Error%t|"+message)
return
- edge_table = mod_meshtools.generate_edgetable(mesh)
+ edge_table = meshtools.generate_edgetable(mesh)
try:
- edge_table = mod_meshtools.generate_edgetable(mesh)
+ edge_table = meshtools.generate_edgetable(mesh)
assert len(edge_table) <= maxedges
except:
edge_table = {}
message = "Unable to generate Edge Table for the object named " + meshname
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
Blender.Draw.PupMenu("Edge Table Error%t|"+message)
Blender.Window.DrawProgressBar(1.0, "") # clear progressbar
return
@@ -109,7 +109,7 @@ def write(filename):
end = time.clock()
seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + os.path.basename(filename) + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
# ====================
# === Write Header ===
diff --git a/release/scripts/nendo_import.py b/release/scripts/nendo_import.py
index 2af19ff5a5d..e7f3071bd99 100644
--- a/release/scripts/nendo_import.py
+++ b/release/scripts/nendo_import.py
@@ -54,7 +54,7 @@ edges during the course of modeling.
# | Read and write Nendo File Format (*.nendo) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, time, sys, os
# =============================
@@ -75,7 +75,7 @@ def read(filename):
uv = read_uv(file)
verts = make_verts(vert_table)
faces = make_faces(edge_table)
- mod_meshtools.create_mesh(verts, faces, objname)
+ meshtools.create_mesh(verts, faces, objname)
Blender.Window.DrawProgressBar(1.0, "Done") # clear progressbar
file.close()
@@ -83,7 +83,7 @@ def read(filename):
seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully imported " + os.path.basename(filename) + seconds
message += " (%s)" % version.title()
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
# =======================
# === Read The Header ===
@@ -93,7 +93,7 @@ def read_header(file):
misc, = struct.unpack(">H", file.read(2))
numobjs, = struct.unpack(">B", file.read(1))
if (version != "nendo 1.0") and (version != "nendo 1.1"):
- mod_meshtools.print_boxed(file.name, "is not a Nendo file")
+ meshtools.print_boxed(file.name, "is not a Nendo file")
return
return version, numobjs
@@ -116,7 +116,7 @@ def read_edge_table(file, version):
numedges, = struct.unpack(">H", file.read(2))
edge_table = {}
for i in range(numedges):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numedges, "Reading Edge Table")
edge = struct.unpack(">8H", file.read(16))
if version == "nendo 1.1":
@@ -132,7 +132,7 @@ def read_face_table(file):
numfaces, = struct.unpack(">H", file.read(2))
face_table = {}
for i in range(numfaces):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Face Table")
face_table[i] = struct.unpack(">H", file.read(2))[0]
return face_table
@@ -144,7 +144,7 @@ def read_vert_table(file):
numverts, = struct.unpack(">H", file.read(2))
vert_table = []
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Vertex Table")
w, x, y, z = struct.unpack(">H3f", file.read(14))
vert_table.append((w,(x, y, z)))
@@ -164,7 +164,7 @@ def read_uv(file):
print "%ix%i" % (xres, yres)
pixel = 0
while pixel < (xres*yres):
- if not pixel%100 and mod_meshtools.show_progress:
+ if not pixel%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(pixel)/xres*yres, "Reading Texture")
count, = struct.unpack(">B", file.read(1))
rgb = file.read(3)
@@ -183,7 +183,7 @@ def make_verts(vert_table):
verts = []
for i in range(len(vert_table)):
vertex = vert_table[i][1]
- vertex = mod_meshtools.apply_transform(vertex, matrix)
+ vertex = meshtools.apply_transform(vertex, matrix)
verts.append(vertex)
return verts
diff --git a/release/scripts/off_export.py b/release/scripts/off_export.py
index 332d553b389..8465720478f 100644
--- a/release/scripts/off_export.py
+++ b/release/scripts/off_export.py
@@ -39,7 +39,7 @@ Notes:<br>
# | Read and write Object File Format (*.off) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
# ==============================
@@ -62,14 +62,14 @@ def write(filename):
# === Vertex List ===
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Writing Verts")
x, y, z = mesh.verts[i].co
file.write("%f %f %f\n" % (x, y, z))
# === Face List ===
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Faces")
file.write(`len(mesh.faces[i].v)`+' ')
mesh.faces[i].v.reverse()
@@ -83,7 +83,7 @@ def write(filename):
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
if filename.find('.off', -4) <= 0: filename += '.off'
diff --git a/release/scripts/off_import.py b/release/scripts/off_import.py
index 94b6423149a..cbaab483154 100644
--- a/release/scripts/off_import.py
+++ b/release/scripts/off_import.py
@@ -41,7 +41,7 @@ Notes:<br>
# | Read and write Object File Format (*.off) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
# =============================
@@ -67,7 +67,7 @@ def read(filename):
# === Vertex List ===
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
if has_uv:
x, y, z, u, v = map(float, file.readline().split())
@@ -78,7 +78,7 @@ def read(filename):
# === Face List ===
for i in range(numfaces):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
line = file.readline().split()
numfaceverts = len(line)-1
@@ -91,13 +91,13 @@ def read(filename):
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
- mod_meshtools.create_mesh(verts, faces, objname, faces, uv)
+ meshtools.create_mesh(verts, faces, objname, faces, uv)
Blender.Window.DrawProgressBar(1.0, '') # clear progressbar
file.close()
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully imported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
read(filename)
diff --git a/release/scripts/paths_import.py b/release/scripts/paths_import.py
index 0ec2b4e2f8a..889bcdad1e6 100644
--- a/release/scripts/paths_import.py
+++ b/release/scripts/paths_import.py
@@ -46,19 +46,19 @@ import Blender
argv=__script__['arg']
if argv=='SVG':
- from mod_svg2obj import *
+ from svg2obj import *
elif argv=='AI':
- from mod_ai2obj import *
+ from ai2obj import *
elif argv=='EPS':
- from mod_eps2obj import *
+ from eps2obj import *
elif argv=='Gimp_1_0':
- from mod_gimp2obj import *
+ from gimp2obj import *
elif argv=='Gimp_2_0':
- from mod_svg2obj import *
+ from svg2obj import *
text = 'Import %s' % argv
Blender.Window.FileSelector (fonctionSELECT, text)
diff --git a/release/scripts/radiosity_export.py b/release/scripts/radiosity_export.py
index c9d5128b367..4f7766c3dd5 100644
--- a/release/scripts/radiosity_export.py
+++ b/release/scripts/radiosity_export.py
@@ -52,14 +52,14 @@ specular highlights to the vertex colors.
# | Read and write Radiosity File Format (*.radio) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
try:
import struct
except:
msg = "Error: you need a full Python install to run this script."
- mod_meshtools.print_boxed(msg)
+ meshtools.print_boxed(msg)
Blender.Draw.PupMenu("ERROR%t|"+msg)
# ================================
@@ -75,10 +75,10 @@ def write(filename):
mesh = Blender.NMesh.GetRaw(meshname)
obj = Blender.Object.Get(objname)
- if not mod_meshtools.has_vertex_colors(mesh):
+ if not meshtools.has_vertex_colors(mesh):
message = "Please assign vertex colors before exporting. \n"
message += objname + " object was not saved."
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
Blender.Draw.PupMenu("ERROR%t|"+message)
return
@@ -89,7 +89,7 @@ def write(filename):
# === Vertex List ===
file.write(struct.pack("<l", len(mesh.verts)))
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Writing Verts")
x, y, z = mesh.verts[i].co
@@ -98,7 +98,7 @@ def write(filename):
# === Face List ===
file.write(struct.pack("<l", len(mesh.faces)))
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Faces")
file.write(struct.pack("<b", len(mesh.faces[i].v)))
@@ -116,7 +116,7 @@ def write(filename):
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
if filename.find('.radio', -6) <= 0: filename += '.radio'
diff --git a/release/scripts/radiosity_import.py b/release/scripts/radiosity_import.py
index f3e14d669a6..704a87becf5 100644
--- a/release/scripts/radiosity_import.py
+++ b/release/scripts/radiosity_import.py
@@ -37,14 +37,14 @@ file to open.
# | Read and write Radiosity File Format (*.radio) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
try:
import struct
except:
msg = "Error: you need a full Python install to run this script."
- mod_meshtools.print_boxed(msg)
+ meshtools.print_boxed(msg)
Blender.Draw.PupMenu("ERROR%t|"+msg)
# ===============================
@@ -63,7 +63,7 @@ def read(filename):
# === Vertex List ===
numverts, = struct.unpack("<l", file.read(4))
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
x, y, z = struct.unpack("<fff", file.read(12))
mesh.verts.append(Blender.NMesh.Vert(x, y, z))
@@ -71,7 +71,7 @@ def read(filename):
# === Face List ===
numfaces, = struct.unpack("<l", file.read(4))
for i in range(numfaces):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
face = Blender.NMesh.Face()
@@ -105,7 +105,7 @@ def read(filename):
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully imported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
read(filename)
diff --git a/release/scripts/raw_export.py b/release/scripts/raw_export.py
index 4cc49baff1e..f52f0404e19 100644
--- a/release/scripts/raw_export.py
+++ b/release/scripts/raw_export.py
@@ -39,7 +39,7 @@ Usage:<br>
# | Read and write RAW Triangle File Format (*.raw) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import sys
#import time
@@ -78,7 +78,7 @@ def write(filename):
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
if filename.find('.raw', -4) <= 0: filename += '.raw'
diff --git a/release/scripts/raw_import.py b/release/scripts/raw_import.py
index 13b2e187826..c793791664f 100644
--- a/release/scripts/raw_import.py
+++ b/release/scripts/raw_import.py
@@ -44,7 +44,7 @@ tolerance.
# | Read and write RAW Triangle File Format (*.raw) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
# ================================
@@ -79,13 +79,13 @@ def read(filename):
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
- mod_meshtools.create_mesh(verts, faces, objname)
+ meshtools.create_mesh(verts, faces, objname)
Blender.Window.DrawProgressBar(1.0, '') # clear progressbar
file.close()
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully imported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
read(filename)
diff --git a/release/scripts/slp_import.py b/release/scripts/slp_import.py
index e8c84f62ba2..246f84ec02b 100644
--- a/release/scripts/slp_import.py
+++ b/release/scripts/slp_import.py
@@ -42,7 +42,7 @@ tolerance.
# | Read and write SLP Triangle File Format (*.slp) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
# ================================
@@ -86,13 +86,13 @@ def read(filename):
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
- mod_meshtools.create_mesh(verts, faces, objname)
+ meshtools.create_mesh(verts, faces, objname)
Blender.Window.DrawProgressBar(1.0, '') # clear progressbar
file.close()
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully imported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
read(filename)
diff --git a/release/scripts/sysinfo.py b/release/scripts/sysinfo.py
index 04d31ccec16..daa6867e1a8 100644
--- a/release/scripts/sysinfo.py
+++ b/release/scripts/sysinfo.py
@@ -2,14 +2,14 @@
"""
Name: 'System Information...'
-Blender: 234
+Blender: 236
Group: 'HelpSystem'
Tooltip: 'Information about your Blender environment, useful to diagnose problems.'
"""
__author__ = "Willian P. Germano"
__url__ = ("blender", "elysiun")
-__version__ = "1.0"
+__version__ = "1.1"
__bpydoc__ = """\
This script creates a text in Blender's Text Editor with information
about your OS, video card, OpenGL driver, Blender and Python versions and
@@ -24,7 +24,7 @@ or the program's developers.
# $Id$
#
# --------------------------------------------------------------------------
-# sysinfo.py version 1.0 Jun 09, 2004
+# sysinfo.py version 1.1 Mar 20, 2005
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
@@ -37,7 +37,7 @@ or the program's developers.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
@@ -48,6 +48,7 @@ or the program's developers.
# --------------------------------------------------------------------------
import Blender
+import Blender.sys as bsys
from Blender.BGL import *
import sys
@@ -55,25 +56,26 @@ Blender.Window.WaitCursor(1)
# has_textwrap = 1 # see commented code below
output_filename = "system-info.txt"
warnings = 0
+notices = 0 # non critical warnings
def cutPoint(text, length):
- "Returns position of the last space found before 'length' chars"
- l = length
- c = text[l]
- while c != ' ':
- l -= 1
- if l == 0: return length # no space found
- c = text[l]
- return l
+ "Returns position of the last space found before 'length' chars"
+ l = length
+ c = text[l]
+ while c != ' ':
+ l -= 1
+ if l == 0: return length # no space found
+ c = text[l]
+ return l
def textWrap(text, length = 70):
- lines = []
- while len(text) > 70:
- cpt = cutPoint(text, length)
- line, text = text[:cpt], text[cpt + 1:]
- lines.append(line)
- lines.append(text)
- return lines
+ lines = []
+ while len(text) > 70:
+ cpt = cutPoint(text, length)
+ line, text = text[:cpt], text[cpt + 1:]
+ lines.append(line)
+ lines.append(text)
+ return lines
## Better use our own text wrap functions here
#try:
@@ -83,7 +85,7 @@ def textWrap(text, length = 70):
# msg = sys.exc_info()[1].__str__().split()[3]
# Blender.Draw.PupMenu("Python error:|This script requires the %s module" %msg)
-header = "= Blender %s System Information =" % Blender.Get("version")
+header = "= Blender %s System Information =" % Blender.Get("version")
lilies = len(header)*"="+"\n"
header = lilies + header + "\n" + lilies
@@ -97,66 +99,148 @@ output.write("Python:\n======\n\n")
output.write("- Version: %s\n\n" % sys.version)
output.write("- Path:\n\n")
for p in sys.path:
- output.write(p + '\n')
+ output.write(p + '\n')
-output.write("\n- Default folder for registered scripts:\n\n")
-scriptsdir = Blender.Get("scriptsdir")
-if not scriptsdir:
- output.write("<WARNING> -- not found")
- warnings += 1
+output.write("\n- Directories:")
+
+if not Blender.Get('homedir'):
+ outmsg = """
+
+<WARNING> - Blender home dir not found!
+ This should probably be "<path>/.blender/"
+ where <path> is usually the user's home dir.
+
+ Blender's home dir is where entries like:
+ folders scripts/, plugins/ and locale/ and
+ files .Blanguages and .bfont.ttf
+ are located.
+
+ It's also where Blender stores the Bpymenus file
+ with information about registered scripts, so it
+ only needs to scan scripts dir(s) when they are
+ modified.
+"""
+ output.write(outmsg)
+ if Blender.Get('scriptsdir').find('release') > 0:
+ output.write("""
+It seems this Blender binary is located at its cvs source tree:
+that's ok, but the scripts registration data will be recreated
+from dir(s) whenever you start the program, instead of only
+when those dirs are modified.
+
+Adding a .blender/ subdir to e. g. your home dir can prevent that.
+""")
+
+dirlist = [
+ ['homedir', 'Blender home dir', 1],
+ ['scriptsdir', 'Default dir for scripts', 1],
+ ['datadir', 'Default "bpydata/" data dir for scripts', 1],
+ ['uscriptsdir', 'User defined dir for scripts', 0],
+ ['udatadir', 'Data dir "bpydata/" inside user defined dir', 0]
+]
+
+for dir in dirlist:
+ dirname, dirstr, is_critical = dir
+ dirpath = Blender.Get(dirname)
+ output.write("\n\n %s:\n" % dirstr)
+ if not dirpath:
+ if is_critical:
+ warnings += 1
+ output.write(" <WARNING> -- not found")
+ else:
+ notices += 1
+ output.write(" <NOTICE> -- not found")
+ else:
+ output.write(" %s" % dirpath)
+
+configdir = bsys.join(Blender.Get('datadir'), 'config')
+output.write('\n\n Default config data "bpydata/config/" dir:')
+if bsys.exists(configdir):
+ output.write(" %s" % configdir)
else:
- output.write(scriptsdir)
+ warnings += 1
+ output.write("""
+ <WARNING> -- not found.
+ config/ should be inside the default scripts *data dir*.
+ It's used by Blender to store scripts configuration data.
+""")
+
+if Blender.Get('udatadir'):
+ uconfigdir = bsys.join(Blender.Get('udatadir'), 'config')
+ output.write("\n\n User defined config data dir:")
+ if bsys.exists(configdir):
+ output.write(" %s" % configdir)
+ else:
+ notices += 1
+ output.write("""
+ <NOTICE> -- not found.
+ bpydata/config/ should be inside the user defined scripts dir.
+ It's used by Blender to store scripts configuration data.
+ (Since it is on the user defined dir, a new Blender installation
+ won't overwrite the data.)
+""")
missing_mods = [] # missing basic modules
try:
- from mod_blender import basic_modules
- for m in basic_modules:
- try: exec ("import %s" % m)
- except: missing_mods.append(m)
-
- if missing_mods:
- output.write("\n\n<WARNING>:\n\nSome expected modules were not found.\n")
- output.write("Because of that some scripts bundled with Blender may not work.\n")
- output.write("Please read the FAQ in the Readme.html file shipped with Blender\n")
- output.write("for information about how to fix the problem.\n\n")
- output.write("The missing modules:\n")
- warnings += 1
- for m in missing_mods:
- output.write('-> ' + m + '\n')
- else:
- output.write("\n\n- Modules: all basic ones were found.\n")
-
-except:
- output.write("\n\n<WARNING>:\nCouldn't find mod_blender.py in scripts dir.")
- output.write("\nBasic modules availability won't be tested.\n")
- warnings += 1
-
+ from BPyBlender import basic_modules
+ for m in basic_modules:
+ try: exec ("import %s" % m)
+ except: missing_mods.append(m)
+
+ if missing_mods:
+ outmsg = """
+
+<WARNING>:
+
+Some expected modules were not found.
+Because of that some scripts bundled with Blender may not work.
+Please read the FAQ in the Readme.html file shipped with Blender
+for information about how to fix the problem.
+Missing modules:"""
+ output.write(outmsg)
+ warnings += 1
+ for m in missing_mods:
+ output.write('-> ' + m + '\n')
+ else:
+ output.write("\n\n- Modules: all basic ones were found.\n")
+
+except ImportError:
+ output.write("\n\n<WARNING>:\n Couldn't find BPyBlender.py in scripts/bpymodules/ dir.")
+ output.write("\n Basic modules availability won't be tested.\n")
+ warnings += 1
output.write("\nOpenGL:\n======\n\n")
-output.write("- Renderer: %s\n" % glGetString(GL_RENDERER))
-output.write("- Vendor: %s\n" % glGetString(GL_VENDOR))
-output.write("- Version: %s\n\n" % glGetString(GL_VERSION))
+output.write("- Renderer: %s\n" % glGetString(GL_RENDERER))
+output.write("- Vendor: %s\n" % glGetString(GL_VENDOR))
+output.write("- Version: %s\n\n" % glGetString(GL_VERSION))
output.write("- Extensions:\n\n")
glext = glGetString(GL_EXTENSIONS)
glext = textWrap(glext, 70)
for l in glext:
- output.write(l + "\n")
+ output.write(l + "\n")
output.write("\n\n- Simplistic almost useless benchmark:\n\n")
t = Blender.sys.time()
nredraws = 10
for i in range(nredraws):
- Blender.Redraw(-1) # redraw all windows
-result = str(Blender.sys.time() - t)
-output.write("Redrawing all areas %s times took %s seconds.\n" % (nredraws, result))
-
-if (warnings):
- output.write("\n(*) Found %d warning" % warnings)
- if (warnings > 1): output.write("s") # (blush)
- output.write(", documented in the text above.")
+ Blender.Redraw(-1) # redraw all windows
+result = Blender.sys.time() - t
+output.write("Redrawing all areas %s times took %.4f seconds.\n" % (nredraws, result))
+
+if warnings or notices:
+ output.write("\n%s%s\n" % (warnings*"#", notices*"."))
+ if warnings:
+ output.write("\n(*) Found %d warning" % warnings)
+ if (warnings > 1): output.write("s") # (blush)
+ output.write(", documented in the text above.\n")
+ if notices:
+ output.write("\n(*) Found %d notice" % notices)
+ if (notices > 1): output.write("s") # (blush)
+ output.write(", documented in the text above.\n")
+
else: output.write("\n==\nNo problems were found (scroll up for details).")
Blender.Window.WaitCursor(0)
diff --git a/release/scripts/truespace_export.py b/release/scripts/truespace_export.py
index d9cd0b1ad99..af9aa2a5a23 100644
--- a/release/scripts/truespace_export.py
+++ b/release/scripts/truespace_export.py
@@ -63,7 +63,7 @@ how to handle it.
# | Read and write Caligari trueSpace File Format (*.cob) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, os, cStringIO, time
# ==============================
@@ -86,7 +86,7 @@ def write(filename):
grou = generate_grou('Group ' + `objects.index(object)+1`)
polh = generate_polh(objname, obj, mesh)
- if mod_meshtools.has_vertex_colors(mesh): vcol = generate_vcol(mesh)
+ if meshtools.has_vertex_colors(mesh): vcol = generate_vcol(mesh)
unit = generate_unit()
mat1 = generate_mat1(mesh)
@@ -94,7 +94,7 @@ def write(filename):
write_chunk(file, "Grou", 0, 1, G, X, grou)
write_chunk(file, "PolH", 0, 4, P, G, polh)
- if mod_meshtools.has_vertex_colors(mesh) and vcol:
+ if meshtools.has_vertex_colors(mesh) and vcol:
write_chunk(file, "VCol", 1, 0, V, P, vcol)
write_chunk(file, "Unit", 0, 1, U, P, unit)
write_chunk(file, "Mat1", 0, 5, M, P, mat1)
@@ -109,7 +109,7 @@ def write(filename):
end = time.clock()
seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + os.path.basename(filename) + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
# =============================
# === Write COB File Header ===
@@ -163,7 +163,7 @@ def write_CurrentPosition(data, obj):
def write_VertexList(data, mesh):
data.write(struct.pack("<l", len(mesh.verts)))
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Writing Verts")
x, y, z = mesh.verts[i].co
data.write(struct.pack("<fff", -y, x, z))
@@ -185,7 +185,7 @@ def write_UVCoordsList(data, mesh):
uvcoords = {}
uvidx = 0
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing UV Coords")
numfaceverts = len(mesh.faces[i].v)
for j in range(numfaceverts-1, -1, -1): # Reverse order
@@ -206,7 +206,7 @@ def write_UVCoordsList(data, mesh):
def write_FaceList(data, mesh, uvcoords):
data.write(struct.pack("<l", len(mesh.faces)))
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Faces")
numfaceverts = len(mesh.faces[i].v)
data.write(struct.pack("<B", 0x10)) # Cull Back Faces Flag
@@ -230,7 +230,7 @@ def generate_vcol(mesh):
uniquecolors = {}
unique_alpha = {}
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Vertex Colors")
numfaceverts = len(mesh.faces[i].v)
data.write(struct.pack("<ll", i, numfaceverts))
diff --git a/release/scripts/truespace_import.py b/release/scripts/truespace_import.py
index d1bfd3ab6bf..40326612f3f 100644
--- a/release/scripts/truespace_import.py
+++ b/release/scripts/truespace_import.py
@@ -68,7 +68,7 @@ how to handle it.
# | Read and write Caligari trueSpace File Format (*.cob) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, chunk, os, cStringIO, time
# =======================
@@ -146,7 +146,7 @@ def read_LocalAxes(data):
#print "% f % f % f" % row
rotation_matrix.append(list(row))
#print
- rotation_matrix = mod_meshtools.transpose(rotation_matrix)
+ rotation_matrix = meshtools.transpose(rotation_matrix)
# === Read Current Position ===
def read_CurrentPosition(data):
@@ -162,7 +162,7 @@ def read_VertexList(data):
verts = []
numverts, = struct.unpack("<l", data.read(4))
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
x, y, z = struct.unpack("<fff", data.read(12))
verts.append((y, -x, z))
@@ -173,7 +173,7 @@ def read_UVCoords(data):
uvcoords = []
numuvcoords, = struct.unpack("<l", data.read(4))
for i in range(numuvcoords):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numuvcoords, "Reading UV Coords")
uv = struct.unpack("<ff", data.read(8))
uvcoords.append(uv)
@@ -187,7 +187,7 @@ def read_FaceList(data, chunk):
faces = [] ; facesuv = []
numfaces, = struct.unpack("<l", data.read(4))
for i in range(numfaces):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
face_flags, numfaceverts = struct.unpack("<Bh", data.read(3))
@@ -231,13 +231,13 @@ def read(filename):
break
if cobchunk.chunkname == "PolH":
verts, faces, objname, facesuv, uvcoords = read_polh(cobchunk)
- mod_meshtools.create_mesh(verts, faces, objname, facesuv, uvcoords)
+ meshtools.create_mesh(verts, faces, objname, facesuv, uvcoords)
'''
object = Blender.Object.GetSelected()
obj = Blender.Object.Get(objname)
obj.loc = location
- obj.rot = mod_meshtools.mat2euler(rotation_matrix)
+ obj.rot = meshtools.mat2euler(rotation_matrix)
obj.size = (transformation_matrix[0][0]/rotation_matrix[0][0],
transformation_matrix[1][1]/rotation_matrix[1][1],
transformation_matrix[2][2]/rotation_matrix[2][2])
@@ -251,7 +251,7 @@ def read(filename):
end = time.clock()
seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully imported " + os.path.basename(filename) + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
#print "objname :", objname
#print "numverts:", len(verts)
#print "numfaces:", len(faces)
diff --git a/release/scripts/videoscape_export.py b/release/scripts/videoscape_export.py
index 26bd7d08b01..37905239496 100644
--- a/release/scripts/videoscape_export.py
+++ b/release/scripts/videoscape_export.py
@@ -57,7 +57,7 @@ specular highlights to the vertex colors.
# | Write Videoscape File Format (*.obj NOT WAVEFRONT OBJ) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
#import time
# =====================================
@@ -73,10 +73,10 @@ def write(filename):
mesh = Blender.NMesh.GetRaw(meshname)
obj = Blender.Object.Get(objname)
- if not mod_meshtools.has_vertex_colors(mesh):
+ if not meshtools.has_vertex_colors(mesh):
message = "Please assign vertex colors before exporting.\n"
message += objname + " object was not saved."
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
return
vcols = average_vertexcolors(mesh)
@@ -87,7 +87,7 @@ def write(filename):
# === Write Vertex List & Vertex Colors ===
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Writing Verts")
file.write("% f % f % f 0x" % tuple(mesh.verts[i].co))
for j in range(len(vcols[i])):
@@ -96,7 +96,7 @@ def write(filename):
# === Write Face List ===
for i in range(len(mesh.faces)):
- if not i%100 and mod_meshtools.show_progress:
+ if not i%100 and meshtools.show_progress:
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Faces")
file.write("%d " % len(mesh.faces[i].v)) # numfaceverts
for j in range(len(mesh.faces[i].v)):
@@ -108,7 +108,7 @@ def write(filename):
#end = time.clock()
#seconds = " in %.2f %s" % (end-start, "seconds")
message = "Successfully exported " + Blender.sys.basename(filename)# + seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
# ===========================================
# === Vector Operations for Vertex Colors ===
@@ -122,7 +122,7 @@ vcolor_div = lambda u, s: [u[0]/s, u[1]/s, u[2]/s, u[3]/s]
def average_vertexcolors(mesh, debug=0):
vertexcolors = {}
for i in range(len(mesh.faces)): # get all vcolors that share this vertex
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Finding Shared VColors")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Finding Shared VColors")
for j in range(len(mesh.faces[i].v)):
index = mesh.faces[i].v[j].index
color = mesh.faces[i].col[j]
@@ -131,7 +131,7 @@ def average_vertexcolors(mesh, debug=0):
if debug: print 'before'; vcprint(vertexcolors)
for i in range(len(vertexcolors)): # average them
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
vcolor = [0,0,0,0] # rgba
for j in range(len(vertexcolors[i])):
vcolor = vcolor_add(vcolor, vertexcolors[i][j])
@@ -147,7 +147,7 @@ def average_vertexcolors_slow_1(mesh, debug=0):
vertexcolors = []
i = 0
for vertex in mesh.verts:
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
i += 1
vcolor = [0,0,0,0] # rgba
shared = 0
@@ -169,7 +169,7 @@ def average_vertexcolors_slow_1(mesh, debug=0):
def average_vertexcolors_slow_2(mesh, debug=0):
vertexcolors = []
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
vcolor = [0,0,0,0] # rgba
shared = 0
for j in range(len(mesh.faces)):
@@ -189,7 +189,7 @@ def average_vertexcolors_slow_2(mesh, debug=0):
def average_vertexcolors_slow_3(mesh, debug=0):
vertexcolors = []
for i in range(len(mesh.verts)):
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Averaging Vertex Colors")
vcolor = [0,0,0,0] # rgba
shared = 0
for j in range(len(mesh.faces)):
diff --git a/release/scripts/wings_export.py b/release/scripts/wings_export.py
index c35b141cc97..424ee2513d4 100644
--- a/release/scripts/wings_export.py
+++ b/release/scripts/wings_export.py
@@ -56,7 +56,7 @@ Notes:<br>
# | Read and write Wings3D File Format (*.wings) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, time, sys, os, zlib, cStringIO
# ===============================================
@@ -74,7 +74,7 @@ def write_faces(data, mesh):
numfaces = len(mesh.faces)
data.write(struct.pack(">BL", 0x6C, numfaces))
#for i in range(numfaces):
- # if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numfaces, "Writing Faces")
+ # if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numfaces, "Writing Faces")
# data.write("\x6A")
data.write("\x6A" * numfaces) # same, but faster than the above loop
data.write("\x6A")
@@ -86,7 +86,7 @@ def write_verts(data, mesh):
numverts = len(mesh.verts)
data.write(struct.pack(">BL", 0x6C, numverts))
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numverts, "Writing Verts")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numverts, "Writing Verts")
data.write(struct.pack(">BLBL", 0x6C, 1, 0x6D, 24))
#data.write("\x6c\x00\x00\x00\x01\x6D\x00\x00\x00\x30")
x, y, z = mesh.verts[i].co
@@ -104,9 +104,9 @@ def write_edges(data, mesh, edge_table):
keys.sort()
for key in keys:
i = edge_table[key][6]
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numedges, "Writing Edges")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numedges, "Writing Edges")
- if mod_meshtools.has_vertex_colors(mesh):
+ if meshtools.has_vertex_colors(mesh):
r1, g1, b1 = edge_table[key][7]
r2, g2, b2 = edge_table[key][8]
data.write("\x6C\x00\x00\x00\x02")
@@ -141,7 +141,7 @@ def write_mode(data, mesh):
data.write("\x6A")
data.write(struct.pack(">BL", 0x6C, 1))
write_chunkheader(data, 0x68, 0x02, "mode")
- if mod_meshtools.has_vertex_colors(mesh):
+ if meshtools.has_vertex_colors(mesh):
data.write(struct.pack(">BH6s", 0x64, 6, "vertex"))
else:
data.write(struct.pack(">BH8s", 0x64, 8, "material"))
@@ -313,12 +313,12 @@ def write(filename):
obj = Blender.Object.Get(objname)
try:
- edge_table = mod_meshtools.generate_edgetable(mesh)
+ edge_table = meshtools.generate_edgetable(mesh)
except:
edge_table = {}
message = "Unable to generate\nEdge Table for mesh.\n"
message += "Object name is: " + meshname
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
Blender.Draw.PupMenu("Wings Export error|Unable to generate Edge Table for mesh")
return
@@ -369,7 +369,7 @@ def write(filename):
message += "faces : " + `len(mesh.faces)` + '\n'
message += "edges : " + `len(edge_table)` + '\n'
message += "verts : " + `len(mesh.verts)` + '\n'
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
if filename.find('.wings', -6) <= 0: filename += '.wings'
diff --git a/release/scripts/wings_import.py b/release/scripts/wings_import.py
index dc28e978aae..70f124b3bac 100644
--- a/release/scripts/wings_import.py
+++ b/release/scripts/wings_import.py
@@ -53,7 +53,7 @@ Notes:<br>
# | Read and write Wings3D File Format (*.wings) |
# +---------------------------------------------------------+
-import Blender, mod_meshtools
+import Blender, meshtools
import struct, time, sys, os, zlib, cStringIO
# ==============================================
@@ -107,7 +107,7 @@ def read_edges(data):
misc, numedges = struct.unpack(">BL", data.read(5))
edge_table = {} # the winged-edge table
for i in range(numedges):
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numedges, "Reading Edges")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numedges, "Reading Edges")
misc, etype = struct.unpack(">BL", data.read(5))
if etype == 2: # Vertex Colors
data.read(10) # or read_chunkheader(data) # "color"
@@ -136,7 +136,7 @@ def read_edges(data):
def read_faces(data):
misc, numfaces = struct.unpack(">BL", data.read(5))
for i in range(numfaces):
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
if data.read(1) == '\x6C': # a material follows
data.read(4)
read_chunkheader(data)
@@ -153,7 +153,7 @@ def read_verts(data):
misc, numverts = struct.unpack(">BL", data.read(5))
verts = [] # a list of verts
for i in range(numverts):
- if not i%100 and mod_meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
+ if not i%100 and meshtools.show_progress: Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
data.read(10)
x, y, z = struct.unpack(">ddd", data.read(24)) # double precision
verts.append((x, -z, y))
@@ -305,7 +305,7 @@ def read(filename):
read_mode(data)
faces = make_faces(edge_table)
message += "%s %8s %8s %8s\n" % (objname.ljust(15), len(faces), len(edge_table), len(verts))
- mod_meshtools.create_mesh(verts, faces, objname)
+ meshtools.create_mesh(verts, faces, objname)
material = data.read()
#for i in material[0:6]: print "%02X" % ord(i),
@@ -315,7 +315,7 @@ def read(filename):
end = time.clock()
seconds = "\nDone in %.2f %s" % (end-start, "seconds")
message += seconds
- mod_meshtools.print_boxed(message)
+ meshtools.print_boxed(message)
def fs_callback(filename):
read(filename)
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index ab981939987..dbf464de019 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -78,7 +78,6 @@ extern "C" {
void init_syspath( int first_time );
void syspath_append( char *dir );
- char *bpy_gethome( int append_scriptsdir );
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 0034a65b547..fa38aa8c4c1 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -147,9 +147,6 @@ void BPY_start_python( int argc, char **argv )
* rest of our init msgs.
*/
- if( first_time ) { /* so it only prints msg on first_time */
- }
-
Py_Initialize( );
PySys_SetArgv( argc_copy, argv_copy );
@@ -211,7 +208,7 @@ void init_syspath( int first_time )
PyObject *mod, *d;
PyObject *p;
char *c, *progname;
- char execdir[FILE_MAXDIR + FILE_MAXFILE]; /*defines from DNA_space_types.h */
+ char execdir[FILE_MAXDIR]; /*defines from DNA_space_types.h */
int n;
@@ -310,9 +307,28 @@ that dir info is available.
void BPY_post_start_python( void )
{
PyObject *result, *dict;
+ char dirpath[FILE_MAXDIR];
+ char *sdir = NULL;
+
+ if(U.pythondir[0] != '\0' ) {
+ char modpath[FILE_MAXDIR];
+
+ BLI_strncpy(dirpath, U.pythondir, FILE_MAXDIR);
+ BLI_convertstringcode(dirpath, G.sce, 0);
+ syspath_append(dirpath); /* append to module search path */
+
+ BLI_make_file_string("/", modpath, dirpath, "bpymodules/");
+ if (BLI_exists(modpath)) syspath_append(modpath);
+ }
+
+ sdir = bpy_gethome(1);
+ if (sdir) {
- if( U.pythondir && U.pythondir[0] != '\0' )
- syspath_append( U.pythondir ); /* append to module search path */
+ syspath_append(sdir);
+
+ BLI_make_file_string("/", dirpath, sdir, "bpymodules/");
+ if (BLI_exists(dirpath)) syspath_append(dirpath);
+ }
BPyMenu_Init( 0 ); /* get dynamic menus (registered scripts) data */
@@ -642,15 +658,29 @@ int BPY_menu_do_python( short menutype, int event )
}
}
- if( !pyarg ) { /* no submenus */
+ if( !pyarg ) { /* no submenus */
Py_INCREF( Py_None );
pyarg = Py_None;
}
- if( pym->dir ) /* script is in U.pythondir */
- BLI_make_file_string( "/", filestr, U.pythondir, pym->filename );
- else /* script is in ~/.blender/scripts/ */
- BLI_make_file_string( "/", filestr, bpy_gethome(1), pym->filename );
+ if( pym->dir ) { /* script is in U.pythondir */
+ char upythondir[FILE_MAXDIR];
+
+ /* dirs in Blender can be "//", which has a special meaning */
+ BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
+ BLI_convertstringcode(upythondir, G.sce, 0); /* if so, this expands it */
+ BLI_make_file_string( "/", filestr, upythondir, pym->filename );
+ }
+ else { /* script is in default scripts dir */
+ char *scriptsdir = bpy_gethome(1);
+
+ if (!scriptsdir) {
+ printf("Error loading script: can't find default scripts dir!");
+ return 0;
+ }
+
+ BLI_make_file_string( "/", filestr, scriptsdir, pym->filename );
+ }
fp = fopen( filestr, "rb" );
if( !fp ) {
@@ -782,8 +812,8 @@ int BPY_menu_do_python( short menutype, int event )
if( !py_res ) { /* Failed execution of the script */
BPY_Err_Handle( script->id.name + 2 );
- PyErr_Print( );
ReleaseGlobalDictionary( py_dict );
+ script->py_globaldict = NULL;
if( G.main->script.first )
free_libblock( &G.main->script, script );
error( "Python script error: check console" );
@@ -1344,61 +1374,3 @@ void init_ourImport( void )
d = PyModule_GetDict( m );
PyDict_SetItemString( d, "__import__", import );
}
-
-/* this makes sure BLI_gethome() returns a path with '.blender' appended
- * Besides, this function now either returns userhome/.blender (if it exists)
- * or blenderInstallDir/.blender/ otherwise.
- * If append_scriptsdir is non NULL, "scripts/" is appended to the dir, to
- * get the path to the scripts folder.
- * Finally, if searched dir doesn't exist, NULL is returned.
-*/
-char *bpy_gethome(int append_scriptsdir)
-{
- static char homedir[FILE_MAXDIR];
- static char scriptsdir[FILE_MAXDIR];
- char bprogdir[FILE_MAXDIR];
- char *s;
- int i;
-
- if (append_scriptsdir) {
- if (scriptsdir[0] != '\0')
- return scriptsdir;
- }
- else if (homedir[0] != '\0')
- return homedir;
-
- s = BLI_gethome( );
-
- if( strstr( s, ".blender" ) )
- PyOS_snprintf( homedir, FILE_MAXDIR, s );
- else
- BLI_make_file_string( "/", homedir, s, ".blender/" );
-
- /* if userhome/.blender/ exists, return it */
- if( BLI_exists( homedir ) ) {
- if (append_scriptsdir) {
- BLI_make_file_string("/", scriptsdir, homedir, "scripts/");
- if (BLI_exists (scriptsdir)) return scriptsdir;
- }
- else return homedir;
- }
-
- /* otherwise, use argv[0] (bprogname) to get .blender/ in
- * Blender's installation dir */
- s = BLI_last_slash( bprogname );
-
- i = s - bprogname + 1;
-
- PyOS_snprintf( bprogdir, i, bprogname );
- BLI_make_file_string( "/", homedir, bprogdir, ".blender/" );
-
- if (BLI_exists(homedir)) {
- if (append_scriptsdir) {
- BLI_make_file_string("/", scriptsdir, homedir, "scripts/");
- if (BLI_exists(scriptsdir)) return scriptsdir;
- }
- else return homedir;
- }
-
- return NULL;
-}
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c
index c75b4c470fe..a35c7470841 100644
--- a/source/blender/python/BPY_menus.c
+++ b/source/blender/python/BPY_menus.c
@@ -63,6 +63,7 @@
#include "BPY_extern.h"
#include "BPY_menus.h"
+#include "api2_2x/EXPP_interface.h" /* for bpy_gethome() */
#include <errno.h>
@@ -337,8 +338,14 @@ static BPyMenu *bpymenu_AddEntry( short group, short version, char *name,
next = menu->next;
} else { /* they are in the same dir */
if (DEBUG) {
- printf("\nWarning: script %s's menu name is already in use.\n", fname );
- printf("Edit the script and change its Name: '%s' field, please.\n" "Note: if you really want two scripts in the same menu with\n" "the same name, keep one in the default dir and the other in\n" "the user defined dir, where it will take precedence.\n", name);
+ fprintf(stderr, "\n\
+Warning: script %s's menu name is already in use.\n\
+Edit the script and change its \n\
+Name: '%s'\n\
+field, please.\n\
+Note: if you really want to have two scripts for the same menu with\n\
+the same name, keep one in the default dir and the other in\n\
+the user defined dir (only the later will be registered).\n", fname, name);
}
return NULL;
}
@@ -422,6 +429,7 @@ static int bpymenu_CreateFromFile( void )
{
FILE *fp;
char line[255], w1[255], w2[255], tooltip[255], *tip;
+ char *homedir = NULL;
int parsing, version, is_userdir;
short group;
BPyMenu *pymenu = NULL;
@@ -432,13 +440,21 @@ static int bpymenu_CreateFromFile( void )
BPyMenuTable[group] = NULL;
/* let's try to open the file with bpymenu data */
- BLI_make_file_string( "/", line, bpy_gethome(0), BPYMENU_DATAFILE );
+ homedir = bpy_gethome(0);
+ if (!homedir) {
+ if( DEBUG )
+ fprintf(stderr,
+ "BPyMenus error: couldn't open config file Bpymenus: no home dir.\n");
+ return -1;
+ }
+
+ BLI_make_file_string( "/", line, homedir, BPYMENU_DATAFILE );
fp = fopen( line, "rb" );
if( !fp ) {
if( DEBUG )
- printf( "BPyMenus error: couldn't open config file %s.\n", line );
+ fprintf(stderr, "BPyMenus error: couldn't open config file %s.\n", line );
return -1;
}
@@ -449,7 +465,11 @@ static int bpymenu_CreateFromFile( void )
w1[0] = '\0';
fscanf( fp, "# User defined scripts dir: %[^\n]\n", w1 );
if( w1 ) {
- if( strcmp( w1, U.pythondir ) != 0 )
+ char upythondir[FILE_MAXDIR];
+
+ BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
+ BLI_convertstringcode(upythondir, G.sce, 0);
+ if( strcmp( w1, upythondir ) != 0 )
return -1;
w1[0] = '\0';
}
@@ -471,7 +491,9 @@ static int bpymenu_CreateFromFile( void )
if( parsing == 1 ) { /* got menu group string */
group = bpymenu_group_atoi( w1 );
if( group < 0 && DEBUG ) { /* invalid type */
- printf( "BPyMenus error parsing config file: wrong group: %s, " "will use 'Misc'.\n", w1 );
+ fprintf(stderr,
+ "BPyMenus error parsing config file: wrong group: %s,\n\
+will use 'Misc'.\n", w1 );
}
} else
continue;
@@ -526,15 +548,24 @@ static void bpymenu_WriteDataFile( void )
BPyMenu *pymenu;
BPySubMenu *smenu;
FILE *fp;
- char fname[FILE_MAXDIR + FILE_MAXFILE];
+ char fname[FILE_MAXDIR], *homedir;
int i;
- BLI_make_file_string( "/", fname, bpy_gethome(0), BPYMENU_DATAFILE );
+ homedir = bpy_gethome(0);
+
+ if (!homedir) {
+ if( DEBUG )
+ fprintf(stderr,
+ "BPyMenus error: couldn't write Bpymenus file: no home dir.\n\n");
+ return;
+ }
+
+ BLI_make_file_string( "/", fname, homedir, BPYMENU_DATAFILE );
fp = fopen( fname, "w" );
if( !fp ) {
if( DEBUG )
- printf( "BPyMenus error: couldn't write %s file.",
+ fprintf(stderr, "BPyMenus error: couldn't write %s file.\n\n",
fname );
return;
}
@@ -542,8 +573,15 @@ static void bpymenu_WriteDataFile( void )
fprintf( fp,
"# Blender: registered menu entries for bpython scripts\n" );
- if( U.pythondir[0] != '\0' && strcmp(U.pythondir, "/") != 0)
- fprintf( fp, "# User defined scripts dir: %s\n", U.pythondir );
+ if (U.pythondir[0] != '\0' &&
+ strcmp(U.pythondir, "/") != 0 && strcmp(U.pythondir, "//") != 0)
+ {
+ char upythondir[FILE_MAXDIR];
+
+ BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
+ BLI_convertstringcode(upythondir, G.sce, 0);
+ fprintf( fp, "# User defined scripts dir: %s\n", upythondir );
+ }
for( i = 0; i < PYMENU_TOTAL; i++ ) {
pymenu = BPyMenuTable[i];
@@ -777,7 +815,7 @@ static int bpymenu_ParseDir(char *dirname, char *parentdir, int is_userdir )
struct dirent *de;
struct stat status;
char *file_extension;
- char path[FILE_MAXFILE + FILE_MAXDIR];
+ char path[FILE_MAXDIR];
char subdir[FILE_MAXDIR];
char *s = NULL;
@@ -827,23 +865,27 @@ static int bpymenu_ParseDir(char *dirname, char *parentdir, int is_userdir )
Dir_Depth++;
if (Dirs_Number > MAX_DIR_NUMBER) {
if (DEBUG) {
- fprintf(stderr, "BPyMenus error: Too many subdirs.\n");
+ fprintf(stderr, "BPyMenus error: too many subdirs.\n");
}
+ closedir(dir);
return -1;
}
else if (Dir_Depth > MAX_DIR_DEPTH) {
- Dir_Depth--;
if (DEBUG)
fprintf(stderr,
- "BPyMenus error: Max depth reached traversing dirs.\n");
- break;
+ "BPyMenus error: max depth reached traversing dir tree.\n");
+ closedir(dir);
+ return -1;
}
s = de->d_name;
if (parentdir) {
BLI_make_file_string(NULL, subdir, parentdir, de->d_name);
s = subdir;
}
- if (bpymenu_ParseDir(path, s, is_userdir) == -1) return -1;
+ if (bpymenu_ParseDir(path, s, is_userdir) == -1) {
+ closedir(dir);
+ return -1;
+ }
}
}
@@ -889,112 +931,148 @@ static int bpymenu_GetStatMTime( char *name, int is_file, time_t * mtime )
*/
int BPyMenu_Init( int usedir )
{
- char fname[FILE_MAXDIR + FILE_MAXFILE];
+ char fname[FILE_MAXDIR];
char dirname[FILE_MAXDIR];
- char *upydir = U.pythondir;
- time_t tdir1 = 0, tdir2 = 0, tfile = 0;
- int res1 = 0, res2 = 0, resf = 0;
+ char upythondir[FILE_MAXDIR];
+ char *upydir = U.pythondir, *sdir = NULL;
+ time_t time_dir1 = 0, time_dir2 = 0, time_file = 0;
+ int stat_dir1 = 0, stat_dir2 = 0, stat_file = 0;
+ int i;
DEBUG = G.f & G_DEBUG; /* is Blender in debug mode (started with -d) ? */
/* init global bpymenu table (it is a list of pointers to struct BPyMenus
* for each available group: import, export, etc.) */
- for( res1 = 0; res1 < PYMENU_TOTAL; res1++ )
- BPyMenuTable[res1] = NULL;
+ for( i = 0; i < PYMENU_TOTAL; i++ )
+ BPyMenuTable[i] = NULL;
- if( U.pythondir[0] == '\0' || strcmp(U.pythondir, "/") == 0)
+ if( U.pythondir[0] == '\0' ||
+ strcmp(U.pythondir, "/") == 0 || strcmp(U.pythondir, "//") == 0)
+ {
upydir = NULL;
+ }
+ else {
+ BLI_strncpy(upythondir, upydir, FILE_MAXDIR);
+ BLI_convertstringcode(upythondir, G.sce, 0);
+ }
- BLI_strncpy(dirname, bpy_gethome(1), FILE_MAXDIR);
-
- res1 = bpymenu_GetStatMTime( dirname, 0, &tdir1 );
-
- if( res1 < 0 ) {
- tdir1 = 0;
- if( DEBUG ) {
- printf( "\nDefault scripts dir: %s:\n%s\n", dirname,
- strerror( errno ) );
- if( upydir )
- printf( "Getting scripts menu data from user defined dir: %s.\n", upydir );
+ sdir = bpy_gethome(1);
+
+ if (sdir) {
+ BLI_strncpy(dirname, sdir, FILE_MAXDIR);
+ stat_dir1 = bpymenu_GetStatMTime( dirname, 0, &time_dir1 );
+
+ if( stat_dir1 < 0 ) {
+ time_dir1 = 0;
+ if( DEBUG ) {
+ fprintf(stderr,
+ "\nDefault scripts dir: %s:\n%s\n", dirname, strerror(errno));
+ if( upydir )
+ fprintf(stderr,
+ "Getting scripts menu data from user defined dir: %s.\n",
+ upythondir );
+ }
}
- } else {
- syspath_append( dirname );
}
+ else stat_dir1 = -1;
if( upydir ) {
- res2 = bpymenu_GetStatMTime( U.pythondir, 0, &tdir2 );
+ stat_dir2 = bpymenu_GetStatMTime( upythondir, 0, &time_dir2 );
- if( res2 < 0 ) {
- tdir2 = 0;
+ if( stat_dir2 < 0 ) {
+ time_dir2 = 0;
if( DEBUG )
- printf( "\nUser defined scripts dir: %s:\n%s.\n", upydir, strerror( errno ) );
- if( res1 < 0 ) {
+ fprintf(stderr, "\nUser defined scripts dir: %s:\n%s.\n",
+ upythondir, strerror( errno ) );
+ if( stat_dir1 < 0 ) {
if( DEBUG )
- printf( "To have scripts in menus, please add them to the" "default scripts dir: %s\n" "and/or go to 'Info window -> File Paths tab' and set a valid\n" "path for the user defined scripts dir.\n", dirname );
+ fprintf(stderr, "\
+To have scripts in menus, please add them to the default scripts dir:\n\
+%s\n\
+and / or go to 'Info window -> File Paths tab' and set a valid path for\n\
+the user defined scripts dir.\n", dirname );
return -1;
}
}
- } else
- res2 = -1;
+ }
+ else stat_dir2 = -1;
- if( ( res1 < 0 ) && ( res2 < 0 ) ) {
+ if( ( stat_dir1 < 0 ) && ( stat_dir2 < 0 ) ) {
if( DEBUG ) {
- printf( "\nCannot register scripts in menus, no scripts dir" " available.\nExpected default dir in %s .\n", dirname );
+ fprintf(stderr, "\nCannot register scripts in menus, no scripts dir"
+ " available.\nExpected default dir at: %s \n", dirname );
}
return -1;
}
if( DEBUG )
- printf( "\nRegistering scripts in Blender menus ...\n\n" );
+ fprintf(stderr, "\nRegistering scripts in Blender menus ...\n\n" );
- if (usedir) resf = -1;
+ if (usedir) stat_file = -1;
else { /* if we're not forced to use the dir */
- BLI_make_file_string( "/", fname, bpy_gethome(0),
- BPYMENU_DATAFILE );
- resf = bpymenu_GetStatMTime( fname, 1, &tfile );
- if( resf < 0 )
- tfile = 0;
+ char *homedir = bpy_gethome(0);
+
+ if (homedir) {
+ BLI_make_file_string( "/", fname, homedir, BPYMENU_DATAFILE );
+ stat_file = bpymenu_GetStatMTime( fname, 1, &time_file );
+ if( stat_file < 0 )
+ time_file = 0;
/* comparing dates */
- if( ( tfile > tdir1 ) && ( tfile > tdir2 ) && !resf ) { /* file is newer */
- resf = bpymenu_CreateFromFile( ); /* -1 if an error occurred */
- if( !resf && DEBUG )
- printf( "Getting menu data for scripts from file: %s\n\n", fname );
+ if((stat_file == 0)
+ && (time_file > time_dir1) && (time_file > time_dir2))
+ { /* file is newer */
+ stat_file = bpymenu_CreateFromFile( ); /* -1 if an error occurred */
+ if( !stat_file && DEBUG )
+ fprintf(stderr,
+ "Getting menu data for scripts from file: %s\n\n", fname );
+ }
+ else stat_file = -1;
}
- else resf = -1; /* -1 to use dirs: didn't use file or it was corrupted */
+ else stat_file = -1; /* -1 to use dirs: didn't use file or it was corrupted */
}
- if( resf == -1 ) { /* use dirs */
+ if( stat_file == -1 ) { /* use dirs */
if( DEBUG ) {
- printf( "Getting menu data for scripts from dir(s):\n%s\n\n", dirname );
+ fprintf(stderr,
+ "Getting menu data for scripts from dir(s):\ndefault: %s\n", dirname );
if( upydir )
- printf( "%s\n", upydir );
+ fprintf(stderr, "user defined: %s", upythondir );
+ fprintf(stderr, "\n");
+ }
+ if( stat_dir1 == 0 ) {
+ i = bpymenu_ParseDir( dirname, NULL, 0 );
+ if (i == -1 && DEBUG)
+ fprintf(stderr, "Default scripts dir does not seem valid.\n\n");
}
- if( res1 == 0 )
- bpymenu_ParseDir( dirname, NULL, 0 );
- if( res2 == 0 ) {
+ if( stat_dir2 == 0 ) {
BLI_strncpy(dirname, U.pythondir, FILE_MAXDIR);
BLI_convertstringcode(dirname, G.sce, 0);
- bpymenu_ParseDir( dirname, NULL, 1 );
+ i = bpymenu_ParseDir( dirname, NULL, 1 );
+ if (i == -1 && DEBUG)
+ fprintf(stderr, "User defined scripts dir does not seem valid.\n\n");
}
/* check if we got any data */
- for( res1 = 0; res1 < PYMENU_TOTAL; res1++ )
- if( BPyMenuTable[res1] )
+ for( i = 0; i < PYMENU_TOTAL; i++ )
+ if( BPyMenuTable[i] )
break;
/* if we got, recreate the file */
- if( res1 < PYMENU_TOTAL )
+ if( i < PYMENU_TOTAL )
bpymenu_WriteDataFile( );
else if( DEBUG ) {
- printf( "\nWarning: Registering scripts in menus -- no info found.\n" "Either your scripts dirs have no .py scripts or the scripts\n" "don't have a header with registration data.\n" "Default scripts dir is: %s\n", dirname );
+ fprintf(stderr, "\n\
+Warning: Registering scripts in menus -- no info found.\n\
+Either your scripts dirs have no .py scripts or the scripts\n\
+don't have a header with registration data.\n\
+Default scripts dir is:\n\
+%s\n", dirname );
if( upydir )
- printf( "User defined scripts dir is: %s\n",
- upydir );
+ fprintf(stderr, "User defined scripts dir is: %s\n",
+ upythondir );
}
-
- return 0;
}
return 0;
diff --git a/source/blender/python/BPY_menus.h b/source/blender/python/BPY_menus.h
index 8848ba75a45..52ab5e85e4a 100644
--- a/source/blender/python/BPY_menus.h
+++ b/source/blender/python/BPY_menus.h
@@ -39,7 +39,7 @@
* slots are called groups here (Import, Export, etc). This is how it works:
* - scripts at dirs user pref U.pythondir and .blender/scripts/ are scanned
* for registration info.
- * - this data is also saved to a .Bpymenus file at the user's home dir and
+ * - this data is also saved to a Bpymenus file at the user's .blender/ dir and
* only re-created when the scripts folder gets modified.
* - on start-up Blender uses this info to fill a table, which is used to
* create the menu entries when they are needed (see header_info.c or
@@ -91,7 +91,7 @@ typedef enum {
PYMENU_UV,/* UV editing tools, to go in UV/Image editor space, 'UV' menu */
PYMENU_WIZARDS,/* complex 'app' scripts */
- /* entries put below don't appear at the Scripts win->Scripts menu;
+ /* entries put after Wizards don't appear at the Scripts win->Scripts menu;
* see define right below */
PYMENU_FACESELECT,
@@ -102,7 +102,7 @@ typedef enum {
PYMENU_TOTAL
} PYMENUHOOKS;
-#define PYMENU_SCRIPTS_MENU_TOTAL PYMENU_FACESELECT
+#define PYMENU_SCRIPTS_MENU_TOTAL (PYMENU_WIZARDS + 1)
/* BPyMenuTable holds all registered pymenus, as linked lists for each menu
* where they can appear (see PYMENUHOOKS enum above).
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 342c167530f..017ede81b80 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -60,9 +60,10 @@
#include <BKE_ipo.h>
#include <blendef.h>
+#include "EXPP_interface.h" /* for bpy_gethome() */
#include "gen_utils.h"
#include "modules.h"
-#include "../BPY_extern.h" /* for bpy_gethome() */
+#include "../BPY_extern.h" /* BPY_txt_do_python_Text */
#include "../BPY_menus.h" /* to update menus */
/**********************************************************/
@@ -217,19 +218,21 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
ret = PyString_FromString( G.sce );
else if( StringEqual( str, "homedir" ) ) {
char *hdir = bpy_gethome(0);
- if( BLI_exists( hdir ))
+ if( hdir && BLI_exists( hdir ))
ret = PyString_FromString( hdir );
else
ret = EXPP_incr_ret( Py_None );
}
else if( StringEqual( str, "datadir" ) ) {
char datadir[FILE_MAXDIR];
+ char *sdir = bpy_gethome(1);
- BLI_make_file_string( "/", datadir, bpy_gethome(1), "bpydata/" );
- if( BLI_exists( datadir ) )
- ret = PyString_FromString( datadir );
- else
- ret = EXPP_incr_ret( Py_None );
+ if (sdir) {
+ BLI_make_file_string( "/", datadir, sdir, "bpydata/" );
+ if( BLI_exists( datadir ) )
+ ret = PyString_FromString( datadir );
+ }
+ if (!ret) ret = EXPP_incr_ret( Py_None );
}
else if(StringEqual(str, "udatadir")) {
if (U.pythondir[0] != '\0') {
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c
index 2a03936c3f7..0dd363146e7 100644
--- a/source/blender/python/api2_2x/EXPP_interface.c
+++ b/source/blender/python/api2_2x/EXPP_interface.c
@@ -37,15 +37,83 @@
#include <BKE_global.h>
#include <BKE_library.h>
#include <BKE_main.h>
+#include <BLI_blenlib.h>
+#include <DNA_space_types.h> /* for FILE_MAXDIR, FILE_MAXFILE */
#include "EXPP_interface.h"
#include "Blender.h"
#include "Registry.h"
#include "gen_utils.h"
+extern char bprogname[]; /* argv[0] from creator.c */
void initBlenderApi2_2x( void )
{
g_blenderdict = NULL;
M_Blender_Init( );
}
+
+/* this makes sure BLI_gethome() returns a path with '.blender' appended
+ * Besides, this function now either returns userhome/.blender (if it exists)
+ * or blenderInstallDir/.blender/ otherwise (can also be cvs dir).
+ * If append_scriptsdir is non NULL, "scripts/" is appended to the dir, to
+ * get the path to the scripts folder ("release/scripts/" if cvs dir).
+ * Finally, if all else fails BLI_gethome() is returned
+ * (or NULL if append_scriptdir != 0).
+*/
+char *bpy_gethome(int append_scriptsdir)
+{
+ static char homedir[FILE_MAXDIR];
+ static char scriptsdir[FILE_MAXDIR];
+ char bprogdir[FILE_MAXDIR];
+ char *s;
+ int i;
+
+ if (append_scriptsdir) {
+ if (scriptsdir[0] != '\0')
+ return scriptsdir;
+ }
+ else if (homedir[0] != '\0')
+ return homedir;
+
+ s = BLI_gethome();
+
+ if( strstr( s, ".blender" ) )
+ PyOS_snprintf( homedir, FILE_MAXDIR, s );
+ else
+ BLI_make_file_string( "/", homedir, s, ".blender/" );
+
+ /* if userhome/.blender/ exists, return it */
+ if( BLI_exists( homedir ) ) {
+ if (append_scriptsdir) {
+ BLI_make_file_string("/", scriptsdir, homedir, "scripts/");
+ if (BLI_exists (scriptsdir)) return scriptsdir;
+ }
+ else return homedir;
+ }
+
+ /* otherwise, use argv[0] (bprogname) to get .blender/ in
+ * Blender's installation dir */
+ s = BLI_last_slash( bprogname );
+
+ i = s - bprogname + 1;
+
+ PyOS_snprintf( bprogdir, i, bprogname );
+ BLI_make_file_string( "/", homedir, bprogdir, ".blender/" );
+
+ if (BLI_exists(homedir)) {
+ if (append_scriptsdir) {
+ BLI_make_file_string("/", scriptsdir, homedir, "scripts/");
+ if (BLI_exists(scriptsdir)) return scriptsdir;
+ }
+ else return homedir;
+ }
+
+ /* last try for scripts dir: blender in cvs dir, scripts/ inside release/: */
+ if (append_scriptsdir) {
+ BLI_make_file_string("/", scriptsdir, bprogdir, "release/scripts/");
+ if (BLI_exists(scriptsdir)) return scriptsdir;
+ }
+
+ return NULL;
+}
diff --git a/source/blender/python/api2_2x/EXPP_interface.h b/source/blender/python/api2_2x/EXPP_interface.h
index ba267c5c935..3e38810143f 100644
--- a/source/blender/python/api2_2x/EXPP_interface.h
+++ b/source/blender/python/api2_2x/EXPP_interface.h
@@ -30,10 +30,16 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+#ifndef EXPP_INTERFACE_H
+#define EXPP_INTERFACE_H
+
#include <DNA_ID.h>
struct Script;
void initBlenderApi2_2x( void );
+char *bpy_gethome( int append_scriptsdir );
void discardFromBDict( char *key );
void EXPP_Library_Close( void ); /* in Library.c, used by BPY_end_python */
+
+#endif /* EXPP_INTERFACE_H */