mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
draw settings
This commit is contained in:
@@ -47,8 +47,14 @@ class draw_settings:
|
|||||||
width: float = 297.0
|
width: float = 297.0
|
||||||
height: float = 420.0
|
height: float = 420.0
|
||||||
scale: float = 1.0 / 100.0
|
scale: float = 1.0 / 100.0
|
||||||
auto_elevation: bool = True
|
auto_elevation: bool = False
|
||||||
auto_section: bool = True
|
auto_section: bool = False
|
||||||
|
auto_floorplan: bool = True
|
||||||
|
space_names: bool = False
|
||||||
|
space_areas: bool = False
|
||||||
|
door_arcs: bool = False
|
||||||
|
css: bool = True
|
||||||
|
storey_heights: str = "none"
|
||||||
include_entities: str = ""
|
include_entities: str = ""
|
||||||
exclude_entities: str = "IfcOpeningElement"
|
exclude_entities: str = "IfcOpeningElement"
|
||||||
|
|
||||||
@@ -80,8 +86,9 @@ def main(settings, files, progress_function=DO_NOTHING):
|
|||||||
buffer = ifcopenshell.geom.serializers.buffer()
|
buffer = ifcopenshell.geom.serializers.buffer()
|
||||||
sr = ifcopenshell.geom.serializers.svg(buffer, SETTINGS)
|
sr = ifcopenshell.geom.serializers.svg(buffer, SETTINGS)
|
||||||
|
|
||||||
# sr.setFile(files[0])
|
sr.setFile(files[0])
|
||||||
# sr.setSectionHeightsFromStoreys()
|
if settings.auto_floorplan:
|
||||||
|
sr.setSectionHeightsFromStoreys()
|
||||||
|
|
||||||
# required for svgfill
|
# required for svgfill
|
||||||
sr.setPolygonal(True)
|
sr.setPolygonal(True)
|
||||||
@@ -94,13 +101,23 @@ def main(settings, files, progress_function=DO_NOTHING):
|
|||||||
sr.setScale(settings.scale)
|
sr.setScale(settings.scale)
|
||||||
sr.setAutoElevation(settings.auto_elevation)
|
sr.setAutoElevation(settings.auto_elevation)
|
||||||
sr.setAutoSection(settings.auto_section)
|
sr.setAutoSection(settings.auto_section)
|
||||||
|
sr.setPrintSpaceNames(settings.space_names)
|
||||||
|
sr.setPrintSpaceAreas(settings.space_areas)
|
||||||
|
sr.setDrawDoorArcs(settings.door_arcs)
|
||||||
|
sr.setNoCSS(not settings.css)
|
||||||
|
|
||||||
|
try:
|
||||||
|
sh = ['none', 'full', 'left'].index(settings.storey_heights)
|
||||||
|
sr.setDrawStoreyHeights(sh)
|
||||||
|
except:
|
||||||
|
raise ValueError("storey_heights should be one of {'none', 'full', 'left'}")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# It is also possible to add drawing planes manually
|
# It is also possible to add drawing planes manually
|
||||||
sr.addDrawing(
|
sr.addDrawing(
|
||||||
obj.matrix_world().transposed()[3][0:3],
|
obj.matrix_world.transposed()[3][0:3],
|
||||||
-obj.matrix_world().transposed()[2][0:3],
|
-obj.matrix_world.transposed()[2][0:3],
|
||||||
-obj.matrix_world().transposed()[0][0:3],
|
-obj.matrix_world.transposed()[0][0:3],
|
||||||
"Test", # drawing name
|
"Test", # drawing name
|
||||||
True # include projection
|
True # include projection
|
||||||
)
|
)
|
||||||
@@ -273,14 +290,15 @@ if __name__ == "__main__":
|
|||||||
for field in fields(draw_settings):
|
for field in fields(draw_settings):
|
||||||
if field.type == bool:
|
if field.type == bool:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--" + field.name, dest=field.name, action="store_true"
|
"--" + field.name.replace("_", "-"), dest=field.name, action="store_true"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-" + field.name, dest=field.name, action="store_false"
|
"--no-" + field.name.replace("_", "-"), dest=field.name, action="store_false"
|
||||||
)
|
)
|
||||||
|
parser.set_defaults(**{field.name: field.default})
|
||||||
else:
|
else:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--" + field.name, type=field.type, default=field.default
|
"--" + field.name.replace("_", "-"), dest=field.name, type=field.type, default=field.default
|
||||||
)
|
)
|
||||||
|
|
||||||
args = vars(parser.parse_args(sys.argv))
|
args = vars(parser.parse_args(sys.argv))
|
||||||
@@ -291,4 +309,5 @@ if __name__ == "__main__":
|
|||||||
settings = draw_settings(**args)
|
settings = draw_settings(**args)
|
||||||
|
|
||||||
files = list(map(ifcopenshell.open, files))
|
files = list(map(ifcopenshell.open, files))
|
||||||
open(output, "wb").write(main(settings, files, progress_function=print))
|
open(output, "wb").write(main(settings, files, progress_function=lambda *args: print("\r", *args, " "*10, end="", flush=True)))
|
||||||
|
print("\r Done!")
|
||||||
|
|||||||
Reference in New Issue
Block a user