[Bug?] TechDraw Detail view chokes if body contains both a volume and a sketch

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

[Bug?] TechDraw Detail view chokes if body contains both a volume and a sketch

Post by aapo »

Hi!

I found a way to use PartDesign sketches as a helper line system for TechDraw, by putting a solid volume and an unpadded sketch (containing helper geometry) inside a body, and then selecting both of them together for a TechDraw view projection. Works nicely for ProjGroup view, but there is a problem with Detail views, where I get an error message:
FreeCAD-helper-line-example-errormessage.png
FreeCAD-helper-line-example-errormessage.png (14.96 KiB) Viewed 1368 times
The unpadded sketch is nicely visible and dimensionable for ProjGroup views, but I never seem to get anything else than abovementioned error messages for the Detail view based on the ProjGroup items.
FreeCAD-helper-line-example-view.png
FreeCAD-helper-line-example-view.png (48.24 KiB) Viewed 1368 times
FCStd file demonstrating the problem:
FreeCAD-helper-line-example.FCStd
(17.28 KiB) Downloaded 69 times
Nice addition would be to have the unused sketches inside a body to always project as thinner dashed lines, so that it would be obvious that they are just helper geometry. Now I just change the linetypes in Inkscape or some other svg program. I'm not sure if projecting sketches to TechDraw is intended use, but at the moment it works very nicely in all other cases than Detail views. Thanks!

FreeCAD version:

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedKingdom (en_GB)
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Bug?] TechDraw Detail view chokes if body contains both a volume and a sketch

Post by wandererfan »

aapo wrote: Tue Mar 19, 2019 11:36 am I found a way to use PartDesign sketches as a helper line system for TechDraw, by putting a solid volume and an unpadded sketch (containing helper geometry) inside a body, and then selecting both of them together for a TechDraw view projection. Works nicely for ProjGroup view, but there is a problem with Detail views, where I get an error message:
Apparently, you cannot do a boolean fuse on a Sketch and a Pad:

Code: Select all

Rebuilding Views for: Page/Page
DVp - Fusion failed - ProjItem
Error in feature: Detail
DVD::execute - mkCommon not done
DVp - Fusion failed - ProjItem
Error in feature: Detail
DVD::execute - mkCommon not done
Or even in the Part workbench:

Code: Select all

Part::MultiFuse / Fusion: Links go out of the allowed scope
Exception (Tue Mar 19 16:26:10 2019): MultiFusion failed  
Will have to see if Detail can work without fusing multiple Source objects first.
Nice addition would be to have the unused sketches inside a body to always project as thinner dashed lines, so that it would be obvious that they are just helper geometry. Now I just change the linetypes in Inkscape or some other svg program. I'm not sure if projecting sketches to TechDraw is intended use, but at the moment it works very nicely in all other cases than Detail views.
Making a View of a Sketch is no problem, but Detail is expecting a Solid as input and Sketches are not Solids. Might need special handling for 2D input.

On the drawing board for v0.19 is the ability to insert 2D geometry on top of a View. This should give you what you need.
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] TechDraw Detail view chokes if body contains both a volume and a sketch

Post by aapo »

wandererfan wrote: Tue Mar 19, 2019 8:40 pm Will have to see if Detail can work without fusing multiple Source objects first.
Thanks! Do you mean that way you'd be able to solve the problem completely, because it would make Detail View working the same way as Views currently do?

Making a View of a Sketch is no problem, but Detail is expecting a Solid as input and Sketches are not Solids. Might need special handling for 2D input.
If it is not possible to process sketches in Detail View, would it be easy to completely filter out any sketches from Detail Views, so that the Detail View would show the solids and not choke on the sketch-is-not-a-solid error? That would of course be sub-optimal compared to what you propose, but possibly much easier to implement.

On the drawing board for v0.19 is the ability to insert 2D geometry on top of a View. This should give you what you need.
That'd be great! I'm really looking forward for the v0.19 development versions! :D
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] TechDraw Detail view chokes if body contains both a volume and a sketch

Post by aapo »

Hi,

I collected some additional info about the Detail View and Sketches. Interestingly, it seems to be ok for Detail View, if it is based on a View sourcing from two or more sketches. I haven't looked at the code, but for some reason combining two sketches does not fail, so I suppose it doesn't try to fuse the sketches together with the 3D-solid-fuse. I'd guess that the code seems to try to do boolean fuse only if there are two or more objects AND at least one solid. So, surprisingly enough, everything works very well with several sketches if there are no solids within the View source list!

Don't know if this helps, but I suspect that the boolean fusing is not (always) necessary in the Detail view for two reasons: a) The normal Views work fine without any boolean fusing, and b) multiple sketches within a body (without any solids) work already fine in the Detail View, too. Unfortunately, I think the boolean fusing of solids in Detail View has to be done at least in one case: If the Detail View is based on a Section View. At least I can't think of a way to make Section Views without boolean fusing the solids first (I should probably mention that the Section Views indeed have the same problems with a combination of sketches and solids). I suspect that the Detail View always does the boolean fuse blindly, in order to take account the possibility it might be based on a Section View.
FreeCAD-helper-line-example-2sketches-Detail.png
FreeCAD-helper-line-example-2sketches-Detail.png (45.17 KiB) Viewed 1250 times
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] TechDraw Detail view chokes if body contains both a volume and a sketch

Post by aapo »

Yes, it seems that TopoDS_Shape DrawViewPart::getSourceShape(void) const {...} can make a compound shape in a loop by for (auto& s:sourceShapes) { ... ; builder.Add(comp, shape);} in DrawViewPart.cpp instead of TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const making a boolean fuse. Thus, the function call getSourceShapeFused() in

Code: Select all

    TopoDS_Shape shape;
    if (dvs != nullptr) {
        shape = dvs->getCutShape();
    } else if (dpgi != nullptr) {
        shape = dpgi->getSourceShapeFused();
    } else {
        shape = dvp->getSourceShapeFused();
    }
in App::DocumentObjectExecReturn *DrawViewDetail::execute(void) of DrawViewDetail.cpp cause the possibly unnecessary fusing for dpgi and dvp source objects. It might be worthwhile to try ->getSourceShape() instead for both, so that the shape would be a compound in all other cases than dvs (i.e. sourced from Section View). However, there is some BLR BRepAlgoAPI_Common() stuff later in the function, for cutting the correct spatial volume for the Detail View. This would also need to be fixed in order for the Detail View to work properly, and I don't see how this could be done...
Post Reply