Allow view scales to be set per camera instead of global

This commit is contained in:
Dion Moult
2020-01-06 11:46:42 +11:00
parent 461b1735dd
commit 6d83815ab1
4 changed files with 38 additions and 9 deletions
@@ -80,6 +80,7 @@ if bpy is not None:
operator.CutSection,
operator.CreateSheets,
operator.GenerateDigitalTwin,
operator.CreateView,
prop.Subcontext,
prop.BIMProperties,
prop.DocProperties,
@@ -95,6 +96,7 @@ if bpy is not None:
prop.BIMMaterialProperties,
prop.SweptSolid,
prop.BIMMeshProperties,
prop.BIMCameraProperties,
ui.BIM_PT_documentation,
ui.BIM_PT_bim,
ui.BIM_PT_owner,
@@ -107,6 +109,7 @@ if bpy is not None:
ui.BIM_PT_material,
ui.BIM_PT_mesh,
ui.BIM_PT_object,
ui.BIM_PT_camera,
)
def menu_func_export(self, context):
@@ -137,6 +140,7 @@ if bpy is not None:
bpy.types.Collection.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties)
bpy.types.Material.BIMMaterialProperties = bpy.props.PointerProperty(type=prop.BIMMaterialProperties)
bpy.types.Mesh.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties)
bpy.types.Camera.BIMCameraProperties = bpy.props.PointerProperty(type=prop.BIMCameraProperties)
def unregister():
for cls in reversed(classes):
@@ -152,6 +156,7 @@ if bpy is not None:
del(bpy.types.Collection.BIMObjectProperties)
del(bpy.types.Material.BIMMaterialProperties)
del(bpy.types.Mesh.BIMMeshProperties)
del(bpy.types.Mesh.BIMCameraProperties)
if __name__ == "__main__":
register()
+1 -1
View File
@@ -855,7 +855,7 @@ class CutSection(bpy.types.Operator):
ifc_cutter.cut_pickle_file = os.path.join(ifc_cutter.data_dir, '{}-cut.pickle'.format(self.diagram_name))
ifc_cutter.should_recut = bpy.context.scene.DocProperties.should_recut
svg_writer = cut_ifc.SvgWriter(ifc_cutter)
numerator, denominator = bpy.context.scene.DocProperties.diagram_scale.split(':')
numerator, denominator = camera.data.BIMCameraProperties.diagram_scale.split(':')
svg_writer.scale = float(numerator) / float(denominator)
ifc_cutter.cut()
svg_writer.write()
+5 -1
View File
@@ -215,11 +215,15 @@ class Subcontext(PropertyGroup):
class DocProperties(PropertyGroup):
diagram_scale: EnumProperty(items=getDiagramScales, name='Diagram Scale')
should_recut: BoolProperty(name="Should Recut", default=True)
view_name: StringProperty(name="View Name")
class BIMCameraProperties(PropertyGroup):
view_name: StringProperty(name="View Name")
diagram_scale: EnumProperty(items=getDiagramScales, name='Diagram Scale')
class BIMProperties(PropertyGroup):
schema_dir: StringProperty(default=os.path.join(cwd ,'schema') + os.path.sep, name="Schema Directory")
data_dir: StringProperty(default=os.path.join(cwd, 'data') + os.path.sep, name="Data Directory")
+27 -7
View File
@@ -198,13 +198,6 @@ class BIM_PT_documentation(Panel):
row.prop(props, 'view_name')
row.operator('bim.create_view', icon='ADD', text='')
row = layout.row()
row.prop(props, 'should_recut')
row = layout.row(align=True)
row.prop(props, 'diagram_scale', text='')
row.operator('bim.cut_section')
row = layout.row()
row.operator('bim.create_sheets')
@@ -212,6 +205,33 @@ class BIM_PT_documentation(Panel):
row.operator('bim.generate_digital_twin')
class BIM_PT_camera(Panel):
bl_label = "Diagrams and Documentation"
bl_idname = "BIM_PT_camera"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = 'data'
@classmethod
def poll(cls, context):
engine = context.engine
return context.camera and (engine in cls.COMPAT_ENGINES) and \
hasattr(context.active_object.data, "BIMCameraProperties")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
dprops = bpy.context.scene.DocProperties
props = context.active_object.data.BIMCameraProperties
row = layout.row()
row.prop(dprops, 'should_recut')
row = layout.row(align=True)
row.prop(props, 'diagram_scale', text='')
row.operator('bim.cut_section')
class BIM_PT_owner(Panel):
bl_label = "Owner History"
bl_idname = "BIM_PT_owner"