Revision: 29582 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29582 Author: migius Date: 2010-06-20 21:21:41 +0200 (Sun, 20 Jun 2010)
Log Message: ----------- DXF-exporter script update: v1.36 - 2010.06.20 by migius - added export Nurbs-Curve (3,4,5th-degree) into POLYLINE-NURBS(quad,cubic) but no support for Bezier-Curves, because DXF doesnt support them DXF-export library update: v1.34 - 2010.06.20 by migius - bugfix POLYFACE - added DXF-flags for POLYLINE and VERTEX class (NURBS-export) Modified Paths: -------------- branches/blender2.4/release/scripts/bpymodules/dxfLibrary.py branches/blender2.4/release/scripts/export_dxf.py Modified: branches/blender2.4/release/scripts/bpymodules/dxfLibrary.py =================================================================== --- branches/blender2.4/release/scripts/bpymodules/dxfLibrary.py 2010-06-20 19:02:26 UTC (rev 29581) +++ branches/blender2.4/release/scripts/bpymodules/dxfLibrary.py 2010-06-20 19:21:41 UTC (rev 29582) @@ -1,6 +1,6 @@ #dxfLibrary.py : provides functions for generating DXF files # -------------------------------------------------------------------------- -__version__ = "v1.33 - 2009.06.16" +__version__ = "v1.34 - 2010.06.20" __author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)" __license__ = "GPL" __url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf" @@ -20,10 +20,15 @@ TODO: - add support for DXFr14 (needs extended file header) - add support for SPLINEs (possible first in DXFr14 version) +- add support for MTEXT - add user preset for floating point precision (3-16?) History -v1.33 - 2009.06.16 by migius +v1.34 - 2010.06.20 by migius + - bugfix POLYFACE + - added DXF-flags for POLYLINE and VERTEX class (NURBS-export) +v1.33 - 2009.07.03 by migius + - fix MTEXT newline bug (not supported by DXF-Exporter yet) - modif _point(): converts all coords to floats - modif LineType class: implement elements - added VPORT class, incl. defaults @@ -93,7 +98,6 @@ #---helper functions----------------------------------- def _point(x,index=0): """Convert tuple to a dxf point""" - #print 'deb: _point=', x #------------- return '\n'.join([' %s\n%s'%((i+1)*10+index,float(x[i])) for i in range(len(x))]) def _points(plist): @@ -205,7 +209,7 @@ AT_LEAST = 1 #taller characters will override EXACT = 2 #taller characters will not override -#---polyline flags +#---polyline flag 70 CLOSED =1 # This is a closed polyline (or a polygon mesh closed in the M direction) CURVE_FIT =2 # Curve-fit vertices have been added SPLINE_FIT =4 # Spline-fit vertices have been added @@ -215,6 +219,12 @@ POLYFACE_MESH =64 # The polyline is a polyface mesh CONTINOUS_LINETYPE_PATTERN =128 # The linetype pattern is generated continuously around the vertices of this polyline +#---polyline flag 75, = curve type +QUADRIC_NURBS = 5 +CUBIC_NURBS = 6 +BEZIER_CURVE = 8 + + #---text flags #horizontal LEFT = 0 @@ -269,7 +279,6 @@ def __str__(self): out = ' 0\n3DFACE\n%s%s\n' %(self._common(),_points(self.points)) - #print 'deb:out=', out #------------------- return out #----------------------------------------------- @@ -318,34 +327,34 @@ #----------------------------------------------- class PolyLine(_Entity): - def __init__(self,points,org_point=[0,0,0],flag=0,width=None,**common): + def __init__(self,points,org_point=[0,0,0],flag70=0,flag75=0,width=None,**common): #width = number, or width = list [width_start=None, width_end=None] - #for 2d-polyline: points = [ [x, y, z, width_start=None, width_end=None, bulge=0 or None], ...] - #for 3d-polyline: points = [ [x, y, z], ...] + #for 2d-polyline: points = [ [[x, y, z], vflag=None, [width_start=None, width_end=None], bulge=0 or None] ...] + #for 3d-polyline: points = [ [[x, y, z], vflag=None], ...] #for polyface: points = [points_list, faces_list] _Entity.__init__(self,**common) self.points=points self.org_point=org_point - self.flag=flag + self.pflag70 = flag70 + self.pflag75 = flag75 self.polyface = False self.polyline2d = False self.faces = [] # dummy value self.width= None # dummy value - if self.flag & POLYFACE_MESH: + if self.pflag70 & POLYFACE_MESH: self.polyface=True self.points=points[0] self.faces=points[1] self.p_count=len(self.points) self.f_count=len(self.faces) - elif not self.flag & POLYLINE_3D: + elif not (self.pflag70 & POLYLINE_3D): self.polyline2d = True if width: - if type(width)!='list': - width=[width,width] + if type(width)!='list': width=[width,width] self.width=width def __str__(self): - result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.flag) + result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.pflag70) result+=' 66\n1\n' result+='%s\n' %_point(self.org_point) if self.polyface: @@ -353,23 +362,32 @@ result+=' 72\n%s\n' %self.f_count elif self.polyline2d: if self.width!=None: result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1]) + if self.pflag75: + result+=' 75\n%s\n' %self.pflag75 for point in self.points: result+=' 0\nVERTEX\n' result+=' 8\n%s\n' %self.layer if self.polyface: - result+='%s\n' %_point(point[0:3]) + result+='%s\n' %_point(point) result+=' 70\n192\n' elif self.polyline2d: - result+='%s\n' %_point(point[0:2]) - if len(point)>4: - width1, width2 = point[3], point[4] + result+='%s\n' %_point(point[0]) + flag = point[1] + if len(point)>2: + [width1, width2] = point[2] if width1!=None: result+=' 40\n%s\n' %width1 if width2!=None: result+=' 41\n%s\n' %width2 - if len(point)==6: - bulge = point[5] + if len(point)==4: + bulge = point[3] if bulge: result+=' 42\n%s\n' %bulge + if flag: + result+=' 70\n%s\n' %flag else: - result+='%s\n' %_point(point[0:3]) + result+='%s\n' %_point(point[0]) + flag = point[1] + if flag: + result+=' 70\n%s\n' %flag + for face in self.faces: result+=' 0\nVERTEX\n' result+=' 8\n%s\n' %self.layer @@ -456,7 +474,7 @@ else:spacingWidth=self.height*self.spacingFactor for text in texts: while text: - result+='%s\n'%Text(text[:self.width], + result+='%s' %Text(text[:self.width], point=(self.point[0]+x*spacingWidth, self.point[1]+y*spacingWidth, self.point[2]), @@ -472,44 +490,47 @@ #----------------------------------------------- ##class _Mtext(_Entity): -## """Mtext not functioning for minimal dxf.""" -## def __init__(self,text='',point=(0,0,0),attachment=1, -## charWidth=None,charHeight=1,direction=1,height=100,rotation=0, -## spacingStyle=None,spacingFactor=None,style=None,width=100, -## xdirection=None,**common): -## _Entity.__init__(self,**common) -## self.text=text -## self.point=point -## self.attachment=attachment -## self.charWidth=charWidth -## self.charHeight=charHeight -## self.direction=direction -## self.height=height -## self.rotation=rotation -## self.spacingStyle=spacingStyle -## self.spacingFactor=spacingFactor -## self.style=style -## self.width=width -## self.xdirection=xdirection -## def __str__(self): -## input=self.text -## text='' -## while len(input)>250: -## text+='3\n%s\n'%input[:250] -## input=input[250:] -## text+='1\n%s\n'%input -## result= '0\nMTEXT\n%s\n%s\n40\n%s\n41\n%s\n71\n%s\n72\n%s%s\n43\n%s\n50\n%s\n'%\ -## (self._common(),_point(self.point),self.charHeight,self.width, -## self.attachment,self.direction,text, -## self.height, -## self.rotation) -## if self.style:result+='7\n%s\n'%self.style -## if self.xdirection:result+='%s\n'%_point(self.xdirection,1) -## if self.charWidth:result+='42\n%s\n'%self.charWidth -## if self.spacingStyle:result+='73\n%s\n'%self.spacingStyle -## if self.spacingFactor:result+='44\n%s\n'%self.spacingFactor -## return result + """Mtext not functioning for minimal dxf.""" + """ + def __init__(self,text='',point=(0,0,0),attachment=1, + charWidth=None,charHeight=1,direction=1,height=100,rotation=0, + spacingStyle=None,spacingFactor=None,style=None,width=100, + xdirection=None,**common): + _Entity.__init__(self,**common) + self.text=text + self.point=point + self.attachment=attachment + self.charWidth=charWidth + self.charHeight=charHeight + self.direction=direction + self.height=height + self.rotation=rotation + self.spacingStyle=spacingStyle + self.spacingFactor=spacingFactor + self.style=style + self.width=width + self.xdirection=xdirection + def __str__(self): + input=self.text + text='' + while len(input)>250: + text+='3\n%s\n'%input[:250] + input=input[250:] + text+='1\n%s\n'%input + result= '0\nMTEXT\n%s\n%s\n40\n%s\n41\n%s\n71\n%s\n72\n%s%s\n43\n%s\n50\n%s\n'%\ + (self._common(),_point(self.point),self.charHeight,self.width, + self.attachment,self.direction,text, + self.height, + self.rotation) + if self.style:result+='7\n%s\n'%self.style + if self.xdirection:result+='%s\n'%_point(self.xdirection,1) + if self.charWidth:result+='42\n%s\n'%self.charWidth + if self.spacingStyle:result+='73\n%s\n'%self.spacingStyle + if self.spacingFactor:result+='44\n%s\n'%self.spacingFactor + return result + """ + #---tables --------------------------------------------------- #----------------------------------------------- class Block(_Collection): @@ -591,11 +612,11 @@ target=(0.0,0.0,0.0), height=1.0, ratio=1.0, - lens=50, - frontClipping=0, - backClipping=0, - snap_rotation=0, - twist=0, + lens=50.0, + frontClipping=0.0, + backClipping=0.0, + snap_rotation=0.0, + twist=0.0, mode=0, circle_zoom=100, fast_zoom=1, @@ -669,15 +690,15 @@ #----------------------------------------------- class View(_Call): def __init__(self,name,flag=0, - width=1, - height=1, + width=1.0, + height=1.0, center=(0.5,0.5), - direction=(0,0,1), - target=(0,0,0), - lens=50, - frontClipping=0, - backClipping=0, - twist=0,mode=0 + direction=(0.0,0.0,1.0), + target=(0.0,0.0,0.0), + lens=50.0, + frontClipping=0.0, + backClipping=0.0, + twist=0.0,mode=0 ): self.name=name self.flag=flag @@ -836,11 +857,12 @@ self.closed=closed self.points=copy.copy(points) def __str__(self): - if self.closed:points=self.points+[self.points[0]] + if self.closed: + points=self.points+[self.points[0]] else: points=self.points result='' for i in range(len(points)-1): - result+= Line(points=[points[i],points[i+1]],parent=self) + result+= Line(points=[points[i][0],points[i+1][0]],parent=self) return result[1:] #----------------------------------------------------- Modified: branches/blender2.4/release/scripts/export_dxf.py =================================================================== --- branches/blender2.4/release/scripts/export_dxf.py 2010-06-20 19:02:26 UTC (rev 29581) +++ branches/blender2.4/release/scripts/export_dxf.py 2010-06-20 19:21:41 UTC (rev 29582) @@ -7,7 +7,7 @@ Tooltip: 'Export geometry to DXF/DWG-r12 (Drawing eXchange Format).' """ -__version__ = "1.35 - 2009.06.18" @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs