Using TD to create hatches in the FreeCAD model

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Using TD to create hatches in the FreeCAD model

Post by yorik »

This is moslty for @wandererfan I guess

I'd like to pursue this idea to use TD to create hatching of objects inside the model itself, that is, as OCC geometry.

The way I see it: The TechDraw::DrawGeomHatch is the main object to use there, right? It seems to be able to create hatching as a collection of OCC edges. I'm thinking of extending its Python interface so we can manipulate it directly form Python.

My question is, how is it meant to be used? It seems to be used only temporarily, to create the hatching, then it is deleted, is that right?

Then we could do the same from Arch/Draft...
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Using TD to create hatches in the FreeCAD model

Post by wandererfan »

yorik wrote: Thu Jan 23, 2020 3:28 pm I'd like to pursue this idea to use TD to create hatching of objects inside the model itself, that is, as OCC geometry.

The way I see it: The TechDraw::DrawGeomHatch is the main object to use there, right? It seems to be able to create hatching as a collection of OCC edges. I'm thinking of extending its Python interface so we can manipulate it directly form Python.

My question is, how is it meant to be used? It seems to be used only temporarily, to create the hatching, then it is deleted, is that right?
DrawGeomHatch(DGH) does create OCC edges based on a planar face outline and a PAT hatch specification. I don't think it will handle 3d faces in it's current form. It cheats a bit in using simple 2d algebra to find the endpoints of the hatch lines. You could do it in 3D with OCC functions, but it would be a significant change.

DGH isn't deleted after the hatches are created. If the base face changes or the pattern parameters are changed then hatches have to be recreated and DGH hangs around in case the parent view needs new hatches.

Not completely relevant side note: DGH and it's Svg equivalent (DrawHatch) probably shouldn't be DocumentObjects at all, but extensions to DrawViewPart and descendants. DGH & DH are going to be subsumed into a more general FacePainter in a future interation of TD.

You're looking for something like this?

Code: Select all

myHatch = list()  #list of ?TopoShapeEdgePy?
myHatch = hatchAFace(myFace, myPatFile, myPattern);
Seems like a worthwhile project, let me know what I can do to help.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Using TD to create hatches in the FreeCAD model

Post by yorik »

wandererfan wrote: Thu Jan 23, 2020 4:05 pm myHatch = list() #list of ?TopoShapeEdgePy?
myHatch = hatchAFace(myFace, myPatFile, myPattern);
Yes, that would be exactly what I have in mind. I wonder if we can't keep the DGH object anyway, seems practical... And transforming a face to be flat before performing the algorithm doesn't seem a big problem...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Using TD to create hatches in the FreeCAD model

Post by triplus »

It would be nice to have a Hatch command, to add hatches as real geometry to i guess faces and cross-sections directly in the 3D view.

https://forum.freecadweb.org/viewtopic. ... 10#p144481
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Using TD to create hatches in the FreeCAD model

Post by yorik »

I made some progress and came up with this, but it still crashes when trying to use it, not sure yet why..
Seems the good direction to you @WF?
https://github.com/yorikvanhavre/FreeCA ... 9d05230bbb
Post Reply