mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
#1153. Titleblock revision / data is are derived from IfcDocumentInformation
This commit is contained in:
@@ -173,7 +173,7 @@
|
|||||||
style="stroke-width:0.999999px"
|
style="stroke-width:0.999999px"
|
||||||
y="1036.1166"
|
y="1036.1166"
|
||||||
x="3030.9653"
|
x="3030.9653"
|
||||||
id="tspan2527">{{revision}}</tspan></text>
|
id="tspan2527">{{Revision}}</tspan></text>
|
||||||
<text
|
<text
|
||||||
xml:space="preserve"
|
xml:space="preserve"
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3918px;line-height:125%;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.999999px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3918px;line-height:125%;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.999999px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
@@ -183,7 +183,7 @@
|
|||||||
id="tspan2531"
|
id="tspan2531"
|
||||||
x="2804.7021"
|
x="2804.7021"
|
||||||
y="1036.1166"
|
y="1036.1166"
|
||||||
style="stroke-width:0.999999px">{{number}}</tspan></text>
|
style="stroke-width:0.999999px">{{Identification}} - {{Name}}</tspan></text>
|
||||||
</g>
|
</g>
|
||||||
<g
|
<g
|
||||||
transform="matrix(0.26458333,0,0,0.26458334,-3.180917e-5,297.00003)"
|
transform="matrix(0.26458333,0,0,0.26458334,-3.180917e-5,297.00003)"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -169,7 +169,7 @@
|
|||||||
style="stroke-width:0.264583px"
|
style="stroke-width:0.264583px"
|
||||||
y="397.13919"
|
y="397.13919"
|
||||||
x="554.94287"
|
x="554.94287"
|
||||||
id="tspan2527">{{revision}}</tspan></text>
|
id="tspan2527">{{Revision}}</tspan></text>
|
||||||
<text
|
<text
|
||||||
xml:space="preserve"
|
xml:space="preserve"
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.54325px;line-height:125%;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.54325px;line-height:125%;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
id="tspan2531"
|
id="tspan2531"
|
||||||
x="495.07742"
|
x="495.07742"
|
||||||
y="397.13919"
|
y="397.13919"
|
||||||
style="stroke-width:0.264583px">{{number}}</tspan></text>
|
style="stroke-width:0.264583px">{{Identification}} - {{Name}}</tspan></text>
|
||||||
<g
|
<g
|
||||||
style="stroke-width:3.77953"
|
style="stroke-width:3.77953"
|
||||||
id="g90669"
|
id="g90669"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -172,7 +172,7 @@
|
|||||||
id="tspan2527"
|
id="tspan2527"
|
||||||
x="544.94287"
|
x="544.94287"
|
||||||
y="284.13919"
|
y="284.13919"
|
||||||
style="stroke-width:0.264583px">{{revision}}</tspan></text>
|
style="stroke-width:0.264583px">{{Revision}}</tspan></text>
|
||||||
<text
|
<text
|
||||||
id="text2533"
|
id="text2533"
|
||||||
y="284.13919"
|
y="284.13919"
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
style="stroke-width:0.264583px"
|
style="stroke-width:0.264583px"
|
||||||
y="284.13919"
|
y="284.13919"
|
||||||
x="485.07742"
|
x="485.07742"
|
||||||
id="tspan2531">{{number}}</tspan></text>
|
id="tspan2531">{{Identification}} - {{Name}}</tspan></text>
|
||||||
</g>
|
</g>
|
||||||
<g
|
<g
|
||||||
style="stroke-width:3.77953"
|
style="stroke-width:3.77953"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -667,10 +667,11 @@ class CreateSheets(bpy.types.Operator):
|
|||||||
scene = context.scene
|
scene = context.scene
|
||||||
props = scene.DocProperties
|
props = scene.DocProperties
|
||||||
active_sheet = props.sheets[props.active_sheet_index]
|
active_sheet = props.sheets[props.active_sheet_index]
|
||||||
name = active_sheet.name
|
sheet = tool.Ifc.get().by_id(active_sheet.ifc_definition_id)
|
||||||
|
name = tool.Drawing.get_sheet_filename(sheet)
|
||||||
sheet_builder = sheeter.SheetBuilder()
|
sheet_builder = sheeter.SheetBuilder()
|
||||||
sheet_builder.data_dir = scene.BIMProperties.data_dir
|
sheet_builder.data_dir = scene.BIMProperties.data_dir
|
||||||
sheet_builder.build(name)
|
sheet_builder.build(sheet)
|
||||||
|
|
||||||
svg2pdf_command = context.preferences.addons["blenderbim"].preferences.svg2pdf_command
|
svg2pdf_command = context.preferences.addons["blenderbim"].preferences.svg2pdf_command
|
||||||
svg2dxf_command = context.preferences.addons["blenderbim"].preferences.svg2dxf_command
|
svg2dxf_command = context.preferences.addons["blenderbim"].preferences.svg2dxf_command
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ class SheetBuilder:
|
|||||||
|
|
||||||
if os.path.isfile(underlay_path):
|
if os.path.isfile(underlay_path):
|
||||||
background = ET.SubElement(view, "image")
|
background = ET.SubElement(view, "image")
|
||||||
|
background.attrib["data-type"] = "background"
|
||||||
background.attrib["xlink:href"] = os.path.relpath(underlay_path, sheet_dir)
|
background.attrib["xlink:href"] = os.path.relpath(underlay_path, sheet_dir)
|
||||||
background.attrib["x"] = "30"
|
background.attrib["x"] = "30"
|
||||||
background.attrib["y"] = "30"
|
background.attrib["y"] = "30"
|
||||||
@@ -100,6 +101,7 @@ class SheetBuilder:
|
|||||||
|
|
||||||
if os.path.isfile(drawing_path):
|
if os.path.isfile(drawing_path):
|
||||||
foreground = ET.SubElement(view, "image")
|
foreground = ET.SubElement(view, "image")
|
||||||
|
foreground.attrib["data-type"] = "foreground"
|
||||||
foreground.attrib["xlink:href"] = os.path.relpath(drawing_path, sheet_dir)
|
foreground.attrib["xlink:href"] = os.path.relpath(drawing_path, sheet_dir)
|
||||||
foreground.attrib["x"] = "30"
|
foreground.attrib["x"] = "30"
|
||||||
foreground.attrib["y"] = "30"
|
foreground.attrib["y"] = "30"
|
||||||
@@ -119,9 +121,7 @@ class SheetBuilder:
|
|||||||
sheet_tree = ET.parse(sheet_path)
|
sheet_tree = ET.parse(sheet_path)
|
||||||
sheet_root = sheet_tree.getroot()
|
sheet_root = sheet_tree.getroot()
|
||||||
|
|
||||||
print('removing drawing', sheet_root.findall("{http://www.w3.org/2000/svg}g"))
|
|
||||||
for g in sheet_root.findall("{http://www.w3.org/2000/svg}g"):
|
for g in sheet_root.findall("{http://www.w3.org/2000/svg}g"):
|
||||||
print('checking g', g)
|
|
||||||
if g.attrib["data-type"] == "drawing" and g.attrib["data-guid"] == drawing.GlobalId:
|
if g.attrib["data-type"] == "drawing" and g.attrib["data-guid"] == drawing.GlobalId:
|
||||||
sheet_root.remove(g)
|
sheet_root.remove(g)
|
||||||
break
|
break
|
||||||
@@ -160,13 +160,15 @@ class SheetBuilder:
|
|||||||
title_tree = ET.parse(os.path.join(self.data_dir, "templates", "view-title.svg"))
|
title_tree = ET.parse(os.path.join(self.data_dir, "templates", "view-title.svg"))
|
||||||
title_root = title_tree.getroot()
|
title_root = title_tree.getroot()
|
||||||
title = ET.SubElement(parent, "image")
|
title = ET.SubElement(parent, "image")
|
||||||
|
title.attrib["data-type"] = "view-title"
|
||||||
title.attrib["xlink:href"] = "../templates/view-title.svg"
|
title.attrib["xlink:href"] = "../templates/view-title.svg"
|
||||||
title.attrib["x"] = str(x)
|
title.attrib["x"] = str(x)
|
||||||
title.attrib["y"] = str(y)
|
title.attrib["y"] = str(y)
|
||||||
title.attrib["width"] = str(self.convert_to_mm(title_root.attrib.get("width")))
|
title.attrib["width"] = str(self.convert_to_mm(title_root.attrib.get("width")))
|
||||||
title.attrib["height"] = str(self.convert_to_mm(title_root.attrib.get("height")))
|
title.attrib["height"] = str(self.convert_to_mm(title_root.attrib.get("height")))
|
||||||
|
|
||||||
def build(self, sheet_name):
|
def build(self, sheet):
|
||||||
|
sheet_name = tool.Drawing.get_sheet_filename(sheet)
|
||||||
os.makedirs(os.path.join(self.data_dir, "build", sheet_name), exist_ok=True)
|
os.makedirs(os.path.join(self.data_dir, "build", sheet_name), exist_ok=True)
|
||||||
|
|
||||||
sheet_path = os.path.join(self.data_dir, "sheets", f"{sheet_name}.svg")
|
sheet_path = os.path.join(self.data_dir, "sheets", f"{sheet_name}.svg")
|
||||||
@@ -177,48 +179,56 @@ class SheetBuilder:
|
|||||||
tree = ET.parse(sheet_path)
|
tree = ET.parse(sheet_path)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
titleblock = root.findall('{http://www.w3.org/2000/svg}g[@data-type="titleblock"]')[0]
|
self.build_titleblock(root, sheet)
|
||||||
image = titleblock.findall("{http://www.w3.org/2000/svg}image")[0]
|
self.build_drawings(root, sheet_name)
|
||||||
titleblock.append(self.parse_embedded_svg(image, {"number": sheet_name, "revision": "A"}))
|
|
||||||
titleblock.remove(image)
|
|
||||||
|
|
||||||
self.group_number = 1
|
|
||||||
self.build_drawings(root.findall('{http://www.w3.org/2000/svg}g[@data-type="drawing"]'), sheet_name)
|
|
||||||
self.build_schedules(root.findall('{http://www.w3.org/2000/svg}g[@data-type="schedule"]'))
|
self.build_schedules(root.findall('{http://www.w3.org/2000/svg}g[@data-type="schedule"]'))
|
||||||
|
|
||||||
with open(os.path.join(self.data_dir, "build", sheet_name, f"{sheet_name}.svg"), "wb") as output:
|
with open(os.path.join(self.data_dir, "build", sheet_name, f"{sheet_name}.svg"), "wb") as output:
|
||||||
tree.write(output)
|
tree.write(output)
|
||||||
|
|
||||||
def build_drawings(self, drawings, sheet_name):
|
def build_titleblock(self, root, sheet):
|
||||||
for view in drawings:
|
titleblock = root.findall('{http://www.w3.org/2000/svg}g[@data-type="titleblock"]')[0]
|
||||||
|
image = titleblock.findall("{http://www.w3.org/2000/svg}image")[0]
|
||||||
|
titleblock.append(self.parse_embedded_svg(image, sheet.get_info()))
|
||||||
|
titleblock.remove(image)
|
||||||
|
|
||||||
|
def build_drawings(self, root, sheet_name):
|
||||||
|
for view in root.findall('{http://www.w3.org/2000/svg}g[@data-type="drawing"]'):
|
||||||
images = view.findall("{http://www.w3.org/2000/svg}image")
|
images = view.findall("{http://www.w3.org/2000/svg}image")
|
||||||
background = images[0]
|
|
||||||
foreground = images[1]
|
background = None
|
||||||
view_title = images[2]
|
foreground = None
|
||||||
|
view_title = None
|
||||||
|
|
||||||
|
for image in images:
|
||||||
|
if image.attrib["data-type"] == "background":
|
||||||
|
background = image
|
||||||
|
elif image.attrib["data-type"] == "foreground":
|
||||||
|
foreground = image
|
||||||
|
elif image.attrib["data-type"] == "view-title":
|
||||||
|
view_title = image
|
||||||
|
|
||||||
self.scale = "NTS"
|
self.scale = "NTS"
|
||||||
|
|
||||||
# Add foreground
|
if foreground is not None:
|
||||||
view.append(self.parse_embedded_svg(foreground, {}))
|
view.append(self.parse_embedded_svg(foreground, {}))
|
||||||
|
|
||||||
# Add background
|
if background is not None:
|
||||||
background_path = os.path.join(self.data_dir, "sheets", self.get_href(background))
|
background_path = os.path.join(self.data_dir, "sheets", self.get_href(background))
|
||||||
|
copy(background_path, os.path.join(self.data_dir, "build", sheet_name))
|
||||||
|
|
||||||
copy(background_path, os.path.join(self.data_dir, "build", sheet_name))
|
if view_title is not None:
|
||||||
|
foreground_path = self.get_href(foreground)
|
||||||
# Add view title
|
view.append(
|
||||||
foreground_path = self.get_href(foreground)
|
self.parse_embedded_svg(
|
||||||
view.append(
|
view_title,
|
||||||
self.parse_embedded_svg(
|
{"no": 1, "name": ntpath.basename(foreground_path)[0:-4], "scale": self.scale},
|
||||||
view_title,
|
)
|
||||||
{"no": self.group_number, "name": ntpath.basename(foreground_path)[0:-4], "scale": self.scale},
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
for image in images:
|
for image in images:
|
||||||
view.remove(image)
|
view.remove(image)
|
||||||
|
|
||||||
self.group_number += 1
|
|
||||||
|
|
||||||
def build_schedules(self, schedules):
|
def build_schedules(self, schedules):
|
||||||
for group in schedules:
|
for group in schedules:
|
||||||
images = group.findall("{http://www.w3.org/2000/svg}image")
|
images = group.findall("{http://www.w3.org/2000/svg}image")
|
||||||
@@ -231,15 +241,13 @@ class SheetBuilder:
|
|||||||
path = self.get_href(schedule)
|
path = self.get_href(schedule)
|
||||||
group.append(
|
group.append(
|
||||||
self.parse_embedded_svg(
|
self.parse_embedded_svg(
|
||||||
group_title, {"no": self.group_number, "name": ntpath.basename(path)[0:-4], "scale": self.scale}
|
group_title, {"no": 1, "name": ntpath.basename(path)[0:-4], "scale": self.scale}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
for image in images:
|
for image in images:
|
||||||
group.remove(image)
|
group.remove(image)
|
||||||
|
|
||||||
self.group_number += 1
|
|
||||||
|
|
||||||
def get_href(self, element):
|
def get_href(self, element):
|
||||||
return urllib.parse.unquote(element.attrib.get("{http://www.w3.org/1999/xlink}href"))
|
return urllib.parse.unquote(element.attrib.get("{http://www.w3.org/1999/xlink}href"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user