2.50:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19820:HEAD Notes: * Game and sequencer RNA, and sequencer header are now out of date a bit after changes in trunk. * I didn't know how to port these bugfixes, most likely they are not needed anymore. * Fix "duplicate strip" always increase the user count for ipo. * IPO pinning on sequencer strips was lost during Undo.
This commit is contained in:
@@ -132,7 +132,6 @@ modified for Blender/Mathutils by Campell Barton
|
||||
######################################################################
|
||||
# Public interface
|
||||
######################################################################
|
||||
from Blender.Mathutils import DotVecs
|
||||
def convexHull(point_list_2d):
|
||||
"""Calculate the convex hull of a set of vectors
|
||||
The vectors can be 3 or 4d but only the Xand Y are used.
|
||||
@@ -197,7 +196,7 @@ def plane2mat(plane, normalize= False):
|
||||
|
||||
up= cent - ((plane[0]+plane[1])/2.0)
|
||||
right= cent - ((plane[1]+plane[2])/2.0)
|
||||
z= CrossVecs(up, right)
|
||||
z= up.cross(right)
|
||||
|
||||
if normalize:
|
||||
up.normalize()
|
||||
|
||||
@@ -569,12 +569,11 @@ def face_edges(me):
|
||||
|
||||
|
||||
def facesPlanerIslands(me):
|
||||
DotVecs= Blender.Mathutils.DotVecs
|
||||
|
||||
def roundvec(v):
|
||||
return round(v[0], 4), round(v[1], 4), round(v[2], 4)
|
||||
|
||||
face_props= [(cent, no, roundvec(no), DotVecs(cent, no)) for f in me.faces for no, cent in ((f.no, f.cent),)]
|
||||
face_props= [(cent, no, roundvec(no), cent.dot(no)) for f in me.faces for no, cent in ((f.no, f.cent),)]
|
||||
|
||||
face_edge_users= face_edges(me)
|
||||
islands= []
|
||||
@@ -607,7 +606,7 @@ def facesPlanerIslands(me):
|
||||
face_prop2= face_props[fidx2]
|
||||
# normals are the same?
|
||||
if face_prop1[2]==face_prop2[2]:
|
||||
if abs(face_prop1[3] - DotVecs(face_prop1[1], face_prop2[0])) < 0.000001:
|
||||
if abs(face_prop1[3] - face_prop1[1].dot(face_prop2[0])) < 0.000001:
|
||||
used_faces[fidx2]= 1
|
||||
island.append(fidx2)
|
||||
islands.append([me.faces[i] for i in island])
|
||||
@@ -616,7 +615,6 @@ def facesPlanerIslands(me):
|
||||
|
||||
|
||||
def facesUvIslands(me, PREF_IMAGE_DELIMIT=True):
|
||||
DotVecs= Blender.Mathutils.DotVecs
|
||||
def roundvec(v):
|
||||
return round(v[0], 4), round(v[1], 4)
|
||||
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
from Blender import *
|
||||
|
||||
try:
|
||||
import psyco
|
||||
psyco.full()
|
||||
except:
|
||||
print 'no psyco for you!'
|
||||
|
||||
DotVecs= Mathutils.DotVecs
|
||||
#========================================================
|
||||
# SPACIAL TREE - Seperate Class - use if you want to
|
||||
# USed for getting vert is a proximity
|
||||
LEAF_SIZE = 128
|
||||
class octreeNode:
|
||||
def __init__(self, verts, parent):
|
||||
|
||||
# Assunme we are a leaf node, until split is run.
|
||||
self.verts = verts
|
||||
self.children = []
|
||||
|
||||
if parent == None: # ROOT NODE, else set bounds when making children,
|
||||
# BOUNDS
|
||||
v= verts[0]
|
||||
maxx,maxy,maxz= v.co
|
||||
minx,miny,minz= maxx,maxy,maxz
|
||||
|
||||
for v in verts:
|
||||
x,y,z= v.co
|
||||
if x>maxx: maxx= x
|
||||
if y>maxy: maxy= y
|
||||
if z>maxz: maxz= z
|
||||
|
||||
if x<minx: minx= x
|
||||
if y<miny: miny= y
|
||||
if z<minz: minz= z
|
||||
|
||||
self.minx= minx
|
||||
self.miny= miny
|
||||
self.minz= minz
|
||||
|
||||
self.maxx= maxx
|
||||
self.maxy= maxy
|
||||
self.maxz= maxz
|
||||
|
||||
# We have no parent to split us so split ourselves.
|
||||
#self.setCornerPoints()
|
||||
self.splitNode()
|
||||
|
||||
def splitNode(self):
|
||||
if len(self.verts) > LEAF_SIZE:
|
||||
self.makeChildren() # 8 new children,
|
||||
self.verts = None
|
||||
# Alredy assumed a leaf not so dont do anything here.
|
||||
|
||||
def makeChildren(self):
|
||||
verts= self.verts
|
||||
# Devide into 8 children.
|
||||
axisDividedVerts = [[],[],[],[],[],[],[],[]] # Verts Only
|
||||
|
||||
|
||||
divx = (self.maxx + self.minx) / 2
|
||||
divy = (self.maxy + self.miny) / 2
|
||||
divz = (self.maxz + self.minz) / 2
|
||||
|
||||
# Sort into 8
|
||||
for v in verts:
|
||||
x,y,z = v.co
|
||||
|
||||
if x > divx:
|
||||
if y > divy:
|
||||
if z > divz:
|
||||
axisDividedVerts[0].append(v)
|
||||
else:
|
||||
axisDividedVerts[1].append(v)
|
||||
else:
|
||||
if z > divz:
|
||||
axisDividedVerts[2].append(v)
|
||||
else:
|
||||
axisDividedVerts[3].append(v)
|
||||
else:
|
||||
if y > divy:
|
||||
if z > divz:
|
||||
axisDividedVerts[4].append(v)
|
||||
else:
|
||||
axisDividedVerts[5].append(v)
|
||||
else:
|
||||
if z > divz:
|
||||
axisDividedVerts[6].append(v)
|
||||
else:
|
||||
axisDividedVerts[7].append(v)
|
||||
|
||||
# populate self.children
|
||||
for i in xrange(8):
|
||||
octNode = octreeNode(axisDividedVerts[i], self)
|
||||
# Set bounds manually
|
||||
if i == 0:
|
||||
octNode.minx = divx
|
||||
octNode.maxx = self.maxx
|
||||
octNode.miny = divy
|
||||
octNode.maxy = self.maxy
|
||||
octNode.minz = divz
|
||||
octNode.maxz = self.maxz
|
||||
elif i == 1:
|
||||
octNode.minx = divx
|
||||
octNode.maxx = self.maxx
|
||||
octNode.miny = divy
|
||||
octNode.maxy = self.maxy
|
||||
octNode.minz = self.minz #
|
||||
octNode.maxz = divz #
|
||||
elif i == 2:
|
||||
octNode.minx = divx
|
||||
octNode.maxx = self.maxx
|
||||
octNode.miny = self.miny #
|
||||
octNode.maxy = divy #
|
||||
octNode.minz = divz
|
||||
octNode.maxz = self.maxz
|
||||
elif i == 3:
|
||||
octNode.minx = divx
|
||||
octNode.maxx = self.maxx
|
||||
octNode.miny = self.miny #
|
||||
octNode.maxy = divy #
|
||||
octNode.minz = self.minz #
|
||||
octNode.maxz = divz #
|
||||
elif i == 4:
|
||||
octNode.minx = self.minx #
|
||||
octNode.maxx = divx #
|
||||
octNode.miny = divy
|
||||
octNode.maxy = self.maxy
|
||||
octNode.minz = divz
|
||||
octNode.maxz = self.maxz
|
||||
elif i == 5:
|
||||
octNode.minx = self.minx #
|
||||
octNode.maxx = divx #
|
||||
octNode.miny = divy
|
||||
octNode.maxy = self.maxy
|
||||
octNode.minz = self.minz #
|
||||
octNode.maxz = divz #
|
||||
elif i == 6:
|
||||
octNode.minx = self.minx #
|
||||
octNode.maxx = divx #
|
||||
octNode.miny = self.miny #
|
||||
octNode.maxy = divy #
|
||||
octNode.minz = divz
|
||||
octNode.maxz = self.maxz
|
||||
elif i == 7:
|
||||
octNode.minx = self.minx #
|
||||
octNode.maxx = divx #
|
||||
octNode.miny = self.miny #
|
||||
octNode.maxy = divy #
|
||||
octNode.minz = self.minz #
|
||||
octNode.maxz = divz #
|
||||
#octNode.setCornerPoints()
|
||||
octNode.splitNode() # Splits the node if it can.
|
||||
self.children.append(octNode)
|
||||
|
||||
# GETS VERTS IN A Distance RANGE-
|
||||
def getVertsInRange(self, loc, normal, range_val, vertList):
|
||||
#loc= Mathutils.Vector(loc) # MUST BE VECTORS
|
||||
#normal= Mathutils.Vector(normal)
|
||||
|
||||
'''
|
||||
loc: Vector of the location to search from
|
||||
normal: None or Vector - if a vector- will only get verts on this side of the vector
|
||||
range_val: maximum distance. A negative value will fill the list with teh closest vert only.
|
||||
vertList: starts as an empty list
|
||||
list that this function fills with verts that match
|
||||
'''
|
||||
xloc,yloc,zloc= loc
|
||||
|
||||
if range_val<0:
|
||||
range_val= -range_val
|
||||
FIND_CLOSEST= True
|
||||
vertList.append(None) # just update the 1 vertex
|
||||
else:
|
||||
FIND_CLOSEST= False
|
||||
|
||||
if self.children:
|
||||
# Check if the bounds are in range_val,
|
||||
for childNode in self.children:
|
||||
# First test if we are surrounding the point.
|
||||
if\
|
||||
childNode.minx - range_val < xloc and\
|
||||
childNode.maxx + range_val > xloc and\
|
||||
childNode.miny - range_val < yloc and\
|
||||
childNode.maxy + range_val > yloc and\
|
||||
childNode.minz - range_val < zloc and\
|
||||
childNode.maxz + range_val > zloc:
|
||||
# Recurse down or get virts.
|
||||
childNode.getVertsInRange(loc, normal, range_val, vertList)
|
||||
#continue # Next please
|
||||
|
||||
else: # we are a leaf node. Test vert locations.
|
||||
if not normal:
|
||||
# Length only check
|
||||
for v in self.verts:
|
||||
length = (loc - v.co).length
|
||||
if length < range_val:
|
||||
if FIND_CLOSEST:
|
||||
# Just update the 1 vert
|
||||
vertList[0]= (v, length)
|
||||
range_val= length # Shink the length so we only get verts from their.
|
||||
else:
|
||||
vertList.append((v, length))
|
||||
else:
|
||||
# Lengh and am I infront of the vert.
|
||||
for v in self.verts:
|
||||
length = (loc - v.co).length
|
||||
if length < range_val:
|
||||
# Check if the points in front
|
||||
dot= DotVecs(normal, loc) - DotVecs(normal, v.co)
|
||||
if dot<0:
|
||||
vertList.append((v, length))
|
||||
|
||||
# END TREE
|
||||
|
||||
|
||||
|
||||
|
||||
# EXAMPLE RADIO IN PYTHON USING THE ABOVE FUNCTION
|
||||
"""
|
||||
import BPyMesh
|
||||
# Radio bake
|
||||
def bake():
|
||||
|
||||
_AngleBetweenVecs_= Mathutils.AngleBetweenVecs
|
||||
def AngleBetweenVecs(a1,a2):
|
||||
try:
|
||||
return _AngleBetweenVecs_(a1,a2)
|
||||
except:
|
||||
return 180
|
||||
|
||||
|
||||
|
||||
scn = Scene.GetCurrent()
|
||||
ob = scn.getActiveObject()
|
||||
me = ob.getData(mesh=1)
|
||||
|
||||
dist= Draw.PupFloatInput('MaxDist:', 2.0, 0.1, 20.0, 0.1, 3)
|
||||
if dist==None:
|
||||
return
|
||||
|
||||
# Make nice normals
|
||||
BPyMesh.meshCalcNormals(me)
|
||||
|
||||
|
||||
len_verts= len(me.verts)
|
||||
#me.sel= False
|
||||
meshOctTree = octreeNode(me.verts, None)
|
||||
|
||||
|
||||
|
||||
# Store face areas
|
||||
vertex_areas= [0.0] * len_verts
|
||||
|
||||
# Get vertex areas - all areas of face users
|
||||
for f in me.faces:
|
||||
a= f.area
|
||||
for v in f.v:
|
||||
vertex_areas[v.index] += a
|
||||
|
||||
|
||||
|
||||
bias= 0.001
|
||||
|
||||
t= sys.time()
|
||||
|
||||
# Tone for the verts
|
||||
vert_tones= [0.0] * len_verts
|
||||
maxtone= 0.0
|
||||
mintone= 100000000
|
||||
for i, v in enumerate(me.verts):
|
||||
if not i%10:
|
||||
print 'verts to go', len_verts-i
|
||||
v_co= v.co
|
||||
v_no= v.no
|
||||
verts_in_range= []
|
||||
meshOctTree.getVertsInRange(v_co, v_no, dist, verts_in_range)
|
||||
|
||||
tone= 0.0
|
||||
# These are verts in our range
|
||||
for test_v, length in verts_in_range:
|
||||
if bias<length:
|
||||
try:
|
||||
# Make sure this isnt a back facing vert
|
||||
normal_diff= AngleBetweenVecs(test_v.no, v_no)
|
||||
except:
|
||||
continue
|
||||
|
||||
if normal_diff > 90: # were facing this vert
|
||||
#if 1:
|
||||
# Current value us between zz90 and 180
|
||||
# make between 0 and 90
|
||||
# so 0 is right angles and 90 is direct opposite vertex normal
|
||||
normal_diff= (normal_diff-90)
|
||||
|
||||
# Vertex area needs to be taken into account so we dont have small faces over influencing.
|
||||
vertex_area= vertex_areas[test_v.index]
|
||||
|
||||
# Get the angle the vertex is in location from the location and normal of the vert.
|
||||
above_diff= AngleBetweenVecs(test_v.co-v.co, v_no)
|
||||
## Result will be between 0 :above and 90: horizon.. invert this so horizon has littel effect
|
||||
above_diff= 90-above_diff
|
||||
# dist-length or 1.0/length both work well
|
||||
tone= (dist-length) * vertex_area * above_diff * normal_diff
|
||||
vert_tones[i] += tone
|
||||
|
||||
if maxtone<vert_tones[i]:
|
||||
maxtone= vert_tones[i]
|
||||
if mintone>vert_tones[i]:
|
||||
mintone= vert_tones[i]
|
||||
|
||||
|
||||
if not maxtone:
|
||||
Draw.PupMenu('No verts in range, use a larger range')
|
||||
return
|
||||
|
||||
# Apply tones
|
||||
for f in me.faces:
|
||||
f_col= f.col
|
||||
for i, v in enumerate(f.v):
|
||||
c= f_col[i]
|
||||
v_index= v.index
|
||||
tone= int(((maxtone - vert_tones[v.index]) / maxtone) * 255 )
|
||||
#print tone
|
||||
c.r= c.g= c.b= tone
|
||||
|
||||
print 'time', sys.time()-t
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
bake()
|
||||
"""
|
||||
@@ -25,7 +25,6 @@ import Blender
|
||||
import bpy
|
||||
Vector= Blender.Mathutils.Vector
|
||||
Ang= Blender.Mathutils.AngleBetweenVecs
|
||||
CrossVecs= Blender.Mathutils.CrossVecs
|
||||
MidpointVecs= Blender.Mathutils.MidpointVecs
|
||||
import BPyMesh
|
||||
|
||||
@@ -198,8 +197,8 @@ def redux(ob, REDUX=0.5, BOUNDRY_WEIGHT=2.0, REMOVE_DOUBLES=False, FACE_AREA_WEI
|
||||
# the point of collapsing.
|
||||
|
||||
# Enlarge so we know they intersect: self.length*2
|
||||
cv1= CrossVecs(v1no, CrossVecs(v1no, v1co-v2co))
|
||||
cv2= CrossVecs(v2no, CrossVecs(v2no, v2co-v1co))
|
||||
cv1= v1no.cross(v1no.cross(v1co-v2co))
|
||||
cv2= v2no.cross(v2no.cross(v2co-v1co))
|
||||
|
||||
# Scale to be less then the edge lengths.
|
||||
cv2.length = cv1.length = 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Blender
|
||||
from Blender import Mathutils, Window, Scene, Draw, Mesh
|
||||
from Blender.Mathutils import CrossVecs, Matrix, Vector, Intersect
|
||||
from Blender.Mathutils import Matrix, Vector, Intersect
|
||||
|
||||
# DESCRIPTION:
|
||||
# screen_x, screen_y the origin point of the pick ray
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#dxfLibrary.py : provides functions for generating DXF files
|
||||
# --------------------------------------------------------------------------
|
||||
__version__ = "v1.29beta - 2008.12.28"
|
||||
__version__ = "v1.32 - 2009.06.06"
|
||||
__author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)"
|
||||
__license__ = "GPL"
|
||||
__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
|
||||
@@ -18,31 +18,39 @@ IDEAs:
|
||||
-
|
||||
|
||||
TODO:
|
||||
- add support for SPLINEs, (bad idea, cause DXF r14 object :(
|
||||
- add support for DXFr14 (needs extended file header)
|
||||
- add support for SPLINEs (possible first in DXFr14 version)
|
||||
|
||||
History
|
||||
v1.32 - 2009.06.06 by migius
|
||||
- modif Style class: changed defaults to widthFactor=1.0, obliqueAngle=0.0
|
||||
- modif Text class: alignment parameter reactivated
|
||||
v1.31 - 2009.06.02 by migius
|
||||
- modif _Entity class: added paperspace,elevation
|
||||
v1.30 - 2009.05.28 by migius
|
||||
- bugfix 3dPOLYLINE/POLYFACE: VERTEX needs x,y,z coordinates, index starts with 1 not 0
|
||||
v1.29 - 2008.12.28 by Yorik
|
||||
- modif POLYLINE to support bulge segments
|
||||
- modif POLYLINE to support bulge segments
|
||||
v1.28 - 2008.12.13 by Steeve/BlenderArtists
|
||||
- bugfix for EXTMIN/EXTMAX to suit Cycas-CAD
|
||||
- bugfix for EXTMIN/EXTMAX to suit Cycas-CAD
|
||||
v1.27 - 2008.10.07 by migius
|
||||
- beautifying output code: keys whitespace prefix
|
||||
- refactoring DXF-strings format: NewLine moved to the end of
|
||||
- beautifying output code: keys whitespace prefix
|
||||
- refactoring DXF-strings format: NewLine moved to the end of
|
||||
v1.26 - 2008.10.05 by migius
|
||||
- modif POLYLINE to support POLYFACE
|
||||
- modif POLYLINE to support POLYFACE
|
||||
v1.25 - 2008.09.28 by migius
|
||||
- modif FACE class for r12
|
||||
- modif FACE class for r12
|
||||
v1.24 - 2008.09.27 by migius
|
||||
- modif POLYLINE class for r12
|
||||
- changing output format from r9 to r12(AC1009)
|
||||
- modif POLYLINE class for r12
|
||||
- changing output format from r9 to r12(AC1009)
|
||||
v1.1 (20/6/2005) by www.stani.be/python/sdxf
|
||||
- Python library to generate dxf drawings
|
||||
- Python library to generate dxf drawings
|
||||
______________________________________________________________
|
||||
""" % (__author__,__version__,__license__,__url__)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# DXF Library: copyright (C) 2005 by Stani Michiels (AKA Stani)
|
||||
# 2008 modif by Remigiusz Fiedler (AKA migius)
|
||||
# 2008/2009 modif by Remigiusz Fiedler (AKA migius)
|
||||
# --------------------------------------------------------------------------
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
@@ -85,7 +93,6 @@ def _point(x,index=0):
|
||||
def _points(plist):
|
||||
"""Convert a list of tuples to dxf points"""
|
||||
out = '\n'.join([_point(plist[i],i)for i in range(len(plist))])
|
||||
#print 'deb: points=\n', out #-------------------
|
||||
return out
|
||||
|
||||
#---base classes----------------------------------------
|
||||
@@ -104,17 +111,21 @@ class _Call:
|
||||
#-------------------------------------------------------
|
||||
class _Entity(_Call):
|
||||
"""Base class for _common group codes for entities."""
|
||||
def __init__(self,color=None,extrusion=None,layer='0',
|
||||
def __init__(self,paperspace=None,color=None,layer='0',
|
||||
lineType=None,lineTypeScale=None,lineWeight=None,
|
||||
thickness=None,parent=None):
|
||||
extrusion=None,elevation=None,thickness=None,
|
||||
parent=None):
|
||||
"""None values will be omitted."""
|
||||
self.paperspace = paperspace
|
||||
self.color = color
|
||||
self.extrusion = extrusion
|
||||
self.layer = layer
|
||||
self.lineType = lineType
|
||||
self.lineTypeScale = lineTypeScale
|
||||
self.lineWeight = lineWeight
|
||||
self.extrusion = extrusion
|
||||
self.elevation = elevation
|
||||
self.thickness = thickness
|
||||
#self.visible = visible
|
||||
self.parent = parent
|
||||
|
||||
def _common(self):
|
||||
@@ -122,13 +133,16 @@ class _Entity(_Call):
|
||||
if self.parent:parent=self.parent
|
||||
else:parent=self
|
||||
result =''
|
||||
if parent.paperspace==1: result+=' 67\n1\n'
|
||||
if parent.layer!=None: result+=' 8\n%s\n'%parent.layer
|
||||
if parent.color!=None: result+=' 62\n%s\n'%parent.color
|
||||
if parent.extrusion!=None: result+='%s\n'%_point(parent.extrusion,200)
|
||||
if parent.lineType!=None: result+=' 6\n%s\n'%parent.lineType
|
||||
#TODO: if parent.lineWeight!=None: result+='370\n%s\n'%parent.lineWeight
|
||||
#TODO: if parent.visible!=None: result+='60\n%s\n'%parent.visible
|
||||
if parent.lineTypeScale!=None: result+=' 48\n%s\n'%parent.lineTypeScale
|
||||
if parent.elevation!=None: result+=' 38\n%s\n'%parent.elevation
|
||||
if parent.thickness!=None: result+=' 39\n%s\n'%parent.thickness
|
||||
if parent.extrusion!=None: result+='%s\n'%_point(parent.extrusion,200)
|
||||
return result
|
||||
|
||||
#--------------------------
|
||||
@@ -307,6 +321,10 @@ class PolyLine(_Entity):
|
||||
self.points=points
|
||||
self.org_point=org_point
|
||||
self.flag=flag
|
||||
self.polyface = False
|
||||
self.polyline2d = False
|
||||
self.faces = [] # dummy value
|
||||
self.width= None # dummy value
|
||||
if self.flag & POLYFACE_MESH:
|
||||
self.polyface=True
|
||||
self.points=points[0]
|
||||
@@ -322,21 +340,21 @@ class PolyLine(_Entity):
|
||||
|
||||
def __str__(self):
|
||||
result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.flag)
|
||||
#print 'deb: self._common()', self._common() #----------
|
||||
result+=' 66\n1\n'
|
||||
result+='%s\n' %_point(self.org_point)
|
||||
if self.polyface:
|
||||
result+=' 71\n%s\n' %self.p_count
|
||||
result+=' 72\n%s\n' %self.f_count
|
||||
elif self.polyline2d:
|
||||
if self.width: result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
|
||||
if self.width!=None: result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
|
||||
for point in self.points:
|
||||
result+=' 0\nVERTEX\n'
|
||||
result+=' 8\n%s\n' %self.layer
|
||||
result+='%s\n' %_point(point[0:2])
|
||||
if self.polyface:
|
||||
result+='%s\n' %_point(point[0:3])
|
||||
result+=' 70\n192\n'
|
||||
elif self.polyline2d:
|
||||
result+='%s\n' %_point(point[0:2])
|
||||
if len(point)>4:
|
||||
width1, width2 = point[3], point[4]
|
||||
if width1!=None: result+=' 40\n%s\n' %width1
|
||||
@@ -344,6 +362,8 @@ class PolyLine(_Entity):
|
||||
if len(point)==6:
|
||||
bulge = point[5]
|
||||
if bulge: result+=' 42\n%s\n' %bulge
|
||||
else:
|
||||
result+='%s\n' %_point(point[0:3])
|
||||
for face in self.faces:
|
||||
result+=' 0\nVERTEX\n'
|
||||
result+=' 8\n%s\n' %self.layer
|
||||
@@ -407,7 +427,7 @@ class Text(_Entity):
|
||||
if self.style: result+=' 7\n%s\n'%self.style
|
||||
if self.flag: result+=' 71\n%s\n'%self.flag
|
||||
if self.justifyhor: result+=' 72\n%s\n'%self.justifyhor
|
||||
#TODO: if self.alignment: result+='%s\n'%_point(self.alignment,1)
|
||||
if self.alignment: result+='%s\n'%_point(self.alignment,1)
|
||||
if self.justifyver: result+=' 73\n%s\n'%self.justifyver
|
||||
return result
|
||||
|
||||
@@ -528,7 +548,7 @@ class LineType(_Call):
|
||||
#-----------------------------------------------
|
||||
class Style(_Call):
|
||||
"""Text style"""
|
||||
def __init__(self,name='standard',flag=0,height=0,widthFactor=40,obliqueAngle=50,
|
||||
def __init__(self,name='standard',flag=0,height=0,widthFactor=1.0,obliqueAngle=0.0,
|
||||
mirror=0,lastHeight=1,font='arial.ttf',bigFont=''):
|
||||
self.name=name
|
||||
self.flag=flag
|
||||
|
||||
@@ -6,7 +6,7 @@ import BPyWindow
|
||||
|
||||
mouseViewRay= BPyWindow.mouseViewRay
|
||||
from Blender import Mathutils, Window, Scene, Draw, sys
|
||||
from Blender.Mathutils import CrossVecs, Vector, Intersect, LineIntersect, AngleBetweenVecs
|
||||
from Blender.Mathutils import Vector, Intersect, LineIntersect, AngleBetweenVecs
|
||||
LMB= Window.MButs['L']
|
||||
|
||||
def mouseup():
|
||||
@@ -101,11 +101,11 @@ def vertexGradientPick(ob, MODE):
|
||||
|
||||
# make a line 90d to the grad in screenspace.
|
||||
if (OriginA-OriginB).length <= eps: # Persp view. same origin different direction
|
||||
cross_grad= CrossVecs(DirectionA, DirectionB)
|
||||
cross_grad= DirectionA.cross(DirectionB)
|
||||
ORTHO= False
|
||||
|
||||
else: # Ortho - Same direction, different origin
|
||||
cross_grad= CrossVecs(DirectionA, OriginA-OriginB)
|
||||
cross_grad= DirectionA.cross(OriginA-OriginB)
|
||||
ORTHO= True
|
||||
|
||||
cross_grad.normalize()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: latin-1 -*-
|
||||
"""
|
||||
SVG 2 OBJ translater, 0.5.9n
|
||||
Copyright (c) jm soler juillet/novembre 2004-february 2009,
|
||||
SVG 2 OBJ translater, 0.5.9o
|
||||
Copyright (c) jm soler juillet/novembre 2004-april 2009,
|
||||
# ---------------------------------------------------------------
|
||||
released under GNU Licence
|
||||
for the Blender 2.42 Python Scripts Bundle.
|
||||
@@ -255,7 +255,7 @@ Changelog:
|
||||
- removed all debug statements
|
||||
- correction of a zero division error in the calc_arc function.
|
||||
|
||||
0.5.9f: - 2007/15/7
|
||||
0.5.9f: - 2007/15/7
|
||||
- Correction de plusieurs bugs sur l'attributions des couleurs et le nommage
|
||||
des courbes
|
||||
|
||||
@@ -266,6 +266,8 @@ Changelog:
|
||||
0.5.9k : - 14/01/2009
|
||||
0.5.9l : - 31/01/2009
|
||||
0.5.9n : - 01/02/2009
|
||||
0.5.9o : - 04/04/2009, remove pattern if it made with path.
|
||||
|
||||
|
||||
==================================================================================
|
||||
=================================================================================="""
|
||||
@@ -280,6 +282,7 @@ LAST_ID=''
|
||||
LAST_COLOR=[0.0,0.0,0.0,0.0]
|
||||
SEPARATE_CURVES=0
|
||||
USE_COLORS=0
|
||||
PATTERN=0
|
||||
|
||||
SVGCOLORNAMELIST={ 'aliceblue':[240, 248, 255] ,'antiquewhite':[250, 235, 215]
|
||||
,'aqua':[ 0, 255, 255], 'aquamarine':[127, 255, 212]
|
||||
@@ -787,6 +790,7 @@ def polygon(prp):
|
||||
D.append('Z')
|
||||
return D
|
||||
|
||||
|
||||
#--------------------
|
||||
# 0.5.8, to remove exec
|
||||
#--------------------
|
||||
@@ -1462,13 +1466,13 @@ def collect_ATTRIBUTS(data):
|
||||
# --------------------------------------------
|
||||
def build_HIERARCHY(t):
|
||||
global CP, curves, SCALE, DEBUG, BOUNDINGBOX, scale_, tagTRANSFORM
|
||||
global LAST_ID
|
||||
global LAST_ID, PATTERN
|
||||
TRANSFORM=0
|
||||
t=t.replace('\t',' ')
|
||||
while t.find(' ')!=-1: t=t.replace(' ',' ')
|
||||
n0=0
|
||||
t0=t1=0
|
||||
baliste=[]
|
||||
#baliste=[]
|
||||
balisetype=['?','?','/','/','!','!']
|
||||
BALISES=['D', #DECL_TEXTE',
|
||||
'D', #DECL_TEXTE',
|
||||
@@ -1490,26 +1494,37 @@ def build_HIERARCHY(t):
|
||||
if t0>-1 and t1>-1:
|
||||
if t[t0+1] in balisetype:
|
||||
b=balisetype.index(t[t0+1])
|
||||
|
||||
if t[t0+2]=='-':
|
||||
b=balisetype.index(t[t0+1])+1
|
||||
|
||||
balise=BALISES[b]
|
||||
|
||||
if b==2:
|
||||
parent=STACK.pop(-1)
|
||||
if parent!=None and TRANSFORM>0:
|
||||
TRANSFORM-=1
|
||||
|
||||
elif t[t1-1] in balisetype:
|
||||
balise=BALISES[balisetype.index(t[t1-1])+1]
|
||||
|
||||
else:
|
||||
t2=t.find(' ',t0)
|
||||
if t2>t1: t2=t1
|
||||
ouvrante=1
|
||||
NOM=t[t0+1:t2]
|
||||
|
||||
|
||||
if '</'+NOM in t: #.find('</'+NOM)>-1:
|
||||
balise=BALISES[-1]
|
||||
if NOM=='pattern' and not PATTERN:
|
||||
t1=t.find('</'+NOM+'>',t0)+len('</'+NOM+'>')
|
||||
balise=BALISES[-3]
|
||||
else:
|
||||
balise=BALISES[-2]
|
||||
|
||||
if balise=='E' or balise=='O':
|
||||
|
||||
proprietes=collect_ATTRIBUTS(t[t0:t1+ouvrante])
|
||||
|
||||
if 'id' in proprietes:
|
||||
@@ -1532,6 +1547,11 @@ def build_HIERARCHY(t):
|
||||
# 0.5.8, to remove exec
|
||||
#--------------------
|
||||
D=OTHERSSHAPES[proprietes['TYPE']](proprietes)
|
||||
|
||||
#elif proprietes['TYPE'] in ['pattern']:
|
||||
# print 'pattern'
|
||||
# D=''
|
||||
|
||||
CP=[0.0,0.0]
|
||||
if len(D)>0:
|
||||
cursor=0
|
||||
@@ -1567,7 +1587,7 @@ def build_HIERARCHY(t):
|
||||
|
||||
def scan_FILE(nom):
|
||||
global CP, curves, SCALE, DEBUG, BOUNDINGBOX, scale_, tagTRANSFORM
|
||||
global SEPARATE_CURVES, USE_COLORS
|
||||
global SEPARATE_CURVES, USE_COLORS, PATTERN
|
||||
|
||||
dir,name=split(nom)
|
||||
name=name.split('.')
|
||||
@@ -1583,13 +1603,14 @@ def scan_FILE(nom):
|
||||
togAS = Blender.Draw.Create(0)
|
||||
togSP = Blender.Draw.Create(0)
|
||||
togCOL = Blender.Draw.Create(0)
|
||||
Pattern= Blender.Draw.Create(0)
|
||||
block=[\
|
||||
("Clamp Width 1", togW, "Rescale the import with a Width of one unit"),\
|
||||
("Clamp Height 1", togH, "Rescale the import with a Heightof one unit"),\
|
||||
("No Rescaling", togAS, "No rescaling, the result can be very large"),\
|
||||
("Separate Curves", togSP, "Create an object for each curve, Slower. May manage colors"),\
|
||||
("Import Colors", togCOL, "try to import color if the path is set as 'fill'. Only With separate option")]
|
||||
|
||||
("Import Colors", togCOL, "try to import color if the path is set as 'fill'. Only With separate option"),\
|
||||
("Import Patterns", Pattern, "import pattern content if it is made with paths.")]
|
||||
retval = Blender.Draw.PupBlock("Import Options", block)
|
||||
if togW.val: scale_=1
|
||||
elif togH.val: scale_=2
|
||||
@@ -1598,6 +1619,8 @@ def scan_FILE(nom):
|
||||
if togSP.val: SEPARATE_CURVES=1
|
||||
|
||||
if togCOL.val and SEPARATE_CURVES : USE_COLORS=1
|
||||
|
||||
if Pattern.val : PATTERN =1
|
||||
|
||||
t1=Blender.sys.time()
|
||||
# 0.4.1 : to avoid to use sax and the xml
|
||||
@@ -1625,4 +1648,4 @@ def functionSELECT(nom):
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
Blender.Window.FileSelector (functionSELECT, 'SELECT an .SVG FILE', '*.svg')
|
||||
Blender.Window.FileSelector (functionSELECT, 'SELECT an .SVG FILE', '*.svg')
|
||||
Reference in New Issue
Block a user