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:
authorCampbell Barton <ideasman42@gmail.com>2007-04-07 21:35:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-04-07 21:35:47 +0400
commit76420c2fecdd57acf4fe0440fb681cf8f46707e4 (patch)
treea2ce3b28bf0d93aa4b2e241cc36a949f364d2a82 /release
parent4fae78f8d9e1acd55a5d068ea4f161687c8efc0c (diff)
appending libdata no longer breaks all external references.
Existing data is flagged with LIB_APPEND_TAG and all_local only has an option to only operate on un-flagged data. If you append an object thats linked to a material alredy linked in your scene, the material will not be made local. So at worst youll need to make local some of the datablocks. This is fairly simple and though my tests show it to work, do some tests on your own libraries before assuming its problem free. scripttemplate_mesh_edit wasnt updated with PyAPI changes and moved some functions into generic places.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/bpymodules/BPyMathutils.py27
-rw-r--r--release/scripts/bpymodules/BPyMesh.py17
-rw-r--r--release/scripts/mesh_solidify.py30
-rw-r--r--release/scripts/scripttemplate_mesh_edit.py12
4 files changed, 54 insertions, 32 deletions
diff --git a/release/scripts/bpymodules/BPyMathutils.py b/release/scripts/bpymodules/BPyMathutils.py
index ba15a8b8e8d..27736b4169e 100644
--- a/release/scripts/bpymodules/BPyMathutils.py
+++ b/release/scripts/bpymodules/BPyMathutils.py
@@ -210,3 +210,30 @@ def plane2mat(plane, normalize= False):
mat.resize4x4()
tmat= Blender.Mathutils.TranslationMatrix(cent)
return mat * tmat
+
+
+# Used for mesh_solidify.py and mesh_wire.py
+
+# returns a length from an angle
+# Imaging a 2d space.
+# there is a hoz line at Y1 going to inf on both X ends, never moves (LINEA)
+# down at Y0 is a unit length line point up at (angle) from X0,Y0 (LINEB)
+# This function returns the length of LINEB at the point it would intersect LINEA
+# - Use this for working out how long to make the vector - differencing it from surrounding faces,
+# import math
+from math import pi, sin, cos, sqrt
+
+def angleToLength(angle):
+ # Alredy accounted for
+ if angle < 0.000001:
+ return 1.0
+
+ angle = 2*pi*angle/360
+ x,y = cos(angle), sin(angle)
+ # print "YX", x,y
+ # 0 d is hoz to the right.
+ # 90d is vert upward.
+ fac=1/x
+ x=x*fac
+ y=y*fac
+ return sqrt((x*x)+(y*y))
diff --git a/release/scripts/bpymodules/BPyMesh.py b/release/scripts/bpymodules/BPyMesh.py
index b28ec58c84d..8cba68f012b 100644
--- a/release/scripts/bpymodules/BPyMesh.py
+++ b/release/scripts/bpymodules/BPyMesh.py
@@ -1151,6 +1151,23 @@ def pointInsideMesh(ob, pt):
return len([None for f in me.faces if ptInFaceXYBounds(f, obSpacePt) if faceIntersect(f)]) % 2
+def faceAngles(f):
+ Ang= Blender.Mathutils.AngleBetweenVecs
+ if len(f) == 3:
+ v1,v2,v3 = [v.co for v in f]
+ a1= Ang(v2-v1,v3-v1)
+ a2= Ang(v1-v2,v3-v2)
+ a3 = 180 - (a1+a2) # a3= Mathutils.AngleBetweenVecs(v2-v3,v1-v3)
+ return a1,a2,a3
+
+ else:
+ v1,v2,v3,v4 = [v.co for v in f]
+ a1= Ang(v2-v1,v4-v1)
+ a2= Ang(v1-v2,v3-v2)
+ a3= Ang(v2-v3,v4-v3)
+ a4= Ang(v3-v4,v1-v4)
+ return a1,a2,a3,a4
+
# NMesh wrapper
Vector= Blender.Mathutils.Vector
class NMesh(object):
diff --git a/release/scripts/mesh_solidify.py b/release/scripts/mesh_solidify.py
index 2e58513845c..91943db7a77 100644
--- a/release/scripts/mesh_solidify.py
+++ b/release/scripts/mesh_solidify.py
@@ -23,6 +23,8 @@ import BPyMesh
import BPyMessages
# reload(BPyMessages)
+from BPyMathutils import angleToLength
+
# python 2.3 has no reversed() iterator. this will only work on lists and tuples
try:
reversed
@@ -74,32 +76,6 @@ def copy_facedata_multilayer(me, from_faces, to_faces):
Ang= Mathutils.AngleBetweenVecs
SMALL_NUM=0.00001
-
-# returns a length from an angle
-# Imaging a 2d space.
-# there is a hoz line at Y1 going to inf on both X ends, never moves (LINEA)
-# down at Y0 is a unit length line point up at (angle) from X0,Y0 (LINEB)
-# This function returns the length of LINEB at the point it would intersect LINEA
-# - Use this for working out how long to make the vector - differencing it from surrounding faces,
-# import math
-from math import pi, sin, cos, sqrt
-
-def lengthFromAngle(angle):
- ''' # Alredy accounted for
- if angle < SMALL_NUM:
- return 1.0
- '''
- angle = 2*pi*angle/360
- x,y = cos(angle), sin(angle)
- # print "YX", x,y
- # 0 d is hoz to the right.
- # 90d is vert upward.
- fac=1/x
- x=x*fac
- y=y*fac
- return sqrt((x*x)+(y*y))
-
-
def main():
scn = bpy.scenes.active
ob = scn.objects.active
@@ -164,7 +140,7 @@ def main():
elif a < SMALL_NUM:
length+= 1
else:
- length+= lengthFromAngle(a)
+ length+= angleToLength(a)
length= length/len(vertFaces[i])
#print 'LENGTH %.6f' % length
diff --git a/release/scripts/scripttemplate_mesh_edit.py b/release/scripts/scripttemplate_mesh_edit.py
index 746f11d48ee..27607f2c69c 100644
--- a/release/scripts/scripttemplate_mesh_edit.py
+++ b/release/scripts/scripttemplate_mesh_edit.py
@@ -6,10 +6,11 @@ Group: 'ScriptTemplate'
Tooltip: 'Add a new text for editing a mesh'
"""
-from Blender import Text, Window
+from Blender import Window
+import bpy
-script_data = '''
-#!BPY
+script_data = \
+'''#!BPY
"""
Name: 'My Mesh Script'
Blender: 243
@@ -21,6 +22,7 @@ Tooltip: 'Put some useful info here'
from Blender import Scene, Mesh, Window, sys
import BPyMessages
+import bpy
def my_mesh_util(me):
# This function runs out of editmode with a mesh
@@ -53,7 +55,7 @@ def my_mesh_util(me):
def main():
# Gets the current scene, there can be many scenes in 1 blend file.
- sce = Scene.GetCurrent()
+ sce = bpy.scenes.active
# Get the active object, there can only ever be 1
# and the active object is always the editmode object.
@@ -71,7 +73,7 @@ def main():
if is_editmode: Window.EditMode(1)
Window.WaitCursor(1)
- me = ob_act.getData(mesh=1)
+ me = ob_act.getData(mesh=1) # old NMesh api is default
t = sys.time()
# Run the mesh editing function