mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Feature to set and resize text to 1.8, 2.5, 3.5, 5 and 7 sizes
This commit is contained in:
@@ -121,6 +121,7 @@ if bpy is not None:
|
||||
operator.RemoveIfcFile,
|
||||
operator.SelectDocIfcFile,
|
||||
operator.AddAnnotation,
|
||||
operator.ResizeText,
|
||||
prop.StrProperty,
|
||||
prop.Classification,
|
||||
prop.ClassificationReference,
|
||||
@@ -151,6 +152,7 @@ if bpy is not None:
|
||||
prop.SweptSolid,
|
||||
prop.BIMMeshProperties,
|
||||
prop.BIMCameraProperties,
|
||||
prop.BIMTextProperties,
|
||||
ui.BIM_PT_section_plane,
|
||||
ui.BIM_PT_documentation,
|
||||
ui.BIM_PT_bim,
|
||||
@@ -173,6 +175,7 @@ if bpy is not None:
|
||||
ui.BIM_PT_classification_references,
|
||||
ui.BIM_PT_documents,
|
||||
ui.BIM_PT_camera,
|
||||
ui.BIM_PT_text,
|
||||
ui.BIM_UL_document_information,
|
||||
ui.BIM_UL_document_references,
|
||||
ui.BIM_UL_topics,
|
||||
@@ -210,6 +213,7 @@ if bpy is not None:
|
||||
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)
|
||||
bpy.types.TextCurve.BIMTextProperties = bpy.props.PointerProperty(type=prop.BIMTextProperties)
|
||||
|
||||
def unregister():
|
||||
for cls in reversed(classes):
|
||||
@@ -227,3 +231,4 @@ if bpy is not None:
|
||||
del(bpy.types.Material.BIMMaterialProperties)
|
||||
del(bpy.types.Mesh.BIMMeshProperties)
|
||||
del(bpy.types.Camera.BIMCameraProperties)
|
||||
del(bpy.types.Camera.BIMTextProperties)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import bpy
|
||||
import os
|
||||
from mathutils import Vector
|
||||
|
||||
class Annotator:
|
||||
@@ -12,9 +13,33 @@ class Annotator:
|
||||
co1, co2 = Annotator.get_placeholder_coords()
|
||||
obj.location = co1
|
||||
obj.hide_render = True
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
font = bpy.data.fonts.get('OpenGost TypeB TT')
|
||||
if not font:
|
||||
font = bpy.data.fonts.load(os.path.join(
|
||||
bpy.context.scene.BIMProperties.data_dir, 'fonts', 'OpenGost Type B TT.ttf'))
|
||||
font.name = 'OpenGost Type B TT'
|
||||
obj.data.font = font
|
||||
obj.data.BIMTextProperties.font_size = '2.5'
|
||||
collection = bpy.context.scene.camera.users_collection[0]
|
||||
collection.objects.link(obj)
|
||||
Annotator.resize_text(obj)
|
||||
return obj
|
||||
|
||||
@staticmethod
|
||||
def resize_text(text_obj):
|
||||
camera = None
|
||||
for obj in text_obj.users_collection[0].objects:
|
||||
if isinstance(obj.data, bpy.types.Camera):
|
||||
camera = obj
|
||||
break
|
||||
if not camera:
|
||||
return
|
||||
# This is a magic number for OpenGost
|
||||
font_size = 1.6 / 1000
|
||||
font_size *= float(text_obj.data.BIMTextProperties.font_size)
|
||||
font_size *= float(camera.data.BIMCameraProperties.diagram_scale.split(':')[1])
|
||||
text_obj.data.size = font_size
|
||||
|
||||
@staticmethod
|
||||
def add_line_to_annotation(obj):
|
||||
co1, co2 = Annotator.get_placeholder_coords()
|
||||
|
||||
@@ -1526,6 +1526,7 @@ class CreateView(bpy.types.Operator):
|
||||
views_collection.children.link(view_collection)
|
||||
camera = bpy.data.objects.new(bpy.context.scene.DocProperties.view_name, bpy.data.cameras.new(bpy.context.scene.DocProperties.view_name))
|
||||
camera.data.type = 'ORTHO'
|
||||
camera.data.BIMCameraProperties.diagram_scale = '1:100'
|
||||
bpy.context.scene.camera = camera
|
||||
view_collection.objects.link(camera)
|
||||
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
|
||||
@@ -2408,3 +2409,14 @@ class AddAnnotation(bpy.types.Operator):
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ResizeText(bpy.types.Operator):
|
||||
bl_idname = 'bim.resize_text'
|
||||
bl_label = 'Resize Text'
|
||||
|
||||
def execute(self, context):
|
||||
for obj in bpy.context.scene.camera.users_collection[0].objects:
|
||||
if isinstance(obj.data, bpy.types.TextCurve):
|
||||
annotation.Annotator.resize_text(obj)
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -7,6 +7,7 @@ from . import export_ifc
|
||||
from . import schema
|
||||
from . import bcf
|
||||
from . import ifc
|
||||
from . import annotation
|
||||
import bpy
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.app.handlers import persistent
|
||||
@@ -366,6 +367,10 @@ def getSheets(self, context):
|
||||
return sheets_enum
|
||||
|
||||
|
||||
def refreshFontSize(self, context):
|
||||
annotation.Annotator.resize_text(context.active_object)
|
||||
|
||||
|
||||
class StrProperty(PropertyGroup):
|
||||
pass
|
||||
|
||||
@@ -390,6 +395,16 @@ class BIMCameraProperties(PropertyGroup):
|
||||
is_nts: BoolProperty(name='Is NTS')
|
||||
|
||||
|
||||
class BIMTextProperties(PropertyGroup):
|
||||
font_size: EnumProperty(items=[
|
||||
('1.8', '1.8', ''),
|
||||
('2.5', '2.5', ''),
|
||||
('3.5', '3.5', ''),
|
||||
('5.0', '5.0', ''),
|
||||
('7.0', '7.0', ''),
|
||||
], update=refreshFontSize, name='Font Size')
|
||||
|
||||
|
||||
class DocumentInformation(PropertyGroup):
|
||||
name: StringProperty(name='Identification')
|
||||
human_name: StringProperty(name='Name')
|
||||
|
||||
@@ -630,11 +630,34 @@ class BIM_PT_camera(Panel):
|
||||
row = layout.row()
|
||||
row.prop(props, 'is_nts')
|
||||
|
||||
row = layout.row()
|
||||
row.operator('bim.resize_text')
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(props, 'diagram_scale', text='')
|
||||
row.operator('bim.cut_section')
|
||||
|
||||
|
||||
class BIM_PT_text(Panel):
|
||||
bl_label = "Text Paper Space"
|
||||
bl_idname = "BIM_PT_text"
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
bl_context = 'data'
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (type(context.curve) is bpy.types.TextCurve)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
props = context.active_object.data.BIMTextProperties
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'font_size')
|
||||
|
||||
|
||||
class BIM_PT_owner(Panel):
|
||||
bl_label = "Owner History"
|
||||
bl_idname = "BIM_PT_owner"
|
||||
@@ -655,6 +678,7 @@ class BIM_PT_owner(Panel):
|
||||
row = layout.row()
|
||||
row.prop(props, 'organisation')
|
||||
|
||||
|
||||
class BIM_PT_context(Panel):
|
||||
bl_label = "Geometric Representation Contexts"
|
||||
bl_idname = "BIM_PT_context"
|
||||
|
||||
Reference in New Issue
Block a user