DXF-exporter: initial port to 2.80
This commit is contained in:
parent
07ee2422a0
commit
5b72195662
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
"""
|
||||
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)")
|
||||
if settings['verbose']:
|
||||
print("Generating Object list for export... (Root parents only)")
|
||||
|
||||
scene = context.scene
|
||||
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 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)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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))
|
||||
|
||||
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")
|
||||
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
|
||||
"""
|
||||
"""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
|
||||
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) #--------------
|
||||
#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) #--------------
|
||||
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) #--------------
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
return entitylayer, entitycolor, entityltype
|
||||
|
||||
def getCameraMatrix(cam):
|
||||
raise NotImplementedError()
|
||||
raise NotImplementedError()
|
||||
# camProps = cam.data
|
||||
# mc0 = act_camera.matrix.copy()
|
||||
# #print 'deb: camera.Matrix=\n', mc0 #------------------
|
||||
|
@ -215,70 +216,70 @@ projectionMapping = {
|
|||
|
||||
#-----------------------------------------------------
|
||||
def get_view_projection_matrix(context, settings):
|
||||
"""
|
||||
Returns view projection matrix.
|
||||
Projection matrix is either identity if 3d export is selected or
|
||||
camera projection if a camera or view is selected.
|
||||
Currently only orthographic projection is used. (Subject to discussion).
|
||||
"""
|
||||
cam = settings['projectionThrough']
|
||||
if cam is None:
|
||||
mw = mathutils.Matrix()
|
||||
mw.identity()
|
||||
elif cam in projectionMapping.keys():
|
||||
projection = mathutils.Matrix.OrthoProjection(projectionMapping[cam], 4)
|
||||
mw = projection
|
||||
else: # get camera with given name
|
||||
c = context.scene.objects[cam]
|
||||
mw = getCameraMatrix(c)
|
||||
return mw
|
||||
"""
|
||||
Returns view projection matrix.
|
||||
Projection matrix is either identity if 3d export is selected or
|
||||
camera projection if a camera or view is selected.
|
||||
Currently only orthographic projection is used. (Subject to discussion).
|
||||
"""
|
||||
cam = settings['projectionThrough']
|
||||
if cam is None:
|
||||
mw = mathutils.Matrix()
|
||||
mw.identity()
|
||||
elif cam in projectionMapping.keys():
|
||||
projection = mathutils.Matrix.OrthoProjection(projectionMapping[cam], 4)
|
||||
mw = projection
|
||||
else: # get camera with given name
|
||||
c = context.scene.collection.objects[cam]
|
||||
mw = getCameraMatrix(c)
|
||||
return mw
|
||||
|
||||
def _exportItem(ctx, o, mw, drawing, settings):
|
||||
"""
|
||||
Export one item from export list.
|
||||
mw - modelview
|
||||
"""
|
||||
if settings['verbose']: print('Exporting %s' % o)
|
||||
#mx = ob.matrix.copy()
|
||||
#print 'deb: ob =', ob #---------
|
||||
#print 'deb: ob.type =', ob.type #---------
|
||||
#print 'deb: mx =\n', mx #---------
|
||||
#print 'deb: mw0 =\n', mw0 #---------
|
||||
#mx_n is trans-matrix for normal_vectors for front-side faces
|
||||
mx = o.matrix_world
|
||||
viewRotation = mw.to_euler().to_matrix()
|
||||
mx_n = o.rotation_euler.to_matrix() * viewRotation
|
||||
mx *= mw
|
||||
"""
|
||||
Export one item from export list.
|
||||
mw - modelview
|
||||
"""
|
||||
if settings['verbose']: print('Exporting %s' % o)
|
||||
#mx = ob.matrix.copy()
|
||||
#print 'deb: ob =', ob #---------
|
||||
#print 'deb: ob.type =', ob.type #---------
|
||||
#print 'deb: mx =\n', mx #---------
|
||||
#print 'deb: mw0 =\n', mw0 #---------
|
||||
#mx_n is trans-matrix for normal_vectors for front-side faces
|
||||
mx = o.matrix_world
|
||||
viewRotation = mw.to_euler().to_matrix()
|
||||
mx_n = o.rotation_euler.to_matrix() @ viewRotation
|
||||
mx @= mw
|
||||
|
||||
#mx_inv = mx.copy().invert()
|
||||
elayer, ecolor, eltype = getCommons(o, settings)
|
||||
if settings['verbose']:
|
||||
print('elayer=%s, ecolor=%s, eltype=%s' % (elayer, ecolor, eltype))
|
||||
#TODO: use o.boundBox for drawing extends ??
|
||||
#mx_inv = mx.copy().invert()
|
||||
elayer, ecolor, eltype = getCommons(o, settings)
|
||||
if settings['verbose']:
|
||||
print('elayer=%s, ecolor=%s, eltype=%s' % (elayer, ecolor, eltype))
|
||||
#TODO: use o.boundBox for drawing extends ??
|
||||
|
||||
if elayer is not None and not drawing.containsLayer(elayer):
|
||||
if ecolor is not None: tempcolor = ecolor
|
||||
else: tempcolor = settings['layercolor_def']
|
||||
drawing.addLayer(elayer, tempcolor)
|
||||
if elayer is not None and not drawing.containsLayer(elayer):
|
||||
if ecolor is not None: tempcolor = ecolor
|
||||
else: tempcolor = settings['layercolor_def']
|
||||
drawing.addLayer(elayer, tempcolor)
|
||||
|
||||
if DEBUG: pydevd.settrace()
|
||||
if (o.type == 'MESH') and settings['mesh_as']:
|
||||
from .primitive_exporters.mesh_exporter import MeshDXFExporter
|
||||
e = MeshDXFExporter(settings)
|
||||
elif (o.type == 'CURVE') and settings['curve_as']:
|
||||
from .primitive_exporters.curve_exporter import CurveDXFExporter
|
||||
e = CurveDXFExporter(settings)
|
||||
elif (o.type == 'EMPTY') and settings['empty_as']:
|
||||
from .primitive_exporters.empty_exporter import EmptyDXFExporter
|
||||
e = EmptyDXFExporter(settings)
|
||||
elif (o.type == 'TEXT') and settings['text_as']:
|
||||
from .primitive_exporters.text_exporter import TextDXFExporter
|
||||
e = TextDXFExporter(settings)
|
||||
elif (o.type == 'CAMERA') and settings['camera_as']:
|
||||
from .primitive_exporters.camera_exporter import CameraDXFExporter
|
||||
e = CameraDXFExporter(settings)
|
||||
elif (o.type == 'LIGHT') and settings['light_as']:
|
||||
from .primitive_exporters.light_exporter import LampDXFExporter
|
||||
e = LampDXFExporter(settings)
|
||||
if DEBUG: pydevd.settrace()
|
||||
if (o.type == 'MESH') and settings['mesh_as']:
|
||||
from .primitive_exporters.mesh_exporter import MeshDXFExporter
|
||||
e = MeshDXFExporter(settings)
|
||||
elif (o.type == 'CURVE') and settings['curve_as']:
|
||||
from .primitive_exporters.curve_exporter import CurveDXFExporter
|
||||
e = CurveDXFExporter(settings)
|
||||
elif (o.type == 'EMPTY') and settings['empty_as']:
|
||||
from .primitive_exporters.empty_exporter import EmptyDXFExporter
|
||||
e = EmptyDXFExporter(settings)
|
||||
elif (o.type == 'TEXT') and settings['text_as']:
|
||||
from .primitive_exporters.text_exporter import TextDXFExporter
|
||||
e = TextDXFExporter(settings)
|
||||
elif (o.type == 'CAMERA') and settings['camera_as']:
|
||||
from .primitive_exporters.camera_exporter import CameraDXFExporter
|
||||
e = CameraDXFExporter(settings)
|
||||
elif (o.type == 'LIGHT') and settings['light_as']:
|
||||
from .primitive_exporters.light_exporter import LampDXFExporter
|
||||
e = LampDXFExporter(settings)
|
||||
|
||||
return e.export(ctx, drawing, o, mx, mx_n, color=ecolor, layer=elayer, lineType=eltype)
|
||||
return e.export(ctx, drawing, o, mx, mx_n, color=ecolor, layer=elayer, lineType=eltype)
|
||||
|
|
|
@ -29,7 +29,7 @@ class DXFExporter(bpy.types.Operator):
|
|||
"""
|
||||
bl_idname = "export.dxf"
|
||||
bl_label = "Export DXF"
|
||||
filepath = StringProperty(subtype='FILE_PATH')
|
||||
filepath: StringProperty(subtype='FILE_PATH')
|
||||
|
||||
entitylayer_from_items = (
|
||||
('default_LAYER', 'Default Layer', ''),
|
||||
|
@ -167,86 +167,86 @@ class DXFExporter(bpy.types.Operator):
|
|||
# ('POINT', 'POINT', '')
|
||||
# )
|
||||
# --------- CONTROL PROPERTIES --------------------------------------------
|
||||
projectionThrough = EnumProperty(name="Projection", default="NO",
|
||||
projectionThrough: EnumProperty(name="Projection", default="NO",
|
||||
description="Select camera for use to 2D projection",
|
||||
items=projectionItems)
|
||||
|
||||
onlySelected = BoolProperty(name="Only selected", default=True,
|
||||
onlySelected: BoolProperty(name="Only selected", default=True,
|
||||
description="What object will be exported? Only selected / all objects")
|
||||
|
||||
apply_modifiers = BoolProperty(name="Apply modifiers", default=True,
|
||||
apply_modifiers: BoolProperty(name="Apply modifiers", default=True,
|
||||
description="Shall be modifiers applied during export?")
|
||||
# GUI_B -----------------------------------------
|
||||
mesh_as = EnumProperty( name="Export Mesh As", default='3DFACEs',
|
||||
mesh_as: EnumProperty( name="Export Mesh As", default='3DFACEs',
|
||||
description="Select representation of a mesh",
|
||||
items=mesh_asItems)
|
||||
# curve_as = EnumProperty( name="Export Curve As:", default='NO',
|
||||
# curve_as: EnumProperty( name="Export Curve As:", default='NO',
|
||||
# description="Select representation of a curve",
|
||||
# items=curve_asItems)
|
||||
# surface_as = EnumProperty( name="Export Surface As:", default='NO',
|
||||
# surface_as: EnumProperty( name="Export Surface As:", default='NO',
|
||||
# description="Select representation of a surface",
|
||||
# items=surface_asItems)
|
||||
# meta_as = EnumProperty( name="Export meta As:", default='NO',
|
||||
# meta_as: EnumProperty( name="Export meta As:", default='NO',
|
||||
# description="Select representation of a meta",
|
||||
# items=meta_asItems)
|
||||
# text_as = EnumProperty( name="Export text As:", default='NO',
|
||||
# text_as: EnumProperty( name="Export text As:", default='NO',
|
||||
# description="Select representation of a text",
|
||||
# items=text_asItems)
|
||||
# empty_as = EnumProperty( name="Export empty As:", default='NO',
|
||||
# empty_as: EnumProperty( name="Export empty As:", default='NO',
|
||||
# description="Select representation of a empty",
|
||||
# items=empty_asItems)
|
||||
# group_as = EnumProperty( name="Export group As:", default='NO',
|
||||
# group_as: EnumProperty( name="Export group As:", default='NO',
|
||||
# description="Select representation of a group",
|
||||
# items=group_asItems)
|
||||
## parent_as = EnumProperty( name="Export parent As:", default='NO',
|
||||
## parent_as: EnumProperty( name="Export parent As:", default='NO',
|
||||
## description="Select representation of a parent",
|
||||
## items=parent_asItems)
|
||||
# proxy_as = EnumProperty( name="Export proxy As:", default='NO',
|
||||
# proxy_as: EnumProperty( name="Export proxy As:", default='NO',
|
||||
# description="Select representation of a proxy",
|
||||
# items=proxy_asItems)
|
||||
# camera_as = EnumProperty( name="Export camera As:", default='NO',
|
||||
# camera_as: EnumProperty( name="Export camera As:", default='NO',
|
||||
# description="Select representation of a camera",
|
||||
# items=camera_asItems)
|
||||
# light_as = EnumProperty( name="Export lamp As:", default='NO',
|
||||
# light_as: EnumProperty( name="Export lamp As:", default='NO',
|
||||
# description="Select representation of a lamp",
|
||||
# items=light_asItems)
|
||||
# ----------------------------------------------------------
|
||||
entitylayer_from = EnumProperty(name="Entity Layer", default="obj.data.name",
|
||||
entitylayer_from: EnumProperty(name="Entity Layer", default="obj.data.name",
|
||||
description="Entity LAYER assigned to?",
|
||||
items=entitylayer_from_items)
|
||||
entitycolor_from = EnumProperty(name="Entity Color", default="default_COLOR",
|
||||
entitycolor_from: EnumProperty(name="Entity Color", default="default_COLOR",
|
||||
description="Entity COLOR assigned to?",
|
||||
items=layerColorFromItems)
|
||||
entityltype_from = EnumProperty(name="Entity Linetype", default="CONTINUOUS",
|
||||
entityltype_from: EnumProperty(name="Entity Linetype", default="CONTINUOUS",
|
||||
description="Entity LINETYPE assigned to?",
|
||||
items=entityltype_fromItems)
|
||||
|
||||
layerName_from = EnumProperty(name="Layer Name", default="LAYERNAME_DEF",
|
||||
layerName_from: EnumProperty(name="Layer Name", default="LAYERNAME_DEF",
|
||||
description="From where will layer name be taken?",
|
||||
items=layerNameFromItems)
|
||||
# GUI_A -----------------------------------------
|
||||
# layFrozen_on = BoolProperty(name="LAYER.frozen status", description="(*todo) Support LAYER.frozen status on/off", default=False)
|
||||
# materialFilter_on = BoolProperty(name="Material filtering", description="(*todo) Material filtering on/off", default=False)
|
||||
# colorFilter_on = BoolProperty(name="Color filtering", description="(*todo) Color filtering on/off", default=False)
|
||||
# groupFilter_on = BoolProperty(name="Group filtering", description="(*todo) Group filtering on/off", default=False)
|
||||
# objectFilter_on = BoolProperty(name="Object filtering", description="(*todo) Object filtering on/off", default=False)
|
||||
# paper_space_on = EnumProperty(name="Space of export:", default="2",
|
||||
# layFrozen_on: BoolProperty(name="LAYER.frozen status", description="(*todo) Support LAYER.frozen status on/off", default=False)
|
||||
# materialFilter_on: BoolProperty(name="Material filtering", description="(*todo) Material filtering on/off", default=False)
|
||||
# colorFilter_on: BoolProperty(name="Color filtering", description="(*todo) Color filtering on/off", default=False)
|
||||
# groupFilter_on: BoolProperty(name="Group filtering", description="(*todo) Group filtering on/off", default=False)
|
||||
# objectFilter_on: BoolProperty(name="Object filtering", description="(*todo) Object filtering on/off", default=False)
|
||||
# paper_space_on: EnumProperty(name="Space of export:", default="2",
|
||||
# description="Select space that will be taken for export.",
|
||||
# items=spaceItems)
|
||||
# material_to = EnumProperty(name="Material assigned to?:", default="NO",
|
||||
# material_to: EnumProperty(name="Material assigned to?:", default="NO",
|
||||
# description="Material assigned to?.",
|
||||
# items=material_toItems)
|
||||
|
||||
# prefix_def = StringProperty(name="Prefix for LAYERs", default="DX_",
|
||||
# prefix_def: StringProperty(name="Prefix for LAYERs", default="DX_",
|
||||
# description='Type Prefix for LAYERs')
|
||||
# layername_def = StringProperty(name="default LAYER name", default="DEF_LAY",
|
||||
# layername_def: StringProperty(name="default LAYER name", default="DEF_LAY",
|
||||
# description='Type default LAYER name')
|
||||
# layercolor_def = StringProperty(name="Default layer color:", default="1",
|
||||
# layercolor_def: StringProperty(name="Default layer color:", default="1",
|
||||
# description='Set default COLOR. (0=BYBLOCK,256=BYLAYER)')
|
||||
# layerltype_def = StringProperty(name="Default LINETYPE", default="DEF_LAY_TYPE",
|
||||
# layerltype_def: StringProperty(name="Default LINETYPE", default="DEF_LAY_TYPE",
|
||||
# description='Set default LINETYPE')
|
||||
|
||||
verbose = BoolProperty(name="Verbose", default=False,
|
||||
verbose: BoolProperty(name="Verbose", default=False,
|
||||
description="Run the exporter in debug mode. Check the console for output")
|
||||
|
||||
def execute(self, context):
|
||||
|
|
|
@ -16,7 +16,7 @@ class BasePrimitiveDXFExporter(object):
|
|||
returns a list of [x,y,z]
|
||||
"""
|
||||
#print 'deb:projected_co() verts=', verts #---------
|
||||
temp_verts = [matrix*mathutils.Vector(v) for v in 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
|
||||
|
@ -58,7 +58,7 @@ class BasePrimitiveDXFExporter(object):
|
|||
vec_normal = f.no.copy()
|
||||
#print 'deb: vec_normal=', vec_normal #------------------
|
||||
# must be transferred to camera/view-CS
|
||||
vec_normal *= mx_n
|
||||
vec_normal @= mx_n
|
||||
#vec_normal *= mb.rotationPart()
|
||||
#print 'deb:2vec_normal=', vec_normal #------------------
|
||||
#vec_normal *= mw0.rotationPart()
|
||||
|
@ -72,7 +72,7 @@ class BasePrimitiveDXFExporter(object):
|
|||
frontFace = True
|
||||
else:
|
||||
v = f.verts[0]
|
||||
vert = mathutils.Vector(v.co) * mx
|
||||
vert = mathutils.Vector(v.co) @ mx
|
||||
if mathutils.DotVecs(vert, vec_normal) < 0.00001:
|
||||
frontFace = True
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ def exportInsert(ob, mx, insert_name, **common):
|
|||
[point] = projected_co([point1], mx)
|
||||
if PERSPECTIVE:
|
||||
clipStart = 10.0
|
||||
coef = -clipStart / (point1*mx)[2]
|
||||
coef = -clipStart / (point1 @ mx)[2]
|
||||
#print 'deb: coef=', coef #--------------
|
||||
#TODO: ? sizeX *= coef
|
||||
#sizeY *= coef
|
||||
|
|
|
@ -64,8 +64,9 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
|
|||
allpoints = self.toGlobalOrigin(allpoints)
|
||||
faces=[]
|
||||
edges=[]
|
||||
me.update(calc_tessface=True)
|
||||
me_faces = me.tessfaces
|
||||
|
||||
me.calc_loop_triangles() #me.update(calc_tessface=True)
|
||||
me_faces = me.loop_triangles #tessfaces
|
||||
#print('deb: allpoints=\n', allpoints) #---------
|
||||
#print('deb: me_faces=\n', me_faces) #---------
|
||||
if me_faces and self.PROJECTION and self.HIDDEN_LINES:
|
||||
|
@ -121,7 +122,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
|
|||
faces = [[v+1 for v in f.vertices] for f in faces]
|
||||
else:
|
||||
# for back-Faces-mode remove face-free vertices
|
||||
map=verts_state= [0]*len(allpoints)
|
||||
map=verts_state= [0] * len(allpoints)
|
||||
for f in faces:
|
||||
for v in f:
|
||||
verts_state[v]=1
|
||||
|
@ -130,8 +131,8 @@ class MeshDXFExporter(BasePrimitiveDXFExporter):
|
|||
for used_i,used in enumerate(verts_state):
|
||||
if used:
|
||||
newverts.append(allpoints[used_i])
|
||||
map[used_i]=i
|
||||
i+=1
|
||||
map[used_i] = i
|
||||
i += 1
|
||||
allpoints = newverts
|
||||
faces = [[map[v]+1 for v in f] for f in faces]
|
||||
args = copy.copy(kwargs)
|
||||
|
|
|
@ -57,7 +57,7 @@ def exportText(ob, mx, mw, **common):
|
|||
[point] = projected_co([point1], mx)
|
||||
if PERSPECTIVE:
|
||||
clipStart = 10.0
|
||||
coef = -clipStart / (point1*mx)[2]
|
||||
coef = -clipStart / (point1 @ mx)[2]
|
||||
textHeight *= coef
|
||||
#print 'deb: coef=', coef #--------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue