How to annotate a floorplan right now?

A forum dedicated to the Draft, Arch and BIM workbenches development.
matthijskooijman
Posts: 70
Joined: Thu Mar 25, 2021 10:59 am

How to annotate a floorplan right now?

Postby matthijskooijman » Wed May 05, 2021 3:01 pm

First, for some background: I need a tool to edit and generate complex and annotated floorplans for an existing building (3 connected buildings, 3 floors, about 2000m²), to document current state (including electrical, piping, etc.) and to draw proposed changes. I'm considering FreeCAD for this job. I realize that 2D floorplans and annotations are not the FreeCAD strongest points right now, but given FreeCAD's flexibility in document organization and its powerful scripting, I suspect it might be suited to the job nonetheless (and I really want some opensource workflow, or at least some workflow without any propietary lockin). For additional context, I am a software engineer by trade and have pretty much no experience in arch/BIM/etc., so I'm learning this as a go...

I've experimented a bit with the basics (walls, floors and openings) and producing a floorplan using arch sectionviews and techdraw and there's still some caveats there (especially wrt links), but I think I can manage to figure those out (and/or provide code fixes where needed). However, I can't quite figure out a practical way to get (2D) annotations/symbols on the floorplan. I've read various threads on the forum with suggestions on adding new symbol or annotation objects to solve this and those ideas sound great and very powerful. However, I really need to produce something on quite a short term, so I'm trying to figure out if there is a way I can start with something that works and looks well enough now, and maybe replace the approach with a nicer approach later.

The annotations I'm currently considering:
  • Electrical annotations, in particular wall outlets, light switches and light fixtures, annotated with their circuit number and optionally switch letter.
  • Various piping in the building. I think these can just be modeled as pipe objects, which should show up on the floorplan directly (haven't tested yet, though).
  • Indications of fire-resistance for doors (i.e. a line with two x's at the end perpendicular to the door opening)
  • Indications of fire separation (i.e. lines overlaid over e.g. walls)
  • Other indications (room numbers, notes for specific doors or walls, etc.)
Ideally, the values of these annotations (and maybe the annotation itself), would be part of the objects they apply to. For example, Arch door object currently already automatically generate a symbol showing the swing of the door in the floorplan, based on the door and hinge definition. For fire-resistance in doors, it would be similarly nice if I could just set a property "FireResistance: 30min" or something like that on the door and the symbol would be automatically adapted. Similarly, for electrical outlets, it would be nice if those would be regular 3D objects, that when sectioned, would produce a symbol. Ideally, such a symbol is not necessarily hardcoded (like the door swing), but can just be an arbitrary SVG, draft object(s), or other 2D object linked to the (Arch) 3D object. And any (custom or IFC) properties set on the 3D object (e.g. circuit number) can be used inside the symbol when rendering it (so you can set some properties in a semantic way, and have the symbol adapt automatically).

For other annotations it would make more sense to store the value of the annotation (i.e. the size of a pipe) in a property on the object itself, and have a separate annotation object that can be moved and configured separately (but does take the *value* to show from the related object). I suspect that the draft label is very near to being usable for these, it just might need to support showing arbitrary properties, rather than just a hardcoded list of them (and possibly have a format string). This might be fairly easy to solve by allowing CustomText to be an expression, such as .Target[0].Diameter, maybe expanding expressions to allow string literals and string concatenation so you can do "⌀ " + .Target[0].Diameter. Note that I can already seem to force CustomText to be an expression by using the "Show all" option of the property view and then right-clicking CustomText and picking Expression, but then I get "type in list must be str or unicode, not Base.Quantity", which I can solve by using UserString (i.e. .Target[0].Diameter.UserString). That still leaves some room for improvements (i.e. it produces "50,000 mm" and I might want to use a different unit, omit the unit, use less decimals, etc. but I think all of that could be solved by adding some number formatting and string functions to the expression engine maybe. Anyway, back to the main point.

Coming back from what would be ideal, to what would be practical to do right now, I would be ok with storing data inside annotations (even when it duplicates data in objects) and keeping annotations separate from objects, i.e. some more manual work to define the annotations I need (but if at all possible, it would be good if these manual annotations could somehow be identified using tags, links, or similar so they can be programmatically replaced with a custom script later). Also, I'm using a git master build right now, but if possible, I'd favor doing this with 0.19 features only (easier for other people in our organization). Adding some custom python scripts (macros or a custom workbench maybe) is also an option.

I had a look at doing annotations in Techdraw after sectioning, but it seems that Techdraw has limited to no tools for arbitrary drawings, an archview does not seem to expose any lines or points to techdraw to add annotions or dimensions to, and doing this at the techdraw level completely detaches the annotations from the physical/model world, which does not seem ideal. However, I just discovered that techdraw does supporting inserting arbitrary symbols from external SVG files and even supports inserting basic text insertion into such an SVG, which sounds promising. However, it does seem like this would essentially duplicate the full SVG symbol for every insertion of that symbol, unless you use links, but then you can no longer override the editable texts for each instance of the symbol. Anyway, let's look at other annotation options inside the model.

For most annotations (i.e. simple texts and maybe some lines for fire resistance, etc.) I think these can just be done using draft lines and text objects, inserted directly into the model on the floor plane of the level we're annotating. If these are then added to the section view (probably through a group or layer to keep things managable), then they show up in techdraw as expected. So these are easy. When it's just lines, you can combine a few lines (i.e. that form a symbol together) using "make compound" and then the symbol can be moved around, duplicated, linked, etc. as one as well.

What seems to be harder, is annotations that combine text and graphics. For example, an electrical outlet, that I'd like to look something like this:
Image

What I did here, was combine a draft line with two 180° arcs and add a draft text to show the circuit number ("1" here). When adding these to the section view (probably through some nested groups for structure), they show up in the techdraw view as expected. However, to keep things managable, each outlet should be somehow be grouped so it shows up as a single object in the treeview (with expandable child objects is fine) and can be moved around as a single object.

I tried a few different approaches: Std::Group, Std::Part, make Compound, and part simplecopy (of a Std::Part or compound) but I could not get any of them work well enough.

The most obvious problem is that, except in groups, draft text objects (and also draft labels) are not shown in a section view. For compounds and simplecopy, this makes sense, since AFAIU those operate on the shape of the contained objects, and draft text produces no shape (nor is there any shape primitive for shapes). These would not even show the text in the 3D view. For Part objects, the text would be shown in the 3D view but not in the sectionview. I'm not entirely sure why, maybe the section view delegates drawing the part to the part rather than delegating it to the draft module (which I think it does for other draft and 2D-looking objects)? Note that in addition to text, this same applies to arrows at the end of a line, and I presume everything else that is normally by the draft viewproviders (unlike the basic lines, which are represented in the draft object's shapes as produced by their execute method). Groups do not seem to suffer from this, presumably because the section view just looks through these and draws the contained objects instead.

Another problem is moving the symbol as a whole. For compounds and simplecopy, this works as expected: select the draft move tool, click the object in the 3D view, select two points and the entire thing is moved. For groups and parts, however, you end up selecting parts of the symbol (i.e. individual wire objects) and moving those, breaking up the symbol. This can be worked around by preselecting the group or part in the treeview before selecting the move tool, though.

Simplecopy has the advantange that it is nice and compact in the treeview (just a single opaque object), but it also means that you cannot edit the object anymore after creating (you can probably explode it into parts, edit or replace some parts and reassemble the simplecopy, but I cannot see any way to do this in a way that existing links to the simplecopy object are preserved.

The above suggests that using groups might be the best approach, but I'm a bit hesitant to introduce that many groups into my document (i.e. one for every outlet, means a couple of hundred in the entire drawing). At the very least, that would make the BIM "Add to group..." dialog completely useless.

Any additional suggestions on approaches that would work for the above right now? Or which approach would be easiest to make working? I am under the impression that making text show up in compounds and simplecopy is going to be hard and a hack at best, but maybe letting sectionview treat parts similar to groups might work?

I also considered using shapestring rather than text objects, which works to some degree. However, these produces faces, so this loses the actual text content in the generated SVG and is probably heavier to render and needs to provide an explicit ttf file, which seems less portable to me. It also seems that any compound or simplecopy that includes a face causes arcs to be rendered as faces instead of edges too (but only in techdraw through arch sectionview, in 3D it does render properly), see below (using a rectangle face, but the same happens when using a text face). And using shapestring inside a part gives me "Gui.ViewProviderDocumentObject' object has no attribute 'ShapeColor'" when rendering the sectionview. The latter two are probably fixable bugs, so might not be blockers, but it still feels like shapestring is not the answer here.

Image

A completely different option would be to introduce a custom 2D object or so for these annotations, similar to the CAD2D proof of concept from this forum thread by chakkree. That one works by configuring a drawing using SVG-like drawing commands in a stringlist property, which are converted to a Shape in the object's execute method. This suffers from similar problems with text that cannot be directly represented in a shape, so the CAD2D code solves this by hardcoding a "font" that translates letters into lines and arcs so they can be directly represented in a shape. This is clever, but suffers from similar (performance) problems as the shapestring approach, I guess.

On a related note, it does seem that techdraw / sectionview enforces font size and (font/line) color, rather than using what the draft object defines, which might be somewhat limiting (but, with sufficient structure in the sections and the objects they select, might also actually be useful, I haven't figured this one out yet...).

I'd be happy for some pointers or suggestions on how to achieve the things that (I think) I need (maybe with changes to the code), suggestions for different workflows are also highly welcome :-)
paullee
Posts: 3510
Joined: Wed May 04, 2016 3:58 pm

Re: How to annotate a floorplan right now?

Postby paullee » Wed May 05, 2021 3:43 pm

Before other peoples have more experience on 2D provide more immediate comments :)

matthijskooijman wrote: Wed May 05, 2021 3:01 pm For additional context, I am a software engineer by trade and have pretty much no experience in arch/BIM/etc., so I'm learning this as a go...
Welcome to contribute improving Arch/BIM wb :D
matthijskooijman wrote: Wed May 05, 2021 3:01 pm However, I really need to produce something on quite a short term, so I'm trying to figure out if there is a way I can start with something that works and looks well enough now, and maybe replace the approach with a nicer approach later.
Regis has some very good video, hope it helps - FreeCAD Arch - Creating 2D Plan - 02
phpBB [video]


matthijskooijman wrote: Wed May 05, 2021 3:01 pm
The annotations I'm currently considering:
  • Electrical annotations, in particular wall outlets, light switches and light fixtures, annotated with their circuit number and optionally switch letter.
  • Various piping in the building. I think these can just be modeled as pipe objects, which should show up on the floorplan directly (haven't tested yet, though).
  • Indications of fire-resistance for doors (i.e. a line with two x's at the end perpendicular to the door opening)
  • Indications of fire separation (i.e. lines overlaid over e.g. walls)
  • Other indications (room numbers, notes for specific doors or walls, etc.)
Ideally, the values of these annotations (and maybe the annotation itself), would be part of the objects they apply to. For example, Arch door object currently already automatically generate a symbol showing the swing of the door in the floorplan, based on the door and hinge definition. For fire-resistance in doors, it would be similarly nice if I could just set a property "FireResistance: 30min" or something like that on the door and the symbol would be automatically adapted...

Yes! These are something needs to be done, particularly if all needs has equivalent IFC attributes (I have not much idea about IFC in fact).

Not sure Draft Label could be improved to show more attributes in an Arch Objects?
https://wiki.freecadweb.org/Draft_Label

matthijskooijman wrote: Wed May 05, 2021 3:01 pm I suspect that the draft label is very near to being usable for these, it just might need to support showing arbitrary properties, rather than just a hardcoded list of them (and possibly have a format string). This might be fairly easy to solve by allowing CustomText to be an expression, such as .Target[0].Diameter, maybe expanding expressions to allow string literals and string concatenation so you can do "⌀ " + .Target[0].Diameter. Note that I can already seem to force CustomText to be an expression by using the "Show all" option of the property view and then right-clicking CustomText and picking Expression, but then I get "type in list must be str or unicode, not Base.Quantity", which I can solve by using UserString (i.e. .Target[0].Diameter.UserString)..."
Similar idea above :)

matthijskooijman wrote: Wed May 05, 2021 3:01 pm What seems to be harder, is annotations that combine text and graphics. For example, an electrical outlet, that I'd like to look something like this:
This make me miss AutoCAD, very easy to do that there, something I had no longer use for more than ten years.
matthijskooijman wrote: Wed May 05, 2021 3:01 pm The most obvious problem is that, except in groups, draft text objects (and also draft labels) are not shown in a section view.
I thought Arch SectionPlane + TechDraw ArchView support Draft Text / Annontation ?

Wow, overwhelming account of Arch / Draft / BIM wb capabilities :D

Maybe you can ping @yorik at some point, the core developer of FreeCAD, Draft, Arch/BIM. He seems very occupied recently though.
User avatar
bitacovir
Posts: 1455
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: How to annotate a floorplan right now?

Postby bitacovir » Wed May 05, 2021 4:01 pm

matthijskooijman wrote: Wed May 05, 2021 3:01 pm
I'd be happy for some pointers or suggestions on how to achieve the things that (I think) I need (maybe with changes to the code), suggestions for different workflows are also highly welcome :-)
Very long post! :)

I think you already are well informed about current potential of FreeCAD as drafting tool. As Yorik says, now the idea is to choose a path and improve and optimize it. If you can do something about that, it would be great. I take the strategy of drawing everything on the 3D space (including symbols and annotations) and using TechDraw only for final layout. I don't like import SVG files into TechDraw because I prefer to keep the FC files independent.
Look my workflow. It includes a demo file: https://wiki.osarch.org/index.php?title ... D_workflow
::bitacovir::
===================================
One must be absolutely modern.
Arthur Rimbaud (A Season in Hell -1873)

My personal web site
My GitHub repository
My old Blog
Mini Airflow Tunnel Project
matthijskooijman
Posts: 70
Joined: Thu Mar 25, 2021 10:59 am

Re: How to annotate a floorplan right now?

Postby matthijskooijman » Wed May 05, 2021 4:32 pm

paullee wrote: Wed May 05, 2021 3:43 pm Regis has some very good video, hope it helps - FreeCAD Arch - Creating 2D Plan - 02
Thanks, I had already seen some of their videos, including this one. Their approach is different: Rather than using sections, they just use draft tools to draw everything in 2D (in 3D space) directly, which I guess could also work. It seemed like a lot more manual work and there's no real concept of page sizes etc, but on the plus side, it does give more direct control over what you're drawing, I guess, so maybe I should reconsider that approach. Thanks.
bitacovir wrote: Wed May 05, 2021 4:01 pm Very long post! :)
Yeah, I've been digging and testing for a few days now :-) And writing such experiences down is always useful IMHO, even if not to get an answer, then just for others (and my future self) to learn more :-p
bitacovir wrote: Wed May 05, 2021 4:01 pm I think you already are well informed about current potential of FreeCAD as drafting tool. As Yorik says, now the idea is to choose a path and improve and optimize it. If you can do something about that, it would be great.
As I said elsewhere, I had hoped that I could get this working without spending too much time (overall, and especially on development), but if I can see a path that does not look too long, I'll be happy to contribute something to that path :-)
bitacovir wrote: Wed May 05, 2021 4:01 pm I take the strategy of drawing everything on the 3D space (including symbols and annotations) and using TechDraw only for final layout. I don't like import SVG files into TechDraw because I prefer to keep the FC files independent.
Look my workflow. It includes a demo file: https://wiki.osarch.org/index.php?title ... D_workflow
Right, it seems that you make sections in the 3D view and then do the annotations on those sections and then include the sections and annotations separately in the techdraw (i.e. with a draftview on a layer of draft objects/annotations rather than a sectionview on a group, which I was thinking about, though looking at the code, the end result in both cases is that Draft.get_svg ends up building the SVG for the draft objects). I can see the merit of this approach, though I don't really like the 3D space being littered with all these sections and annotations. Maybe I should reconsider that :-) It still does not solve the core problem of grouping symbols along with some text, I believe though.

In any case, thanks for the detailed workflow writeup and the examples, I will certainly be studying them a bit more closely and find some more nice tricks in there :-)
matthijskooijman
Posts: 70
Joined: Thu Mar 25, 2021 10:59 am

Re: How to annotate a floorplan right now?

Postby matthijskooijman » Thu May 06, 2021 2:03 pm

I had one more idea on how to approach the symbol+text case:
- Create a compound for the lines of the symbol (provided you do not need anything fancy from the draft tools, such as arrows on lines)
- Create a separate draft text or label, with a Host attribute set to the compound and a MoveWithHost so the label stays with the symbol

However, it seems draft text/label do not support Host/MoveWithHost currently, and I'm not sure if just adding them would work. Also, it would be nice if this would actually claim the text/label object (i.e. hide it in the main tree and show below the compound, but I guess that would require changes to the compound viewprovider too...).

Or is there some other way to "attach" a text or label to an arbitrary object to be moved together?
paullee
Posts: 3510
Joined: Wed May 04, 2016 3:58 pm

Re: How to annotate a floorplan right now?

Postby paullee » Thu May 06, 2021 6:17 pm

matthijskooijman wrote: Thu May 06, 2021 2:03 pm Or is there some other way to "attach" a text or label to an arbitrary object to be moved together?
I do not by habit use Move with Host :)

dLabel has a Target which could be pointed to the Compound in your worflow. In this case, maybe an Attachment extension be added to the dLabel so that is could 'attach' to the Compound object. Now if someone move the Compound, the dLabel follows.

How does that sounds?

Some Draft objects already has that, not the Support and MapMode attributes available in DWire objects - I want to add this to Arch Objects also :D

Test_ Draft Label_ 1_ attach to Compound.FCStd
(13.43 KiB) Downloaded 18 times
Screenshot from 2021-05-07 02-08-55.png
Screenshot from 2021-05-07 02-08-55.png (206.31 KiB) Viewed 813 times
Screenshot from 2021-05-07 02-09-26.png
Screenshot from 2021-05-07 02-09-26.png (204.96 KiB) Viewed 813 times
User avatar
bitacovir
Posts: 1455
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: How to annotate a floorplan right now?

Postby bitacovir » Thu May 06, 2021 7:06 pm

matthijskooijman wrote: Thu May 06, 2021 2:03 pm
Or is there some other way to "attach" a text or label to an arbitrary object to be moved together?
Option 1) use Draft Dimension as text. If you select an edge of the symbol you can link a dimension. The dimension moves with the geometry, but not in all directions. In the dimension properties you can overwrite the text and hide the lines. if you select these objects you can create a arch section and use this section as base for a Techdraw ArchView.

Option 2) the same than before, but you can put the symbol and de dimension in a container Std Part https://wiki.freecadweb.org/Std_Part In fact. with StdPart you can move text, labels, etc. with geometries.
dynamic_symbol.FCStd
(29.03 KiB) Downloaded 10 times
op1
s3l2uG6AfU.gif
s3l2uG6AfU.gif (525.86 KiB) Viewed 801 times
.
.
op2
oRZfoa4deH.gif
oRZfoa4deH.gif (422.79 KiB) Viewed 801 times
::bitacovir::
===================================
One must be absolutely modern.
Arthur Rimbaud (A Season in Hell -1873)

My personal web site
My GitHub repository
My old Blog
Mini Airflow Tunnel Project
ABeton
Posts: 147
Joined: Tue Sep 03, 2019 6:39 pm

Re: How to annotate a floorplan right now?

Postby ABeton » Thu May 06, 2021 7:36 pm

matthijskooijman wrote: Wed May 05, 2021 3:01 pm First, for some background: I need a tool to edit and generate complex and annotated floorplans for an existing building (3 connected buildings, 3 floors, about 2000m²), to document current state (including electrical, piping, etc.) and to draw proposed changes. I'm considering FreeCAD for this job. I realize that 2D floorplans and annotations are not the FreeCAD strongest points right now, but given FreeCAD's flexibility in document organization and its powerful scripting, I suspect it might be suited to the job nonetheless (and I really want some opensource workflow, or at least some workflow without any propietary lockin). For additional context, I am a software engineer by trade and have pretty much no experience in arch/BIM/etc., so I'm learning this as a go...

I've experimented a bit with the basics (walls, floors and openings) and producing a floorplan using arch sectionviews and techdraw and there's still some caveats there (especially wrt links), but I think I can manage to figure those out (and/or provide code fixes where needed). However, I can't quite figure out a practical way to get (2D) annotations/symbols on the floorplan. I've read various threads on the forum with suggestions on adding new symbol or annotation objects to solve this and those ideas sound great and very powerful. However, I really need to produce something on quite a short term, so I'm trying to figure out if there is a way I can start with something that works and looks well enough now, and maybe replace the approach with a nicer approach later.

The annotations I'm currently considering:
  • Electrical annotations, in particular wall outlets, light switches and light fixtures, annotated with their circuit number and optionally switch letter.
  • Various piping in the building. I think these can just be modeled as pipe objects, which should show up on the floorplan directly (haven't tested yet, though).
  • Indications of fire-resistance for doors (i.e. a line with two x's at the end perpendicular to the door opening)
  • Indications of fire separation (i.e. lines overlaid over e.g. walls)
  • Other indications (room numbers, notes for specific doors or walls, etc.)
Ideally, the values of these annotations (and maybe the annotation itself), would be part of the objects they apply to. For example, Arch door object currently already automatically generate a symbol showing the swing of the door in the floorplan, based on the door and hinge definition. For fire-resistance in doors, it would be similarly nice if I could just set a property "FireResistance: 30min" or something like that on the door and the symbol would be automatically adapted. Similarly, for electrical outlets, it would be nice if those would be regular 3D objects, that when sectioned, would produce a symbol. Ideally, such a symbol is not necessarily hardcoded (like the door swing), but can just be an arbitrary SVG, draft object(s), or other 2D object linked to the (Arch) 3D object. And any (custom or IFC) properties set on the 3D object (e.g. circuit number) can be used inside the symbol when rendering it (so you can set some properties in a semantic way, and have the symbol adapt automatically).

For other annotations it would make more sense to store the value of the annotation (i.e. the size of a pipe) in a property on the object itself, and have a separate annotation object that can be moved and configured separately (but does take the *value* to show from the related object). I suspect that the draft label is very near to being usable for these, it just might need to support showing arbitrary properties, rather than just a hardcoded list of them (and possibly have a format string). This might be fairly easy to solve by allowing CustomText to be an expression, such as .Target[0].Diameter, maybe expanding expressions to allow string literals and string concatenation so you can do "⌀ " + .Target[0].Diameter. Note that I can already seem to force CustomText to be an expression by using the "Show all" option of the property view and then right-clicking CustomText and picking Expression, but then I get "type in list must be str or unicode, not Base.Quantity", which I can solve by using UserString (i.e. .Target[0].Diameter.UserString). That still leaves some room for improvements (i.e. it produces "50,000 mm" and I might want to use a different unit, omit the unit, use less decimals, etc. but I think all of that could be solved by adding some number formatting and string functions to the expression engine maybe. Anyway, back to the main point.

Coming back from what would be ideal, to what would be practical to do right now, I would be ok with storing data inside annotations (even when it duplicates data in objects) and keeping annotations separate from objects, i.e. some more manual work to define the annotations I need (but if at all possible, it would be good if these manual annotations could somehow be identified using tags, links, or similar so they can be programmatically replaced with a custom script later). Also, I'm using a git master build right now, but if possible, I'd favor doing this with 0.19 features only (easier for other people in our organization). Adding some custom python scripts (macros or a custom workbench maybe) is also an option.

I had a look at doing annotations in Techdraw after sectioning, but it seems that Techdraw has limited to no tools for arbitrary drawings, an archview does not seem to expose any lines or points to techdraw to add annotions or dimensions to, and doing this at the techdraw level completely detaches the annotations from the physical/model world, which does not seem ideal. However, I just discovered that techdraw does supporting inserting arbitrary symbols from external SVG files and even supports inserting basic text insertion into such an SVG, which sounds promising. However, it does seem like this would essentially duplicate the full SVG symbol for every insertion of that symbol, unless you use links, but then you can no longer override the editable texts for each instance of the symbol. Anyway, let's look at other annotation options inside the model.

For most annotations (i.e. simple texts and maybe some lines for fire resistance, etc.) I think these can just be done using draft lines and text objects, inserted directly into the model on the floor plane of the level we're annotating. If these are then added to the section view (probably through a group or layer to keep things managable), then they show up in techdraw as expected. So these are easy. When it's just lines, you can combine a few lines (i.e. that form a symbol together) using "make compound" and then the symbol can be moved around, duplicated, linked, etc. as one as well.

What seems to be harder, is annotations that combine text and graphics. For example, an electrical outlet, that I'd like to look something like this:
Image

What I did here, was combine a draft line with two 180° arcs and add a draft text to show the circuit number ("1" here). When adding these to the section view (probably through some nested groups for structure), they show up in the techdraw view as expected. However, to keep things managable, each outlet should be somehow be grouped so it shows up as a single object in the treeview (with expandable child objects is fine) and can be moved around as a single object.

I tried a few different approaches: Std::Group, Std::Part, make Compound, and part simplecopy (of a Std::Part or compound) but I could not get any of them work well enough.

The most obvious problem is that, except in groups, draft text objects (and also draft labels) are not shown in a section view. For compounds and simplecopy, this makes sense, since AFAIU those operate on the shape of the contained objects, and draft text produces no shape (nor is there any shape primitive for shapes). These would not even show the text in the 3D view. For Part objects, the text would be shown in the 3D view but not in the sectionview. I'm not entirely sure why, maybe the section view delegates drawing the part to the part rather than delegating it to the draft module (which I think it does for other draft and 2D-looking objects)? Note that in addition to text, this same applies to arrows at the end of a line, and I presume everything else that is normally by the draft viewproviders (unlike the basic lines, which are represented in the draft object's shapes as produced by their execute method). Groups do not seem to suffer from this, presumably because the section view just looks through these and draws the contained objects instead.

Another problem is moving the symbol as a whole. For compounds and simplecopy, this works as expected: select the draft move tool, click the object in the 3D view, select two points and the entire thing is moved. For groups and parts, however, you end up selecting parts of the symbol (i.e. individual wire objects) and moving those, breaking up the symbol. This can be worked around by preselecting the group or part in the treeview before selecting the move tool, though.

Simplecopy has the advantange that it is nice and compact in the treeview (just a single opaque object), but it also means that you cannot edit the object anymore after creating (you can probably explode it into parts, edit or replace some parts and reassemble the simplecopy, but I cannot see any way to do this in a way that existing links to the simplecopy object are preserved.

The above suggests that using groups might be the best approach, but I'm a bit hesitant to introduce that many groups into my document (i.e. one for every outlet, means a couple of hundred in the entire drawing). At the very least, that would make the BIM "Add to group..." dialog completely useless.

Any additional suggestions on approaches that would work for the above right now? Or which approach would be easiest to make working? I am under the impression that making text show up in compounds and simplecopy is going to be hard and a hack at best, but maybe letting sectionview treat parts similar to groups might work?

I also considered using shapestring rather than text objects, which works to some degree. However, these produces faces, so this loses the actual text content in the generated SVG and is probably heavier to render and needs to provide an explicit ttf file, which seems less portable to me. It also seems that any compound or simplecopy that includes a face causes arcs to be rendered as faces instead of edges too (but only in techdraw through arch sectionview, in 3D it does render properly), see below (using a rectangle face, but the same happens when using a text face). And using shapestring inside a part gives me "Gui.ViewProviderDocumentObject' object has no attribute 'ShapeColor'" when rendering the sectionview. The latter two are probably fixable bugs, so might not be blockers, but it still feels like shapestring is not the answer here.

Image

A completely different option would be to introduce a custom 2D object or so for these annotations, similar to the CAD2D proof of concept from this forum thread by chakkree. That one works by configuring a drawing using SVG-like drawing commands in a stringlist property, which are converted to a Shape in the object's execute method. This suffers from similar problems with text that cannot be directly represented in a shape, so the CAD2D code solves this by hardcoding a "font" that translates letters into lines and arcs so they can be directly represented in a shape. This is clever, but suffers from similar (performance) problems as the shapestring approach, I guess.

On a related note, it does seem that techdraw / sectionview enforces font size and (font/line) color, rather than using what the draft object defines, which might be somewhat limiting (but, with sufficient structure in the sections and the objects they select, might also actually be useful, I haven't figured this one out yet...).

I'd be happy for some pointers or suggestions on how to achieve the things that (I think) I need (maybe with changes to the code), suggestions for different workflows are also highly welcome :-)
These are some good observations you have, FreeCAD is a really good 3D modeller but 2D needs to be improved. I think that it would be really good if you made a file for each annotation, and then to put each annotation file into the Parts Library from where you can either import or link them(also if you could add it to Git parts library for other people to use it would be great!). And using Group or Part objects to make complex annotations is not the most elegant solution but it works well. This is the system I used to have 2D drawings together with 3D. You can also try to use link sub-elements in an interesting way for 2D.

I really think that the Parts Library needs to be used much more in general, of course also improved(I am working on it slowly), and to have in it an Annotation folder with smart annotations. Also the discussion you linked about hatching is very interesting, we should try to revive that. I attached an example of how I combined a 2D drawing and a 3D model of a chair.

https://forum.freecadweb.org/viewtopic. ... 7&start=10

P.S. I forgot to add, does anyone know if we could save images in different sizes in FreeCAD 3D view. I mean I prefer images like that rather than Techdraw for documentation. So if I draw a rectangle that represents borders of a paper, could we export an image that is the size of that rectangle? I mean could it be done in Python?
Attachments
Link 2D.7z
(644.04 KiB) Downloaded 16 times
matthijskooijman
Posts: 70
Joined: Thu Mar 25, 2021 10:59 am

Re: How to annotate a floorplan right now?

Postby matthijskooijman » Thu May 06, 2021 8:20 pm

paullee wrote: Thu May 06, 2021 6:17 pm dLabel has a Target which could be pointed to the Compound in your worflow. In this case, maybe an Attachment extension be added to the dLabel so that is could 'attach' to the Compound object. Now if someone move the Compound, the dLabel follows.
Ah, Attachment also seems interesting. I just tried this and I can indeed attach a wire to a compound to make it move along with it. And as you said, draft text and label do not support attachment, but it turns out if you just use the Part -> Attachment... menu item, then it will just add an Attachment extension to a draft text and that seems to work pretty well.

Still some caveats:
  • You can no longer move the attached text or line with the draft move tool, I presume since that modifies placement, which is then reset by attachment. This could be fixed by making draft move smarter: If the moved object has an attachment, it could modify the attachment offset instead of the placement perhaps? Seems like a nice and generic improvement?
  • Attaching a line is a bit tricky to get placement right, since wires are created with placement (0,0,0) and the position in their Points, so if you draw a line somewhere nearby the thing you want to attach to, and then attach it, the line jumps to about double the intended coordinates. If you realize what happens, this is not bad (you can fix it manually or first draw something near the origin maybe). This is something that has bitten me more often, for example also with windows based on sketches, where the sketch defines the window position, not the window's placement, which is particularly weird when you make a link to such a door and then change the link's target to another window... Oh well, maybe some tool or macro exists to clean this up somehow :-)
As an added advantage, you can use expressions to refer to the attached-to-object's properties, e.g.:

Image

Expressions do not currently work for the Text property (I tested with the Label above), but as discussed in my original post for draft label, this might be fairly easy to improve on the expression engine side of things.

I did realize that this does not fully solve my problem yet, since now the text *moves with* the compound symbol, which is nice, but this still requires manually keeping them together (i.e. putting them into the same group etc.) or otherwise ensuring that they are both selected by the section to be displayed... But maybe I can do some smartness by just putting all annotations in a layer or so, and then maybe some custom script that figures out which annotations are attached to which objects and then moves them around (or explicitly includes them in the section maybe).

I guess that's an advantage of the Host property, that creates a reverse relation that *is* traversed by the section view, AFAICS. Might be abusing that relation a bit to position a label, though...
bitacovir wrote: Thu May 06, 2021 7:06 pm Option 1) use Draft Dimension as text. If you select an edge of the symbol you can link a dimension. The dimension moves with the geometry, but not in all directions. In the dimension properties you can overwrite the text and hide the lines. if you select these objects you can create a arch section and use this section as base for a Techdraw ArchView.
Ah, interesting approach. However, the fact that it moves along only on one dimension and not the other probably makes it pretty much unusable for the electrical outlet symbol case, but it was nice to play around with the dimension tool a bit, might be useful for other cases.
bitacovir wrote: Thu May 06, 2021 7:06 pm In fact. with StdPart you can move text, labels, etc. with geometries.
Yeah, I tried that, but the problem is that the section view does not see texts inside the part, it probably just renders the part shape, not the objects inside the part as it does for a group (see also my original post).The same holds for a Dimension object, just checked.
ABeton wrote: Thu May 06, 2021 7:36 pm I think that it would be really good if you made a file for each annotation, and then to put each annotation file into the Parts Library from where you can either import or link them(also if you could add it to Git parts library for other people to use it would be great!). And using Group or Part objects to make complex annotations is not the most elegant solution but it works well. This is the system I used to have 2D drawings together with 3D. You can also try to use link sub-elements in an interesting way for 2D.
Hm, using the parts library, interesting thought. I'm not sure what that means technically, but I'll play around with that, thanks.

What do you mean by link sub-elements here?

I'll also look at the your example, thanks for that!
paullee
Posts: 3510
Joined: Wed May 04, 2016 3:58 pm

Re: How to annotate a floorplan right now?

Postby paullee » Fri May 07, 2021 1:12 pm

matthijskooijman wrote: Thu May 06, 2021 8:20 pm Ah, Attachment also seems interesting. I just tried this and I can indeed attach a wire to a compound to make it move along with it. And as you said, draft text and label do not support attachment, but it turns out if you just use the Part -> Attachment... menu item, then it will just add an Attachment extension to a draft text and that seems to work pretty well.
Very long findings :)

First thing first. Effect of use of Part Attachment on an Object which do not have Attachment Extension incorporated in the code is temporary to my understanding.

If A attached to B, move B, A follows. Attachment Offset / MapMode attributes set their relative disposition.