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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'io_export_dxf/primitive_exporters')
-rw-r--r--io_export_dxf/primitive_exporters/__init__.py2
-rw-r--r--io_export_dxf/primitive_exporters/base_exporter.py46
-rw-r--r--io_export_dxf/primitive_exporters/curve_exporter.py22
-rw-r--r--io_export_dxf/primitive_exporters/insert_exporter.py2
-rw-r--r--io_export_dxf/primitive_exporters/mesh_exporter.py20
-rw-r--r--io_export_dxf/primitive_exporters/text_exporter.py2
6 files changed, 47 insertions, 47 deletions
diff --git a/io_export_dxf/primitive_exporters/__init__.py b/io_export_dxf/primitive_exporters/__init__.py
index 8e49ba00..d1cfad46 100644
--- a/io_export_dxf/primitive_exporters/__init__.py
+++ b/io_export_dxf/primitive_exporters/__init__.py
@@ -6,5 +6,5 @@ that is being exported from export_dxf.py in ../
NOTE: Only MESH exporter has been ported since it is imho
mostly used. I am not specialist on Autocad so I cannot
guest how many time the other primitive are used. That's
-why they are left unported.
+why they are left unported.
"""
diff --git a/io_export_dxf/primitive_exporters/base_exporter.py b/io_export_dxf/primitive_exporters/base_exporter.py
index b85dc127..2542a1c0 100644
--- a/io_export_dxf/primitive_exporters/base_exporter.py
+++ b/io_export_dxf/primitive_exporters/base_exporter.py
@@ -1,14 +1,14 @@
import mathutils
class BasePrimitiveDXFExporter(object):
-
+
INSTANCES = False
PROJECTION = False
HIDDEN_LINES = False
-
+
def __init__(self, settings):
self._settings = settings
-
+
def projected_co(self, verts, matrix):
""" converts coordinates of points from OCS to WCS->ScreenCS
needs matrix: a projection matrix
@@ -18,11 +18,11 @@ class BasePrimitiveDXFExporter(object):
#print 'deb:projected_co() verts=', verts #---------
temp_verts = [matrix*mathutils.Vector(v) for v in verts]
#print 'deb:projected_co() temp_verts=', temp_verts #---------
-
+
# if GUI_A['Z_force_on'].val: locZ = GUI_A['Z_elev'].val
# else:locZ = 0.0
locZ = 0.0
-
+
if self.PROJECTION:
if self.PERSPECTIVE:
clipStart = 10.0
@@ -36,7 +36,7 @@ class BasePrimitiveDXFExporter(object):
temp_verts = [v[:3] for v in temp_verts]
#print 'deb:projected_co() out_verts=', temp_verts #---------
return temp_verts
-
+
def isLeftHand(self, matrix):
#Is the matrix a left-hand-system, or not?
ma = matrix.to_euler().to_matrix()
@@ -44,7 +44,7 @@ class BasePrimitiveDXFExporter(object):
check = self.M_DotVecs(ma[2], crossXY)
if check < 0.00001: return 1
return 0
-
+
#-----------------------------------------------------
def hidden_status(self, faces, mx, mx_n):
# sort out back-faces = with normals pointed away from camera
@@ -63,8 +63,8 @@ class BasePrimitiveDXFExporter(object):
#print 'deb:2vec_normal=', vec_normal #------------------
#vec_normal *= mw0.rotationPart()
#print 'deb:3vec_normal=', vec_normal, '\n' #------------------
-
-
+
+
frontFace = False
if not self.PERSPECTIVE: #for ortho mode ----------
# normal must point the Z direction-hemisphere
@@ -75,14 +75,14 @@ class BasePrimitiveDXFExporter(object):
vert = mathutils.Vector(v.co) * mx
if mathutils.DotVecs(vert, vec_normal) < 0.00001:
frontFace = True
-
+
if frontFace:
front_faces.append(f.index)
for key in f.edge_keys:
#this test can be done faster with set()
if key not in front_edges:
front_edges.append(key)
-
+
#print 'deb: amount of visible faces=', len(front_faces) #---------
#print 'deb: visible faces=', front_faces #---------
#print 'deb: amount of visible edges=', len(front_edges) #---------
@@ -100,7 +100,7 @@ class BasePrimitiveDXFExporter(object):
# p[1] += G_ORIGIN[1]
# p[2] += G_ORIGIN[2]
return points
-
+
#---- migration to 2.49-------------------------------------------------
#Draw.PupMenu('DXF exporter: Abort%t|This script version works for Blender up 2.49 only!')
@@ -109,12 +109,12 @@ class BasePrimitiveDXFExporter(object):
return v1.cross(v2) #for up2.49
else:
return mathutils.CrossVecs(v1,v2) #for pre2.49
-
+
def M_DotVecs(self, v1,v2):
if 'cross' in dir(mathutils.Vector()):
return v1.dot(v2) #for up2.49
else:
- return mathutils.DotVecs(v1,v2) #for pre2.49
+ return mathutils.DotVecs(v1,v2) #for pre2.49
#-----------------------------------------------------
def getExtrusion(self, matrix):
@@ -134,18 +134,18 @@ class BasePrimitiveDXFExporter(object):
#print 'deb:\n' #-------------
#print 'deb:getExtrusion() Extrusion=', Extrusion #---------
return Extrusion, AXaxis.normalize()
-
+
#-----------------------------------------------------
# def getZRotation(AXaxis, rot_matrix_invert):
# """calculates ZRotation = angle between ArbitraryXvector and obj.matrix.Xaxis
-#
+#
# """
# # this works: Xaxis is the obj.matrix-Xaxis vector
# # but not correct for all orientations
# #Xaxis = matrix[0].copy().resize3D() # = ArbitraryXvector
# ##Xaxis.normalize() # = ArbitraryXvector
# #ZRotation = - mathutils.AngleBetweenVecs(Xaxis,AXaxis) #output in radians
-#
+#
# # this works for all orientations, maybe a bit faster
# # transform AXaxis into OCS:Object-Coord-System
# #rot_matrix = normalizeMat(matrix.rotationPart())
@@ -155,11 +155,11 @@ class BasePrimitiveDXFExporter(object):
# ##vec.normalize() # not needed for atan2()
# #print '\ndeb:getExtrusion() vec=', vec #---------
# ZRotation = - atan2(vec[1],vec[0]) #output in radians
-#
+#
# #print 'deb:ZRotation() ZRotation=', ZRotation*r2d #---------
# return ZRotation
-#
-#
+#
+#
# #-----------------------------------------------------
# def getTargetOrientation(mx,Extrusion,AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ):
# """given
@@ -175,11 +175,11 @@ class BasePrimitiveDXFExporter(object):
# else: #TODO: to check, why below rot_matrix_invert is not equal above one
# rot_euler_matrix = euler2matrix(rotX,rotY,rotZ)
# rot_matrix_invert = euler2matrix(-rotX,-rotY,-rotZ)
-#
+#
# # OCS_origin is Global_Origin in ObjectCoordSystem
# OCS_origin = mathutils.Vector(WCS_loc) * rot_matrix_invert
# #print 'deb: OCS_origin=', OCS_origin #---------
-#
+#
# ZRotation = rotZ
# if Extrusion!=None:
# ZRotation = getZRotation(AXaxis,rot_matrix_invert)
@@ -187,7 +187,7 @@ class BasePrimitiveDXFExporter(object):
# rs, rc = sin(ZRotation), cos(ZRotation)
# Zrotmatrix = mathutils.Matrix([rc, rs,0.0],[-rs,rc,0.0],[0.0,0.0,1.0])
# #print 'deb: Zrotmatrix=\n', Zrotmatrix #--------------
-#
+#
# # ECS_origin is Global_Origin in EntityCoordSystem
# ECS_origin = OCS_origin * Zrotmatrix
# #print 'deb: ECS_origin=', ECS_origin #---------
diff --git a/io_export_dxf/primitive_exporters/curve_exporter.py b/io_export_dxf/primitive_exporters/curve_exporter.py
index d74a459f..09372cad 100644
--- a/io_export_dxf/primitive_exporters/curve_exporter.py
+++ b/io_export_dxf/primitive_exporters/curve_exporter.py
@@ -32,7 +32,7 @@ def exportCurve(ob, mx, mw, **common):
if not PROJECTION:
#Extrusion, ZRotation, Elevation = getExtrusion(mx)
Extrusion, AXaxis = getExtrusion(imx)
-
+
# no thickness/width for POLYLINEs converted into Screen-C-S
#print 'deb: curve.ext1=', curve.ext1 #---------
if curve.ext1: Thickness = curve.ext1 * sizeZ
@@ -66,7 +66,7 @@ def exportCurve(ob, mx, mw, **common):
rotY = ob.RotY
rotZ = ob.RotZ
#print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #---------
-
+
Thickness,Extrusion,ZRotation,Elevation = None,None,None,None
ZRotation,Zrotmatrix,OCS_origin,ECS_origin = None,None,None,None
AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector
@@ -74,7 +74,7 @@ def exportCurve(ob, mx, mw, **common):
if not PROJECTION:
#Extrusion, ZRotation, Elevation = getExtrusion(mx)
Extrusion, AXaxis = getExtrusion(mx)
-
+
# no thickness/width for POLYLINEs converted into Screen-C-S
#print 'deb: curve.ext1=', curve.ext1 #---------
if curve.ext1: Thickness = curve.ext1 * sizeZ
@@ -174,7 +174,7 @@ def writeCurveEntities(curve, mx,
#print 'deb: pkt=', pkt #---------
points.append(pkt)
flags.append([None, [width1,width2]])
-
+
#print 'deb: points', points #--------------
if len(points)>1:
c = curve_as_list[GUI_A['curve_as'].val]
@@ -192,13 +192,13 @@ def writeCurveEntities(curve, mx,
else:
points = projected_co(points, mx)
#print 'deb: points', points #--------------
-
+
if cur.isCyclic(): closed = 1
else: closed = 0
points = toGlobalOrigin(points)
points_temp = []
for p,f in zip(points,flags):
- points_temp.append([p,f[0],f[1]])
+ points_temp.append([p,f[0],f[1]])
points = points_temp
#print 'deb: points', points #--------------
@@ -209,7 +209,7 @@ def writeCurveEntities(curve, mx,
##common['elevation']= Elevation
common['thickness']= Thickness
#print 'deb: common=', common #------------------
-
+
flag70, flag75 = pflag70+closed, pflag75
if 0: #DEBUG
p=AXaxis[:3]
@@ -222,20 +222,20 @@ def writeCurveEntities(curve, mx,
#OCS_origin=[0,0,0] #only debug----------------
dxfPLINE = DXF.PolyLine(points,OCS_origin, flag70=flag70, flag75=flag70, width=0.0,**common)
entities.append(dxfPLINE)
-
+
dxfPLINE = DXF.PolyLine(points,OCS_origin, flag70=flag70, flag75=flag70, width=0.0,**common)
entities.append(dxfPLINE)
if Thickness:
common['thickness']= -Thickness
dxfPLINE = DXF.PolyLine(points,OCS_origin, flag70=flag70, flag75=flag70, width=0.0,**common)
entities.append(dxfPLINE)
-
+
elif c=="LINEs": # export Curve as multiple LINEs
points = projected_co(points, mx)
if cur.isCyclic(): points.append(points[0])
#print 'deb: points', points #--------------
points = toGlobalOrigin(points)
-
+
if DEBUG: curve_drawBlender(points,WCS_loc,closed) #deb: draw to scene
common['extrusion']= Extrusion
common['elevation']= Elevation
@@ -251,7 +251,7 @@ def writeCurveEntities(curve, mx,
linepoints = [points[i], points[i+1]]
dxfLINE = DXF.Line(linepoints,**common)
entities.append(dxfLINE)
-
+
elif c=="POINTs": # export Curve as multiple POINTs
points = projected_co(points, mx)
for p in points:
diff --git a/io_export_dxf/primitive_exporters/insert_exporter.py b/io_export_dxf/primitive_exporters/insert_exporter.py
index 80cf7dbd..46382e3d 100644
--- a/io_export_dxf/primitive_exporters/insert_exporter.py
+++ b/io_export_dxf/primitive_exporters/insert_exporter.py
@@ -43,7 +43,7 @@ def exportInsert(ob, mx, insert_name, **common):
#TODO: ? sizeX *= coef
#sizeY *= coef
#sizeZ *= coef
-
+
#print 'deb: point=', point #--------------
[point] = toGlobalOrigin([point])
diff --git a/io_export_dxf/primitive_exporters/mesh_exporter.py b/io_export_dxf/primitive_exporters/mesh_exporter.py
index 9764796b..69834871 100644
--- a/io_export_dxf/primitive_exporters/mesh_exporter.py
+++ b/io_export_dxf/primitive_exporters/mesh_exporter.py
@@ -4,7 +4,7 @@ from .base_exporter import BasePrimitiveDXFExporter
import copy
class MeshDXFExporter(BasePrimitiveDXFExporter):
-
+
def export(self, ctx, drawing, ob, mx, mx_n, **kwargs):
"""
Converts Mesh-Object to desired projection and representation(DXF-Entity type)
@@ -15,7 +15,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
# it manipulates original geometry and by retransformation lefts back rounding-errors
# we dont want to manipulate original data!
#temp_verts = me.verts[:] #doesn't work on ubuntu(Yorik), bug?
- if me.vertices:
+ if me.vertices:
# check if there are more instances of this mesh (if used by other objects), then write to BLOCK/INSERT
if self.INSTANCES and me.users>1 and not self.PROJECTION and not (ob.modifiers and self._settings['apply_modifiers']):
if drawing.containsBlock(me.name):
@@ -40,15 +40,15 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
# block = DXF.Block(insert_name,flag=0,base=(0,0,0),entities=entities)
# write INSERT as entity
entities = self._writeInsert(ob, mx, me.name, **(kwargs))
-
+
else: # no other instances, so go the standard way
return self._standard_way(drawing, me, mx, mx_n)
-
+
def _writeInsert(self, drawing, ob, mx, insert_name, **kwargs):
from insert_exporter import InsertDXFExporter
ex = InsertDXFExporter(self._settings)
ex.export(drawing, ob, mx, insert_name, **(kwargs))
-
+
def _getMeshData(self, ctx, obj, settings):
if obj.modifiers and settings['apply_modifiers']:
#this gets mesh with applied modifiers
@@ -57,7 +57,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
# me = ob.getData(mesh=1) # is a Mesh if mesh>0 (otherwise it is a NMesh)
data = obj.data
return data
-
+
def _standard_way(self, drawing, me, mx, mx_n, **kwargs):
allpoints = [v.co for v in me.vertices]
allpoints = self.projected_co(allpoints, mx)
@@ -92,7 +92,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
for type, args in entities:
drawing.addEntity(type, **(args))
return True
-
+
def _writeMeshEntities(self, allpoints, edges, faces, **kwargs):
"""help routine for exportMesh()
"""
@@ -115,7 +115,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
elif c in {'POLYFACE', 'POLYLINE'}:
if faces and allpoints:
#TODO: purge allpoints: left only vertices used by faces
-# if exportsettings['verbose']:
+# if exportsettings['verbose']:
# mesh_drawBlender(allpoints, None, faces) #deb: draw to scene
if not (self.PROJECTION and self.HIDDEN_LINES):
faces = [[v+1 for v in f.vertices] for f in faces]
@@ -129,7 +129,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
i,newverts=0,[]
for used_i,used in enumerate(verts_state):
if used:
- newverts.append(allpoints[used_i])
+ newverts.append(allpoints[used_i])
map[used_i]=i
i+=1
allpoints = newverts
@@ -142,7 +142,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
entities.append(('PolyLine', args))
elif c=='3DFACEs':
if faces and allpoints:
-# if exportsettings['verbose']:
+# if exportsettings['verbose']:
# mesh_drawBlender(allpoints, None, faces) #deb: draw to scene
for f in faces:
points = [allpoints[v_id] for v_id in f.vertices]
diff --git a/io_export_dxf/primitive_exporters/text_exporter.py b/io_export_dxf/primitive_exporters/text_exporter.py
index 98693aec..52d19725 100644
--- a/io_export_dxf/primitive_exporters/text_exporter.py
+++ b/io_export_dxf/primitive_exporters/text_exporter.py
@@ -60,7 +60,7 @@ def exportText(ob, mx, mw, **common):
coef = -clipStart / (point1*mx)[2]
textHeight *= coef
#print 'deb: coef=', coef #--------------
-
+
#print 'deb: point=', point #--------------
[point] = toGlobalOrigin([point])
point2 = point