How to annotate a floorplan right now?

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: How to annotate a floorplan right now?

Post by ABeton »

matthijskooijman wrote: 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!
For the library thing, I was just thinking longterm, that we should have all kinds of "smart objects" including annotation and doors and windows with 2D symbols placed there. The file I attached with the chair could be considered a "smart" library object. What I did in this case is create a chair file in the Parts Library and than I made a 2D view of the chair and put them all in a Link group.

I discovered that if you make a sub-link of the 2D object it will follow the 2D object arround and you can still keep it in a different group or layer and change its visual properties as you wish. Maybe the same principal could be used for annotations. Also to create a sub-link an element needs to be in a Link group I think.

It is a bit difficult to explain properly how this works, but I hope it helps a bit. Try to examine the file I attached before, and see if you get an idea.

And check the topic I linked, I showed there how I did it.
matthijskooijman
Posts: 72
Joined: Thu Mar 25, 2021 10:59 am

Re: How to annotate a floorplan right now?

Post by matthijskooijman »

Slightly related note: While testing, I noticed that when you make a compound that contains a shapestring *and* a line (probably also other draft objects) and render a section view of that, then the section view becomes *really* slow (like 4 seconds to just render a single line and the word "default"). A compound with either the line or the shapestring (or even two compounds with one each) renders instantaneously. No time to investigate now, but in case this is useful for others. For now, it does rule out using shapestrings in compounds entirely, though.

I've also noticed a problem where groups containing only flat thing (i.e. a typical annotation) get rendered twice, the second time ignoring visibility of the group contents. I submitted a fix here: https://github.com/FreeCAD/FreeCAD/pull/4780
User avatar
bitacovir
Veteran
Posts: 1570
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: How to annotate a floorplan right now?

Post by bitacovir »

matthijskooijman wrote: Sun May 09, 2021 4:25 pm I submitted a fix here: https://github.com/FreeCAD/FreeCAD/pull/4780
Thanks for your work.
::bitacovir::
==================
One must be absolutely modern.
Arthur Rimbaud (A Season in Hell -1873)

Canal Youtube Grupo Telegram de FreeCAD Español

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

Re: How to annotate a floorplan right now?

Post by matthijskooijman »

ABeton wrote: Sat May 08, 2021 11:53 am For the library thing, I was just thinking longterm, that we should have all kinds of "smart objects" including annotation and doors and windows with 2D symbols placed there. The file I attached with the chair could be considered a "smart" library object. What I did in this case is create a chair file in the Parts Library and than I made a 2D view of the chair and put them all in a Link group.

I discovered that if you make a sub-link of the 2D object it will follow the 2D object arround and you can still keep it in a different group or layer and change its visual properties as you wish. Maybe the same principal could be used for annotations. Also to create a sub-link an element needs to be in a Link group I think.
Right, I had a closer look at the file and topic, nice approach, I see how these sublinks work now. Now to see if I can use something of this in my workflow maybe :-)

One downside is that, I think, you still need to select all 2D objects manually into the layer, so if you add a few more chairs, they won't automatically appear in the layer, but I guess that's really a limitation of how the layer is implemented (with the layer linking to its contents, rather than the reverse).

But the idea, to bundle a 3D object with a 2D representation is nice. This might need to be supported by the code somehow, so it can automatically use the 3D object in 3D space and the 2D symbol in e.g. a section view, but that's not quite trivial, I'm afraid.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: How to annotate a floorplan right now?

Post by paullee »

Impressive progress :) Hope @yorik will merge that soon :D
matthijskooijman
Posts: 72
Joined: Thu Mar 25, 2021 10:59 am

Re: How to annotate a floorplan right now?

Post by matthijskooijman »

I did one more test with a draft shape2dview, as an alternative to a techdraw sectionview for rendering annotations, but that didn't really work well either. I couldn't get it to produce a projection of my Arch section plane, but when I pointed it to the group of Annotations, it worked. However, it does not seem to project *any* text at all, not even the draft-text-in-a-group that the TD section view displays. Also, shape2dview seems to always ignore visibilty and my shapestrings become wires/edges, no longer faces, so I guess that shape2dview just really produces a shape consisting of edges only and is not useful here.

Then I tried one more thing and used a TD draftview to view the annotations in TD. This does not produce a section, but for pure annotations, that would be fine. However, as I expected, this renders pretty much the same thing as the sectionview: No (draft/label) text is shown, except for the text contained in a group. One interesting thing here is that your can see that the lines contained in the group are wider, since those are rendered using the orginal wire's line width (as long as the draft view's OverrideStyle is false), while the others (parts, compounds, etc.) have been squashed into a shape containing just the edges and no info about line width, so those use the draftview's line width properties.

I've cleaned up my tests a bit and put them in a separate file, for anyone who is interested:
Annotations test.FCStd
(188.27 KiB) Downloaded 37 times
I think the conclusion so far is that I'm going to try the following:
- Draw the symbol using draft wires and arcs
- Make a compound from those
- Create a link to that compound
- Put the link into a group (i.e. 4-plug electrical outlet)
- Create a draft text with the circuit number
- Put the text also in the group
- Then for each outlet, I just duplicate the group, reposition it and change the circuit number.

Some limitations:
- Moving needs a bit of extra care, to first select the group in the treeview and then move the entire thing.
- Alternatively, I could try using attachment to attach the text to the symbol, but then I'd have to modify the draft move tool to modify the attachment offset for attached parts, so you can still conveniently move the text relative to the symbol if needed.
- This will create a ton of groups, making the "Move to group.." feature unusable quickly, I suspect. But make that feature could be improved to show a proper tree view rather than just a flat list of groups (maybe conditionally only when there are more than 15 groups or so, or when there are non-unique labels among the groups?).

Additional thoughts:
- Maybe put the symbol itself, or a template group-with-link-and-text in a separate file
- It would be useful to add more string support to the expression system, as I mentioned earlier, so then you could e.g. define the group label as an expression "4way outlet, circuit " + .Group[1].Text[0], to changing the text inside the group also automatically updates the group label for easy reference (here [1] refers to the second element in the group, which is a bit hardcoded, and [0] is the first line of text).
- It would be even nicer if the group (being the top-level object) could have a custom "Circuit" property and have the text refer to that instead, but I don't think the text can access its containing group in an expression (not unless you add a link from the text to the group, but then you'd have a dependency loop).
- For multiple outlets belonging to the same circuit, you could just make a link to the entire group as well, if nothing needs to change except for placement.
Bance
Veteran
Posts: 4186
Joined: Wed Feb 11, 2015 3:00 pm
Location: London

Re: How to annotate a floorplan right now?

Post by Bance »

matthijskooijman wrote: Sun May 09, 2021 6:27 pm It would be useful to add more string support to the expression system
There are substantial changes in the pipeline from RT branch, in this area. You may check his code? Or there is a forum thread related somewhere(Dev forum perhaps).

Forgive me I'm not a coder, but there is also Dynamic Data WB, and Feature Python Objects, I don't know if they would be of use.

FeaturePython_Custom_Properties

DynamicData_Workbench
matthijskooijman
Posts: 72
Joined: Thu Mar 25, 2021 10:59 am

Re: How to annotate a floorplan right now?

Post by matthijskooijman »

Bance wrote: Mon May 10, 2021 7:27 am There are substantial changes in the pipeline from RT branch, in this area. You may check his code? Or there is a forum thread related somewhere(Dev forum perhaps).
Ah, indeed. I looked at RT's code and from the commit log found this wiki page that describes a lot of the changes: https://github.com/realthunder/FreeCAD_ ... onstration

It looks like the expression language was greatly extended to support a python-like syntax, and allow calling to mostly arbitrary python code as well as using most python types. That sounds like it could indeed make a lot of the things I'm considering would indeed be made possible, nice! I'm slightly worried about the security implications of this approach, though. There is already significant care of this using whitelists and blacklists, but calling potentially arbitrary code can always be risky... In any case, I'll be sure to look at this more closely before I consider submitting string improvements to the expression engine :-p

As for the DynamicData_Workbench, that sound like a convenient way to add custom properties (easier than using the hidden properties interface or scripting, which would be alternatives). It does seem it only allows custom properties on special property containers, not existing objects, but I guess that could work.
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: How to annotate a floorplan right now?

Post by ABeton »

matthijskooijman wrote: Sun May 09, 2021 5:20 pm
ABeton wrote: Sat May 08, 2021 11:53 am For the library thing, I was just thinking longterm, that we should have all kinds of "smart objects" including annotation and doors and windows with 2D symbols placed there. The file I attached with the chair could be considered a "smart" library object. What I did in this case is create a chair file in the Parts Library and than I made a 2D view of the chair and put them all in a Link group.

I discovered that if you make a sub-link of the 2D object it will follow the 2D object arround and you can still keep it in a different group or layer and change its visual properties as you wish. Maybe the same principal could be used for annotations. Also to create a sub-link an element needs to be in a Link group I think.
Right, I had a closer look at the file and topic, nice approach, I see how these sublinks work now. Now to see if I can use something of this in my workflow maybe :-)

One downside is that, I think, you still need to select all 2D objects manually into the layer, so if you add a few more chairs, they won't automatically appear in the layer, but I guess that's really a limitation of how the layer is implemented (with the layer linking to its contents, rather than the reverse).

But the idea, to bundle a 3D object with a 2D representation is nice. This might need to be supported by the code somehow, so it can automatically use the 3D object in 3D space and the 2D symbol in e.g. a section view, but that's not quite trivial, I'm afraid.
I fully agree with you on all points. We could perhaps have a way to clasify objects as 2D and add a property that says what kind of object it is(something similar to Arch Component): door, window and so on. Than(I don't know if it can be done, but probably yes) the Layer group should be able to detect 2D objects which are either imported, linked, or created and sort them according to its type; so all 2D doors go to doors layer, windows to windows and so on. Users could also make their own 2D object types and layers could be generated for them as well.
I think the conclusion so far is that I'm going to try the following:
- Draw the symbol using draft wires and arcs
- Make a compound from those
- Create a link to that compound
- Put the link into a group (i.e. 4-plug electrical outlet)
- Create a draft text with the circuit number
- Put the text also in the group
- Then for each outlet, I just duplicate the group, reposition it and change the circuit number.
For now on I think this is the best way to do it, we really need to make it simpler in the future :? It would be nice if we could have an option to lock groups or different kinds of objects, so they cant be expanded in the tree until unlocked(or that subobjects cant be selected unless unlocked).
Post Reply