[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20490] trunk/blender/release/scripts: bugfix and update DXF-Exporter scripts

Remigiusz Fiedler migius at gmx.net
Fri May 29 08:50:31 CEST 2009


Revision: 20490
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20490
Author:   migius
Date:     2009-05-29 08:50:31 +0200 (Fri, 29 May 2009)

Log Message:
-----------
bugfix and update DXF-Exporter scripts
please get it in 2.49 release

Modified Paths:
--------------
    trunk/blender/release/scripts/bpymodules/dxfLibrary.py
    trunk/blender/release/scripts/export_dxf.py

Modified: trunk/blender/release/scripts/bpymodules/dxfLibrary.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/dxfLibrary.py	2009-05-29 04:30:40 UTC (rev 20489)
+++ trunk/blender/release/scripts/bpymodules/dxfLibrary.py	2009-05-29 06:50:31 UTC (rev 20490)
@@ -1,6 +1,6 @@
 #dxfLibrary.py : provides functions for generating DXF files
 # --------------------------------------------------------------------------
-__version__ = "v1.29beta - 2008.12.28"
+__version__ = "v1.30 - 2009.05.28"
 __author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)"
 __license__ = "GPL"
 __url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
@@ -18,9 +18,12 @@
 -
 
 TODO:
-- add support for SPLINEs, (bad idea, cause DXF r14 object :(
+- add support for DXFr14 (new file header)
+- add support for SPLINEs, although it is DXFr14 object
 
 History
+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
 v1.28 - 2008.12.13 by Steeve/BlenderArtists
@@ -42,7 +45,7 @@
 
 # --------------------------------------------------------------------------
 # 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 +88,6 @@
 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----------------------------------------
@@ -326,7 +328,6 @@
 
 	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:
@@ -337,10 +338,11 @@
 		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
@@ -348,6 +350,8 @@
 				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

Modified: trunk/blender/release/scripts/export_dxf.py
===================================================================
--- trunk/blender/release/scripts/export_dxf.py	2009-05-29 04:30:40 UTC (rev 20489)
+++ trunk/blender/release/scripts/export_dxf.py	2009-05-29 06:50:31 UTC (rev 20490)
@@ -1,47 +1,76 @@
 #!BPY
 
 """
- Name: 'Autodesk (.dxf .dwg)'
- Blender: 247
+ Name: 'Autodesk DXF (.dxf)'
+ Blender: 249
  Group: 'Export'
- Tooltip: 'Export geometry to Autocad DXF/DWG-r12 (Drawing eXchange Format).'
+ Tooltip: 'Export geometry to DXF/DWG-r12 (Drawing eXchange Format).'
 """
 
-__version__ = "v1.29 - 2009.04.11"
-__author__  = "Remigiusz Fiedler (AKA migius), Alexandros Sigalas (AKA alxarch), Stani Michiels"
+__version__ = "1.34 - 2009.05.28"
+__author__  = "Remigiusz Fiedler (AKA migius)"
 __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 Blender geometry to DXF format r12 version.
 
 Version %s
 Copyright %s
 License %s
 
-extern dependances: dxfLibrary.py
+extern dependances: dxfLibrary.py, (optionaly: DConvertCon.exe)
 
+CONTRIBUTORS:
+Remigiusz Fiedler (AKA migius)
+Alexandros Sigalas (AKA alxarch)
+Stani Michiels (AKA stani)
+
 See the homepage for documentation.
 url: %s
 
 IDEAs:
- - correct normals for POLYLINE-POLYFACE via proper point-order
- - HPGL output for 2d and flattened 3d content
-
+- correct normals for POLYLINE-POLYFACE via proper vertex-order
+- HPGL output, especially usefull for correct scaled printing of 2d drawings
+		
 TODO:
 - export dupligroups and dupliverts as blocks ( option for the user to decide ) 
-- optimize back-faces removal (probably needs matrix transform)
 - optimize POLYFACE routine: remove double-vertices
 - optimize POLYFACE routine: remove unused vertices
 - support hierarchies: groups, instances, parented structures
 - support 210-code (3d orientation vector)
-- presets for architectural scales
 - write drawing extends for automatic view positioning in CAD
+- support mapping: materials to DXF-styles
 
 History
-v1.29 - 2009.04.11 by migius
+v1.34 - 2009.05.28 by migius
+- bugfix POLYFACE export, synchronized with dxfLibrary.py
+- changed to the new 2.49 method Vector.cross()
+- output style manager (first try)
+v1.33 - 2009.05.25 by migius
+- bugfix flipping normals in mirrored objects
+- added UI-Button for future Shadow Generator
+- support curve objects in projection-2d mode
+- UI stuff: camera selector/manager
+v1.32 - 2009.05.22 by migius
+- debug mode for curve-objects: output pass to Blender
+- wip support 210-code(extrusion) calculation
+- default settings for 2D and 3D export
+v1.31 - 2009.05.18 by migius
+- globals translated to GUI_A/B dictionary
+- optimizing back-faces removal for "hidden-lines" mode
+- presets for global location and scale (architecture)
+- UI layout: scrollbars, pan with MMB/WHEEL, dynamic width
+- new GUI with Draw.Register() from DXF-importer.py
+v1.30 - 2008.12.14 by migius
+- started work on GUI with Draw.Register()
+v1.29 - 2009.04.11 by stani
 - added DWG support, Stani Michiels idea for binding an extern DXF-DWG-converter 
-v1.28 - 2009.02.05 by alxarch
+v1.28 - 2009.02.05 by Alexandros Sigalas (alxarch)
 - added option to apply modifiers on exported meshes
 - added option to also export duplicates (from dupliverts etc)
+v1.28 - 2008.10.22 by migius
+- workaround for PVert-bug on ubuntu (reported by Yorik)
+- add support for FGons - ignore invisible_tagged edges
+- add support for camera: ortho and perspective
 v1.27 - 2008.10.07 by migius
 - exclude Stani's DXF-Library to extern module
 v1.26 - 2008.10.05 by migius
@@ -92,46 +121,161 @@
 
 
 import Blender
-from Blender import Mathutils, Window, Scene, sys, Draw, Mesh
-import BPyMessages
-try: import os
-except: os = None
-try: import subprocess
-except: subprocess = None
-try: import copy
-except: copy = None
+from Blender import Mathutils, Window, Scene, Draw, Camera, BezTriple
+from Blender import Registry, Object, Mesh
+import os
+import subprocess
 
-#print os.sys.platform
-#print dir(os.sys.version)
-
-#import dxfLibrary
+import dxfLibrary as DXF
+#reload(DXF)
 #reload(dxfLibrary)
-if copy and os:
-    from  dxfLibrary import *
-    #-------- DWG support ------------------------------------------
-    extCONV_OK = True
-    extCONV = 'DConvertCon.exe'
-    extCONV_PATH = os.path.join(Blender.Get('scriptsdir'),extCONV)
-    if not os.path.isfile(extCONV_PATH):
-        extCONV_OK = False
-        extCONV_TEXT = 'DWG-Exporter: Abort, nothing done!|\
-    Copy first %s into Blender script directory.|\
-    More details in online Help.' %extCONV
-    else:
-        if not os.sys.platform.startswith('win'):
-            # check if Wine installed:   
-            if subprocess.Popen(('which', 'winepath'), stdout=subprocess.PIPE).stdout.read().strip():
-                extCONV_PATH    = 'wine %s'%extCONV_PATH
-            else: 
-                extCONV_OK = False
-                extCONV_TEXT = 'DWG-Exporter: Abort, nothing done!|\
-    The external DWG-converter (%s) needs Wine installed on your system.|\
-    More details in online Help.' %extCONV
-    #print 'extCONV_PATH = ', extCONV_PATH
+#from dxfLibrary import *
 
+import math
+from math import atan, log10
 
+#pi = math.pi
+#pi = 3.14159265359
+d2r = math.pi / 180.0
+#note: d2r * angle == math.radians(angle)
 
-#-----------------------------------------------------
+print '\n\n\n'
+print 'DXF-Exporter v%s *** start ***' %(__version__)   #---------------------
+
+#DEBUG = True #activets debug mode
+
+
+#----globals------------------------------------------
+ONLYSELECTED = 1 # 0/1 = False/True
+POLYLINES = 1 # prefer POLYLINEs not LINEs
+POLYFACES = 1 # prefer POLYFACEs not 3DFACEs
+PROJECTION = 0 # flatten output geometry to Z = 0.0
+HIDDEN_LINES = 0 #filter out hidden geometry
+SHADOWS = 0 # sun/shadows simulation
+CAMERA = 1 # view from active camera or from 3d-view
+PERSPECTIVE = 0 #perspective camera
+APPLY_MODIFIERS = 1
+INCLUDE_DUPLIS = 0
+OUTPUT_DWG = 0 #optional save to DWG with extern converter
+
+G_SCALE = 1.0	  #(0.0001-1000) global scaling factor for output dxf data
+G_ORIGIN = [0.0,0.0,0.0]   #global translation-vector (x,y,z) in Blender units
+ELEVATION = 0.0 #standard elevation = coordinate Z value in Blender units
+
+MIN_DIST = 0.001	#cut-off value for sort out short-distance polyline-"duoble_vertex"
+CURV_RESOLUTION = 12 #(1-128) Bezier curves U-resolution
+CURVARC_RESOLUTION = 4 #(3-32) resolution of circle represented as Bezier curve 
+THIN_RESOLUTION = 8   #(4-64) thin_cylinder arc_resolution - number of segments
+MIN_THICK = MIN_DIST * 10.0  #minimal thickness by forced thickness
+MIN_WIDTH = MIN_DIST * 10.0  #minimal width by forced width
+
+BYBLOCK = 0 #DXF-attribute: assign property to BLOCK defaults
+BYLAYER = None #256 #DXF-attribute: assign property to LAYER defaults
+PREFIX = 'BF_' #used as prefix for DXF names
+LAYERNAME_DEF = '' #default layer name
+LAYERCOLOR_DEF = 7 #default layer color index
+LAYERLTYPE_DEF = 0 #'CONTINUOUS' - default layer lineType
+ENTITYLAYER_DEF = LAYERNAME_DEF #default entity color index
+ENTITYCOLOR_DEF = BYLAYER #default entity color index
+ENTITYLTYPE_DEF = BYLAYER #default entity lineType
+E_M = 0
+LAB = "scroll MMB/WHEEL           . wip   .. todo" #"*) parts under construction"
+M_OBJ = 0
+
+FILENAME_MAX = 180  #max length of path+file_name string  (FILE_MAXDIR + FILE_MAXFILE)
+MAX_NAMELENGTH = 17   #max_effective_obnamelength in blender =21=17+(.001)
+INIFILE_DEFAULT_NAME = 'exportDXF'
+INIFILE_EXTENSION = '.ini'

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list