-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use IfcOpenShell's 2D engine #34
Comments
@Moult are IfcConvert's svg output capabilities available from Python? I haven't found that anywhere, and I have the impression that BBIM uses its own system to get an SVG view from a mesh, right? Looking at https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py now but the magic seems to be happening somewhere else... |
The SVG serialization capabilities are available from Python, but it is not documented. One example usage may be found in the ifcopenshell.draw module, and another in blenderbim/BIM/module/drawing/operator.py in create_drawing (see generate_line work). However the BlenderBIM Add-on uses a hybrid of the serialiser for line work and our own svg writer for annotations. This is because it's all a wip and whereas line work is fast in c++ and changes less often which needs recompilation, annotation features change more frequently and are relatively simple and may be prototyped in python. |
Thanks! I begin to have a picture. Yes, doing the annotation work in python is also what we do in FreeCAD. There is so much little detail there to adjust that it makes all sense, and it's still globally relatively fast (much faster than the actual HLR work) So basically we need to work with a svg serializer: settings = ifcopenshell.geom.settings(DISABLE_TRIANGULATION=True, STRICT_TOLERANCE=True, INCLUDE_CURVES=True)
buffer = ifcopenshell.geom.serializers.buffer()
serialiser = ifcopenshell.geom.serializers.svg(buffer, settings)
serialiser.setFile(ifcfile)
it = ifcopenshell.geom.iterator(settings, ifcfile, multiprocessing.cpu_count(), include=elements)
if it.initialize():
while True:
serialiser.write(it.get())
if not it.next():
break
serialiser.finalize()
results = buffer.get_value() Next question then (Thanks for your patience 😅) How do you set the projection direction, and/or cut plane? |
Ok I think found the answer myself in https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/draw.py : serialiser.addDrawing(
(x,y,z), # location
(x,y,z), # z axis (view direction)
(x,y,z), # x axis
"Test", # drawing name
True) # include projection |
Well actually no, the projection direction and cut plane is set in the geometry of the IfcAnnotation object with ObjectType="DRAWING". We established a convention to use a box representation to represent the "section box" of the drawing. So everything is stored in the model and the geometry of the section box is in the model too, so it can be used immediately for intersection tests. It's best to create a drawing in BBIM to see what I mean. |
Ok. it's pretty easy to add such an object (all the data can be obtained from an arch section plane). How do you inform the serializer of which drawing it should use? |
i really need to tweak my mind that EVERYTHING becomes part of the IFC file :) it's really cool |
Ok found it myself I guess.. serialiser.setAutoElevation(True)
serialiser.setAutoSection(True) I guess we'll need to play a bit with those settings. Probably the best path forward is to use ifcopenshell.draw: settings = ifcopenshell.draw.draw_settings()
settings.drawing_guid = "XXXX" # the guid of the drawing to use
svg_result = ifcopenshell.main(settings, [ifcfile]) |
Example at https://gitlab.com/osarch/FreeMVD_WorkFlow/-/tree/master/Examples/BlenderBIM%20-%20annotation%20file |
Use IfcOpenShell to generate SVG code.
The text was updated successfully, but these errors were encountered: