DXF exporter, dxf-library.py updated

v1.28 - 2008.12.13 by Steeve/BlenderArtists
- bugfix for EXTMIN/EXTMAX to suit Cycas-CAD
This commit is contained in:
2008-12-14 21:26:24 +00:00
parent c794e13ba3
commit e7c0666d96

View File

@@ -1,10 +1,10 @@
#dxfLibrary.py : provides functions for generating DXF files #dxfLibrary.py : provides functions for generating DXF files
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
__version__ = "v1.27beta - 2008.10.05" __version__ = "v1.28beta - 2008.12.13"
__author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)" __author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)"
__license__ = "GPL" __license__ = "GPL"
__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf" __url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
__bpydoc__ ="""The script exports geometry data to DXF format r12 version. __bpydoc__ ="""The library to export geometry data to DXF format r12 version.
Copyright %s Copyright %s
Version %s Version %s
@@ -12,15 +12,17 @@ License %s
Homepage %s Homepage %s
See the homepage for documentation. See the homepage for documentation.
url: Dedicated thread on BlenderArtists: http://blenderartists.org/forum/showthread.php?t=136439
IDEAs: IDEAs:
- -
TODO: TODO:
- - add support for SPLINEs
History History
v1.28 - 2008.12.13 by Steeve/BlenderArtists
- bugfix for EXTMIN/EXTMAX to suit Cycas-CAD
v1.27 - 2008.10.07 by migius v1.27 - 2008.10.07 by migius
- beautifying output code: keys whitespace prefix - beautifying output code: keys whitespace prefix
- refactoring DXF-strings format: NewLine moved to the end of - refactoring DXF-strings format: NewLine moved to the end of
@@ -239,7 +241,7 @@ class Face(_Entity):
"""3dface""" """3dface"""
def __init__(self,points,**common): def __init__(self,points,**common):
_Entity.__init__(self,**common) _Entity.__init__(self,**common)
if len(points)<4: #fix for r12 format while len(points)<4: #fix for r12 format
points.append(points[-1]) points.append(points[-1])
self.points=points self.points=points
@@ -336,10 +338,14 @@ class PolyLine(_Entity):
#----------------------------------------------- #-----------------------------------------------
class Point(_Entity): class Point(_Entity):
"""Colored solid fill.""" """Point."""
def __init__(self,points=None,**common): def __init__(self,points=None,**common):
_Entity.__init__(self,**common) _Entity.__init__(self,**common)
self.points=points self.points=points
def __str__(self): #TODO:
return ' 0\nPOINT\n%s%s\n' %(self._common(),
_points(self.points)
)
#----------------------------------------------- #-----------------------------------------------
class Solid(_Entity): class Solid(_Entity):
@@ -468,7 +474,7 @@ class Block(_Collection):
self.name=name self.name=name
self.flag=0 self.flag=0
self.base=base self.base=base
def __str__(self): def __str__(self): #TODO:
e=''.join([str(x)for x in self.entities]) e=''.join([str(x)for x in self.entities])
return ' 0\nBLOCK\n 8\n%s\n 2\n%s\n 70\n%s\n%s\n 3\n%s\n%s 0\nENDBLK\n'%\ return ' 0\nBLOCK\n 8\n%s\n 2\n%s\n 70\n%s\n%s\n 3\n%s\n%s 0\nENDBLK\n'%\
(self.layer,self.name.upper(),self.flag,_point(self.base),self.name.upper(),e) (self.layer,self.name.upper(),self.flag,_point(self.base),self.name.upper(),e)
@@ -552,11 +558,12 @@ def ViewByWindow(name,leftBottom=(0,0),rightTop=(1,1),**options):
#----------------------------------------------- #-----------------------------------------------
class Drawing(_Collection): class Drawing(_Collection):
"""Dxf drawing. Use append or any other list methods to add objects.""" """Dxf drawing. Use append or any other list methods to add objects."""
def __init__(self,insbase=(0.0,0.0,0.0),extmin=(0.0,0.0),extmax=(0.0,0.0), def __init__(self,insbase=(0.0,0.0,0.0),extmin=(0.0,0.0,0.0),extmax=(0.0,0.0,0.0),
layers=[Layer()],linetypes=[LineType()],styles=[Style()],blocks=[], layers=[Layer()],linetypes=[LineType()],styles=[Style()],blocks=[],
views=[],entities=None,fileName='test.dxf'): views=[],entities=None,fileName='test.dxf'):
# TODO: replace list with None,arial # TODO: replace list with None,arial
if not entities:entities=[] if not entities:
entities=[]
_Collection.__init__(self,entities) _Collection.__init__(self,entities)
self.insbase=insbase self.insbase=insbase
self.extmin=extmin self.extmin=extmin