[Bf-extensions-cvs] [5b721956] master: DXF-exporter: initial port to 2.80

migius noreply at git.blender.org
Sat Dec 22 18:45:06 CET 2018


Commit: 5b721956621c34b849281eddd9399fa7c9e1f399
Author: migius
Date:   Sat Dec 22 18:45:41 2018 +0100
Branches: master
https://developer.blender.org/rBA5b721956621c34b849281eddd9399fa7c9e1f399

DXF-exporter: initial port to 2.80

===================================================================

M	io_export_dxf/__init__.py
M	io_export_dxf/export_dxf.py
M	io_export_dxf/operator.py
M	io_export_dxf/primitive_exporters/base_exporter.py
M	io_export_dxf/primitive_exporters/insert_exporter.py
M	io_export_dxf/primitive_exporters/mesh_exporter.py
M	io_export_dxf/primitive_exporters/text_exporter.py

===================================================================

diff --git a/io_export_dxf/__init__.py b/io_export_dxf/__init__.py
index 41fd79e6..9d2e24c8 100644
--- a/io_export_dxf/__init__.py
+++ b/io_export_dxf/__init__.py
@@ -19,13 +19,12 @@
 bl_info = {
     "name": "Export Autocad DXF Format (.dxf)",
     "author": "Remigiusz Fiedler (AKA migius), Vaclav Klecanda",
-    "version": (2, 1, 3),
-    "blender": (2, 63, 0),
-    "location": "File > Export > Autodesk (.dxf)",
+    "version": (2, 2, 3),
+    "blender": (2, 80, 0),
+    "location": "File > Export > AutoCAD DXF",
     "description": "The script exports Blender geometry to DXF format r12 version.",
     "warning": "Under construction! Visit Wiki for details.",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-        "Scripts/Import-Export/DXF_Exporter",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/DXF_Exporter",
     "category": "Import-Export",
 }
 
@@ -38,26 +37,24 @@ import bpy
 from . import operator
 
 def menu_func(self, context):
-    self.layout.operator(operator.DXFExporter.bl_idname, text="Autocad (.dxf)")
+    self.layout.operator(operator.DXFExporter.bl_idname, text="AutoCAD DXF")
 
 classes = (
     operator.DXFExporter,
 )
 
 def register():
-    bpy.types.TOPBAR_MT_file_export.append(menu_func)
-
     from bpy.utils import register_class
     for cls in classes:
         register_class(cls)
+    bpy.types.TOPBAR_MT_file_export.append(menu_func)
 
 
 def unregister():
-    bpy.types.TOPBAR_MT_file_export.remove(menu_func)
-
     from bpy.utils import unregister_class
     for cls in reversed(classes):
         unregister_class(cls)
-
+    bpy.types.TOPBAR_MT_file_export.remove(menu_func)
+    
 if __name__ == "__main__":
     register()
diff --git a/io_export_dxf/export_dxf.py b/io_export_dxf/export_dxf.py
index 934ae90e..66913b6a 100644
--- a/io_export_dxf/export_dxf.py
+++ b/io_export_dxf/export_dxf.py
@@ -21,156 +21,157 @@ import mathutils
 
 DEBUG = os.environ.get('BLENDER_DEBUG', False) #activates debug mode
 if DEBUG:
-	import sys
-	sys.path.append(os.environ['PYDEV_DEBUG_PATH'])
-	import pydevd
+    import sys
+    sys.path.append(os.environ['PYDEV_DEBUG_PATH'])
+    import pydevd
 
 from .model.migiusModel import MigiusDXFLibDrawing
 
 SUPPORTED_TYPES = ('MESH')#,'CURVE','EMPTY','TEXT','CAMERA','LIGHT')
 
 def exportDXF(context, filePath, settings):
-	"""
-	Main entry point into export facility.
-	"""
-	print("----------\nExporting to {}".format(filePath))
-	import time
-	time1 = time.clock()
-
-	if settings['verbose']:
-		print("Generating Object list for export... (Root parents only)")
-
-	scene = context.scene
-
-	if settings['onlySelected'] is True:
-		objects = (ob for ob in scene.objects if ob.is_visible(scene) and ob.select and ob.type in SUPPORTED_TYPES)
-	else:
-		objects = (ob for ob in scene.objects if ob.is_visible(scene) and ob.type in SUPPORTED_TYPES)
-
-	if DEBUG: pydevd.settrace()
-	mw = get_view_projection_matrix(context, settings)
-
-	try:
-		# add Entities --------------------
-		#todo: fixme: seems to be the reason for missing BLOCK-export
-		#if APPLY_MODIFIERS: tmp_me = Mesh.New('tmp')
-		#else: tmp_me = None
-
-		drawing = MigiusDXFLibDrawing()
-		exported = 0
-		for o in objects:
-			if _exportItem(context, o, mw, drawing, settings):
-				exported +=1
-
-		if not drawing.isEmpty():
-			# NOTE: Only orthographic projection used now.
-	#		if PERSPECTIVE: # generate view border - passepartout
-	#			from .primitive_exporters.viewborder_exporter import ViewBorderDXFExporter
-	#			e = ViewBorderDXFExporter(settings)
-	#			e.export(drawing, ob, mx, mw)
-
-			drawing.convert(filePath)
-
-		duration = time.clock() - time1
-		print('%s objects exported in %.2f seconds. -----DONE-----' %\
-			(exported, duration))
-	except IOError:
-		print('DXF Exporter: Write Error: ', filePath)
-	except Exception as e:
-		print('Nothing exported. Error: %s' % str(e))
-
-	print("Finished")
+    """
+    Main entry point into export facility.
+    """
+    print("----------\nExporting to {}".format(filePath))
+    import time
+    time1 = time.clock()
+
+    if settings['verbose']:
+        print("Generating Object list for export... (Root parents only)")
+
+    scene = context.scene
+    
+    if settings['onlySelected'] is True:
+        objects = (ob for ob in scene.objects if not ob.hide_viewport and ob.select_get() and ob.type in SUPPORTED_TYPES)
+    else:
+        objects = (ob for ob in scene.objects if not ob.hide_viewport and ob.type in SUPPORTED_TYPES)
+
+    if DEBUG: pydevd.settrace()
+    mw = get_view_projection_matrix(context, settings)
+
+    try:
+        # add Entities --------------------
+        #todo: fixme: seems to be the reason for missing BLOCK-export
+        #if APPLY_MODIFIERS: tmp_me = Mesh.New('tmp')
+        #else: tmp_me = None
+
+        drawing = MigiusDXFLibDrawing()
+        exported = 0
+        for o in objects:
+            if _exportItem(context, o, mw, drawing, settings):
+                exported +=1
+
+        if not drawing.isEmpty():
+            # NOTE: Only orthographic projection used now.
+    #		if PERSPECTIVE: # generate view border - passepartout
+    #			from .primitive_exporters.viewborder_exporter import ViewBorderDXFExporter
+    #			e = ViewBorderDXFExporter(settings)
+    #			e.export(drawing, ob, mx, mw)
+
+            drawing.convert(filePath)
+
+        duration = time.clock() - time1
+        print('%s objects exported in %.2f seconds. -----DONE-----' %\
+            (exported, duration))
+    except IOError:
+        print('DXF Exporter: Write Error: ', filePath)
+    except Exception as e:
+        print('Nothing exported. Error: %s' % str(e))
+
+    print("Finished")
 
 #-------------------------------------------------
 def getCommons(ob, settings):
-	"""set up common attributes for output style:
-	 color=None
-	 extrusion=None
-	 layer='0',
-	 lineType=None
-	 lineTypeScale=None
-	 lineWeight=None
-	 thickness=None
-	 parent=None
-	"""
-
-	BYBLOCK=0 #DXF-attribute: assign property to BLOCK defaults
-	BYLAYER=None #256 #DXF-attribute: assign property to LAYER defaults
-	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
-
-	layers = ob.layers #gives a list e.g.[1,5,19]
-	if layers: ob_layer_nr = layers[0]
-	if DEBUG: print('ob_layer_nr=', ob_layer_nr) #--------------
-
-	materials = ob.material_slots
-	if materials:
-		ob_material = materials[0]
-		ob_mat_color = ob_material.material.diffuse_color
-	else: ob_mat_color, ob_material = None, None
-	if DEBUG:
-		print('ob_mat_color, ob_material=', ob_mat_color, ob_material) #--------------
-
-	data_materials = ob.material_slots
-	if data_materials:
-		data_material = data_materials[0]
-		data_mat_color = data_material.material.diffuse_color
-	else: data_mat_color, data_material = None, None
-	if DEBUG:
-		print('data_mat_color, data_material=', data_mat_color, data_material) #--------------
-
-	entitylayer = ENTITYLAYER_DEF
-	c = settings['entitylayer_from']
-	#["default_LAYER","obj.name","obj.layer","obj.material","obj.data.name","obj.data.material","..vertexgroup","..group","..map_table"]
-	if c=="default_LAYER":
-		entitylayer = LAYERNAME_DEF
-	elif c=="obj.layer" and ob_layer_nr:
-		entitylayer = 'LAYER'+ str(ob_layer_nr)
-	elif c=="obj.material" and ob_material:
-		entitylayer = ob_material.name
-	elif c=="obj.name":
-		entitylayer = ob.name
-	elif c=="obj.data.material" and ob_material:
-		entitylayer = data_material.name
-	elif c=="obj.data.name":
-		entitylayer = ob.data.name
-
-	entitycolor = ENTITYCOLOR_DEF
-	cfrom = settings['entitycolor_from']
-	if cfrom=="default_COLOR":
-		entitycolor = LAYERCOLOR_DEF
-	elif cfrom=="BYLAYER":
-		entitycolor = BYLAYER
-	elif cfrom=="BYBLOCK":
-		entitycolor = BYBLOCK
-	elif cfrom=="obj.layer" and ob_layer_nr:
-		entitycolor = ob_layer_nr
-	elif cfrom=="obj.color" and ob.color:
-		entitycolor = ob.color
-	elif cfrom=="obj.material" and ob_mat_color:
-		entitycolor = ob_mat_color
-	elif cfrom=="obj.data.material" and data_mat_color:
-		entitycolor = data_mat_color
-
-	entityltype = ENTITYLTYPE_DEF
-	etype = settings['entityltype_from']
-	if etype=="default_LTYPE":
-		entityltype = LAYERLTYPE_DEF
-	elif etype=="BYLAYER":
-		entityltype = BYLAYER
-	elif etype=="BYBLOCK":
-		entityltype = BYBLOCK
-	elif etype:
-		entityltype = etype
-
-	return entitylayer, entitycolor, entityltype
+    """set up common attributes for output style:
+     color=None
+     extrusion=None
+     layer='0',
+     lineType=None
+     lineTypeScale=None
+     lineWeight=None
+     thickness=None
+     parent=None
+    """
+
+    BYBLOCK=0 #DXF-attribute: assign property to BLOCK defaults
+    BYLAYER=None #256 #DXF-attribute: assign property to LAYER defaults
+    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
+
+    #layers = ob.layers #gives a list e.g.[1,5,19]
+    layers = ob.users_collection
+    if layers: ob_layer_nr = layers[0]
+    if DEBUG: print('ob_layer_nr=', ob_layer_nr) #--------------
+
+    materials = ob.material_slots
+    if materials:
+        ob_material = materials[0]
+        ob_mat_color = ob_material.material.diffuse_color
+    else: ob_mat_color, ob_material = None, None
+    if DEBUG:
+        print('ob_mat_color, ob_material=', ob_mat_color, ob_material) #--------------
+
+    data_materials = ob.material_slots
+    if data_materials:
+        data_material = data_materials[0]
+        data_mat_color = data_material.material.diffuse_color
+    else: data_mat_color, data_material = None, None
+    if DEBUG:
+        print('data_mat_color, data_material=', data_mat_color, data_material) #--------------
+
+    entitylayer = ENTITYLAYER_DEF
+    c = settings['entitylayer_from']
+   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list