mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
Fix #2442. Fix bug where viewboxes were not clipped when compiling drawing sheets.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
import ntpath
|
import ntpath
|
||||||
import pystache
|
import pystache
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
@@ -182,6 +183,9 @@ class SheetBuilder:
|
|||||||
tree = ET.parse(sheet_path)
|
tree = ET.parse(sheet_path)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
|
self.defs = ET.Element("defs")
|
||||||
|
root.append(self.defs)
|
||||||
|
|
||||||
self.build_titleblock(root, sheet)
|
self.build_titleblock(root, sheet)
|
||||||
self.build_drawings(root, sheet)
|
self.build_drawings(root, sheet)
|
||||||
self.build_schedules(root)
|
self.build_schedules(root)
|
||||||
@@ -271,6 +275,20 @@ class SheetBuilder:
|
|||||||
group.attrib["transform"] = "translate({},{})".format(
|
group.attrib["transform"] = "translate({},{})".format(
|
||||||
self.convert_to_mm(image.attrib.get("x")), self.convert_to_mm(image.attrib.get("y"))
|
self.convert_to_mm(image.attrib.get("x")), self.convert_to_mm(image.attrib.get("y"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Convert viewBox into a clip path
|
||||||
|
clip_id = str(uuid.uuid4())
|
||||||
|
group.attrib["clip-path"] = f"url(#{clip_id})"
|
||||||
|
clip_path = ET.Element("clipPath")
|
||||||
|
clip_path.attrib["id"] = clip_id
|
||||||
|
rect = ET.Element("rect")
|
||||||
|
rect.attrib["x"] = "0"
|
||||||
|
rect.attrib["y"] = "0"
|
||||||
|
rect.attrib["width"] = str(self.convert_to_mm(image.attrib.get("width")))
|
||||||
|
rect.attrib["height"] = str(self.convert_to_mm(image.attrib.get("height")))
|
||||||
|
clip_path.append(rect)
|
||||||
|
self.defs.append(clip_path)
|
||||||
|
|
||||||
svg_path = self.get_href(image)
|
svg_path = self.get_href(image)
|
||||||
with open(os.path.join(self.data_dir, "sheets", svg_path), "r") as template:
|
with open(os.path.join(self.data_dir, "sheets", svg_path), "r") as template:
|
||||||
embedded = ET.fromstring(pystache.render(template.read(), data))
|
embedded = ET.fromstring(pystache.render(template.read(), data))
|
||||||
|
|||||||
Reference in New Issue
Block a user