Support converting drawings to PDF on the fly

This commit is contained in:
Dion Moult
2020-08-17 21:12:31 +10:00
parent db0c266a17
commit 78d33b4ffd
2 changed files with 19 additions and 1 deletions
@@ -2227,9 +2227,22 @@ class CreateSheets(bpy.types.Operator):
def execute(self, context):
props = bpy.context.scene.DocProperties
name = props.sheets[props.active_sheet_index].name
sheet_builder = sheeter.SheetBuilder()
sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir
sheet_builder.build(props.sheets[props.active_sheet_index].name)
sheet_builder.build(name)
svg2pdf_command = bpy.context.preferences.addons['blenderbim'].preferences.svg2pdf_command
if not svg2pdf_command:
webbrowser.open('file://' + os.path.join(bpy.context.scene.BIMProperties.data_dir, 'build', name, name + '.svg'))
return {'FINISHED'}
import subprocess
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, 'build', name)
svg = os.path.join(path, name + '.svg')
pdf = os.path.join(path, name + '.pdf')
# With great power comes great responsibility. Example:
# ['inkscape', svg, '-o', pdf]
subprocess.run(eval(svg2pdf_command))
webbrowser.open('file://' + os.path.join(pdf))
return {'FINISHED'}
@@ -1,5 +1,7 @@
import bpy
from bpy.types import Panel
from bpy.props import StringProperty
class BIM_PT_object(Panel):
bl_label = 'IFC Object'
@@ -1777,6 +1779,7 @@ class BIM_UL_representation_items(bpy.types.UIList):
class BIM_ADDON_preferences(bpy.types.AddonPreferences):
bl_idname = 'blenderbim'
svg2pdf_command: StringProperty(name="SVG to PDF Command")
def draw(self, context):
layout = self.layout
@@ -1786,6 +1789,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
row = layout.row()
row.operator('bim.open_upstream', text='Visit Wiki').page = 'wiki'
row.operator('bim.open_upstream', text='Visit Community').page = 'community'
row = layout.row()
row.prop(self, 'svg2pdf_command')
class BIM_PT_ifcclash(Panel):