Various transition ducts

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jfc4120
Posts: 449
Joined: Sat Jul 02, 2022 11:16 pm

Various transition ducts

Post by jfc4120 »

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods: 
  * Help 1.0.3
I have one program from Designcad 2000 (using basiccad) that handles numerous transition shapes.

You basically

[*]Draw the fitting
[*]Choose how many key points to click for each end
[*]Then the program triangulates and lays out fitting flat.

Note the pre clicking of points, it's the key to the program working.

Main question, is this possible in Freecad python, the usage of some stored clicked points (or line endings / midpoints) to use in equations?

Some images attached: Also the program works on all type of crazy transitions since it depends on the points to handle the analytic geometry and trig.
Attachments
f3.png
f3.png (4.88 KiB) Viewed 464 times
f2txt.png
f2txt.png (7.77 KiB) Viewed 464 times
f2.png
f2.png (5.75 KiB) Viewed 464 times
f1.png
f1.png (6.73 KiB) Viewed 464 times
edwilliams16
Veteran
Posts: 3192
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Various transition ducts

Post by edwilliams16 »

jfc4120 wrote: Thu Jul 21, 2022 5:30 pm
Main question, is this possible in Freecad python, the usage of some stored clicked points (or line endings / midpoints) to use in equations?
They are all available via the Gui.Selection.getSelectionEx()
function. It returns a list of selected objects, and the locations clicked.

Code: Select all

sels = Gui.Selection.getSelectionEx()

Inspecting the first selection

Code: Select all

sels[0].SubObjects[0].ShapeType
would return 'vertex' or 'edge'
For a vertex

Code: Select all

sels[0].SubObjects[0].Point
would be its location.

Code: Select all

sels[0].PickedPoints
is the list of picked locations.

So there's not much to the required gui interface. It's easy to draw a line between two points, use Part.makeLine()
The challenge is all the book-keeping to create a valid triangulated shell to be unrolled.

FreeCAD's hierarchy here is
Vertex - Edge - Face - Shell

For a triangulated shell, you need a list of two vertices to make a (straight) edge. From three edges, you create a face. From a list of faces you make a shell.
Vertices are shared among edges, edges among faces etc. See https://wiki.freecadweb.org/Topological_data_scripting
Post Reply