yorikvanhavre / BIM_Workbench

A BIM Workbench for FreeCAD
363 stars 77 forks source link

Better support for IfcAnnotations #92

Open yorikvanhavre opened 2 years ago

yorikvanhavre commented 2 years ago

Have a solid, round-trippable support for 2D annotations (lines, texts, dimensions,...) in IFC, through IfcAnnotations.

Related issue @ BlenderBIM: https://github.com/IfcOpenShell/IfcOpenShell/pull/2100

Moult commented 2 years ago

Cheers, most of these already have solutions worked on as part of the IfcOpenShell drawing module, so let's perhaps start with the easiest then work our way up. If you're curious on reading this is a good post to read: https://github.com/IfcOpenShell/IfcOpenShell/issues/1153#issuecomment-749491531

So to start with:

  1. Camera object will be stored in IFC as an IfcAnnotation, it must have an ObjectType of DRAWING. (Camera is Blender jargon, but it's basically the view foreground cutting plane + background cutting plane extents)
  2. IfcAnnotation[ObjectType="DRAWING"] must belong in a single IfcGroup
  3. The DRAWING annotation object must store an IfcBlock in the MODEL/Body/MODEL_VIEW subcontext.
  4. The DRAWING annotation object ObjectPlacement should have a rotation such that -Z points at the direction you are looking at in the section cut (i.e. same as BCF), +X points to the right, and +Y points up the drawing.
  5. The DRAWING annotation object should store a Pset called EPset_Drawing EPset_Drawing should contain: TargetView (enum to match subcontext TargetView attribute), Scale (IfcLabel, like "X/Y" where X and Y are integers)

Once you have these, that should be enough to get a drawing translated across. Hopefully the logic why we need each of these data should be obvious but if it isn't let me know and happy to have a call to explain the reasoning.

yorikvanhavre commented 2 years ago

Thanks for the detailed explanation. Okay, I think that's pretty easy to implement. Two questions:

Moult commented 2 years ago

Exactly, the IfcBlock is the "view cube". Everybody (I assume) needs a view cube to represent the full 3D drawing extents so I think it works well and is agnostic of camera properties.

"EPset_" is a little hack where something is a custom pset, but I consider it to be an extension of IFC itself or a workaround that is common to many implementations. It was an unofficial convention stablished by the georeferencing workarounds in IFC2X3 when IFC2x3 needed EPset_ProjectedCRS and EPset_MapConversion.

theoryshaw commented 2 years ago

following and excited. :)

yorikvanhavre commented 2 years ago

IMG_20220330_185208 I think we could achieve something good here, being able to design such things in either FreeCAD or Blender and render it in the other... I haven't looked deep into finer text styling, if things like font, alignment... are possible..

edit note to self: yes: add an IfcStyledItem + IfcTextStyle https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD1/HTML/schema/ifcpresentationdefinitionresource/lexical/ifctextliteral.htm

Moult commented 2 years ago

By the way I always use IfcTextLiteralWithExtents because that gives me the option of using a BoxAlignment. The BlenderBIM Add-on has a tiny Style manager which includes all the 4 presentations styles (surface, curve, fillarea, and text).

Right now though the styles are done with CSS in SVG, however I do plan to let the IFC styles generate the CSS so they are linked.

yorikvanhavre commented 2 years ago

i like css and svg too.. the thing is how to transport drawings between, say 😇 blender and freecad, in a manner that they don't loose important things like text size and position. For now indeed having that in the ifc file is simple. but indeed, think of css-stylable cad drawings!

yorikvanhavre commented 2 years ago

oops, closed by mistake..

yorikvanhavre commented 2 years ago

As of https://github.com/FreeCAD/FreeCAD/commit/b5a6970c5317f3b82788ea9646d3e80e356b36d5 IfcAnnotations exported from FreeCAD now have these possible ObjectType: LINEWORK,AREA,HATCH,LEADER,TEXT,DIMENSION, or None (empty string)

edit full list BlenderBIM + FreeCAD: BREAKLINE DIMENSION DRAWING EQUAL_DIMENSION GRID HIDDEN_LINE MISC PLAN_LEVEL SECTION_LEVEL STAIR_ARROW TEXT TEXT_LEADER LEADER HATCH LINEWORK AREA

Moult commented 2 years ago

A sample file that includes some sheet and drawing info :)

untitled.ifc.txt

theoryshaw commented 2 years ago

Related: A thread on how to codify dimension offsets in the IFC schema: https://community.osarch.org/discussion/1014/ifc-an-approach-for-dimension-line-offsets/

theoryshaw commented 2 years ago

To help fund this issue directly, OSarch created a 'bounty' here: https://opencollective.com/osarch/projects/roundtrip_ifc_annotation