Request for help from newbie regarding converting polyhedron to wireframe
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Posts: 156
- Joined: Tue Apr 16, 2019 11:25 pm
Re: Request for help from newbie regarding converting polyhedron to wireframe
here the file
- Attachments
-
- 999-edges_as_body.FCStd
- (174.28 KiB) Downloaded 7 times
Marcel a freecad lover
-
- Posts: 156
- Joined: Tue Apr 16, 2019 11:25 pm
Re: Request for help from newbie regarding converting polyhedron to wireframe
I tried buiding something inspired by your idea.
used downgrade to faces from lattice 2 worbench, then link and scale. then made a lof of outer face and inner face pair. then used thicknesstool in part workbench.. is it something in that direction you want to create?
used downgrade to faces from lattice 2 worbench, then link and scale. then made a lof of outer face and inner face pair. then used thicknesstool in part workbench.. is it something in that direction you want to create?
- Attachments
-
- icosahedron._faces_loft_thickness.FCStd
- (105.85 KiB) Downloaded 10 times
-
- icoshedron_faces_loft_thickness.png (10.24 KiB) Viewed 1004 times
-
- sample Icosahedron honeycomb.png (163.58 KiB) Viewed 1004 times
Marcel a freecad lover
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Request for help from newbie regarding converting polyhedron to wireframe
@bonomo
Here's a script that takes a solid polyhedron and builds a frame edge struts. The struts aren't truncated at the corners. If this is some sort of structure, you'd need to design corner pieces anyway and you can use them subtractively to clean of the extra.
EDIT: Fixed my uploads etc.
Here's a script that takes a solid polyhedron and builds a frame edge struts. The struts aren't truncated at the corners. If this is some sort of structure, you'd need to design corner pieces anyway and you can use them subtractively to clean of the extra.
Code: Select all
#script to make edge structure of a regular polyhedron
#select the polhedron in the tree view and run the macro
#Ed williams 7/9/22
import Part
from math import degrees
DEBUG = False
if DEBUG:
import ptvsd
print("Waiting for debugger attach")
ptvsd.enable_attach(address=('localhost', 5678))
ptvsd.wait_for_attach()
doc = App.ActiveDocument
sel, = Gui.Selection.getSelection()
edges = sel.Shape.Edges
vertices = sel.Shape.Vertexes
def radialExtrudeEdge(edge, radialDist, thick, center = App.Vector(0, 0, 0)):
LS = Part.LineSegment
v1, v2 = [v.Point for v in edge.Vertexes]
v1p = (1 + radialDist/(v1 - center).Length)*(v1 - center) + center
v2p = (1 + radialDist/(v2 - center).Length)*(v2 - center) + center
poly = Part.makePolygon([v1, v1p, v2p, v2, v1])
shp = Part.Face(poly)
axis = v2 -v1
midpoint = (v1 + v2)/2
halfangle = degrees((thick/(midpoint - center).Length) * 0.5)
revp = shp.revolve(center, axis, halfangle)
revm = shp.revolve(center, axis, - halfangle)
return revp.fuse(revm)
fuse = False #fusing is slow and sometimes fails
center = sel.Shape.CenterOfGravity # regular solid so expand around center
radius = (vertices[0].Point - center).Length
radialDist = radius/20 # input - or specify distance
thick = radius/20 # input - or specify distance
shps = []
for edge in edges:
shp = radialExtrudeEdge(edge, radialDist, thick, center)
shps.append(shp)
if fuse:
fusedshp = shps[0].fuse(shps[1:])
Part.show(fusedshp, sel.Name + "_frame")
else:
cmpd = Part.makeCompound(shps)
Part.show(cmpd, sel.Name + "_struts")
- Attachments
-
- polyhedronstruts.FCStd
- (783 KiB) Downloaded 11 times
Re: Request for help from newbie regarding converting polyhedron to wireframe
it exactly does your OP #1 question (or q in title)...
nothing more nothing less
nothing more nothing less
-
- Posts: 156
- Joined: Tue Apr 16, 2019 11:25 pm
Re: Request for help from newbie regarding converting polyhedron to wireframe
my attempts are stupid handwork compared to that elegant script...
But anyway i managed to make something....
Used workbenches:
part lattice2(addon) Pyramids-and-Polyhedrons (addon)
When you load the fcstd both addons must be installed otherwise you get errors...
But anyway i managed to make something....
Used workbenches:
part lattice2(addon) Pyramids-and-Polyhedrons (addon)
When you load the fcstd both addons must be installed otherwise you get errors...
- Attachments
-
- dodekaeder_honeycomb.png (149.81 KiB) Viewed 875 times
-
- dodecahedron_honeycomb.FCStd
- (182.48 KiB) Downloaded 11 times
Marcel a freecad lover
-
- Posts: 156
- Joined: Tue Apr 16, 2019 11:25 pm
Re: Request for help from newbie regarding converting polyhedron to wireframe
thx for the awesome script edwilliams16.edwilliams16 wrote: ↑Sat Jul 09, 2022 8:10 pm @bonomo
Here's a script that takes a solid polyhedron and builds a frame edge struts.
Screen Shot 2022-07-09 at 9.56.32 AM.pngScreen Shot 2022-07-09 at 9.57.08 AM.png
Screen Shot 2022-07-09 at 10.05.59 AM.png
The struts aren't truncated at the corners. If this is some sort of structure, you'd need to design corner pieces anyway and you can use them subtractively to clean of the extra.
I used your script on a Icosahedron created with Pyramids-and-Polyhedrons(addon). great result.
To transform the result of your script into a structure containing only one body the following actions were taken:
1. create Icosahedron-> Icosahedron
2. run macro struts->Icosahedron_struts
3. link the icosahedron and scale it in properties -> Icosahedron001
4. select Icosahedron_struts and fuse with lattice2 fuse_compound -> FuseCompound
5. part worbench boolean cut FuseCompound with Icosahedron001-> Cut
6. cut FuseCompound wit Cut -> Cut001
now you have 1 solid Body that has the overlapping corners removed. Attention lattice2 addon must be installed to open fcstd file
- Attachments
-
- Icosahedron_struts_1_body.FCStd
- (536.47 KiB) Downloaded 10 times
-
- Ikosahedron_1_body_clean.png (212.74 KiB) Viewed 846 times
-
- Ikosahedron_using_script.png (260.81 KiB) Viewed 853 times
Marcel a freecad lover
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Request for help from newbie regarding converting polyhedron to wireframe
Good idea. Also Lattice2's fuse_compound worked in this case where the Part fuse() failed. Maybe I'll rewrite the script to use that, but it would put a dependency on Lattice2, and the additional process is pretty simple.intufreecad wrote: ↑Sun Jul 10, 2022 8:58 pm
To transform the result of your script into a structure containing only one body the following actions were taken:
1. create Icosahedron-> Icosahedron
2. run macro struts->Icosahedron_struts
3. link the icosahedron and scale it in properties -> Icosahedron001
4. select Icosahedron_struts and fuse with lattice2 fuse_compound -> FuseCompound
5. part worbench boolean cut FuseCompound with Icosahedron001-> Cut
6. cut FuseCompound wit Cut -> Cut001
Part Boolean|intersection is more straightforward than two cuts.
- Attachments
-
- truncated_icosahedron_cleaned.FCStd
- (1000.01 KiB) Downloaded 12 times
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Request for help from newbie regarding converting polyhedron to wireframe
@bonomo @intufreecad
Seems like some of the difficulties I was having with more complex polyhedra were co-planar issues. This seems to be robust:
Seems like some of the difficulties I was having with more complex polyhedra were co-planar issues. This seems to be robust:
Code: Select all
#script to make edge structure of a regular polyhedron
#select the polyhedron in the tree view and run the macro
#Ed williams 7/9/22
#Added code that takes common with an expanded polyhedron. This trims the struts at the corners. 7/11/22
import Part
from math import degrees
DEBUG = False
if DEBUG:
import ptvsd
print("Waiting for debugger attach")
ptvsd.enable_attach(address=('localhost', 5678))
ptvsd.wait_for_attach()
def radialExtrudeEdge(edge, radialDist, thick, center = App.Vector(0, 0, 0)):
v1, v2 = [v.Point for v in edge.Vertexes]
v1p = (1 + radialDist/(v1 - center).Length)*(v1 - center) + center
v2p = (1 + radialDist/(v2 - center).Length)*(v2 - center) + center
poly = Part.makePolygon([v1, v1p, v2p, v2, v1])
shp = Part.Face(poly)
axis = v2 -v1
midpoint = (v1 + v2)/2
halfangle = degrees((thick/(midpoint - center).Length) * 0.5)
revp = shp.revolve(center, axis, halfangle)
revm = shp.revolve(center, axis, - halfangle)
return revp.fuse(revm)
doc = App.ActiveDocument
sel, = Gui.Selection.getSelection()
edges = sel.Shape.Edges
vertices = sel.Shape.Vertexes
#fuse = True #fusing is slow and sometimes fails
center = sel.Shape.CenterOfGravity # regular solid so expand around center
radius = (vertices[0].Point - center).Length
radialDist = radius/10 # input - or specify distance
thick = radius/20 # input - or specify distance
scale = 1.1 # >1 to try to avoid coplanar issues
fuse = True #can be slow
shps = []
for edge in edges:
shp = radialExtrudeEdge(edge, radialDist * scale, thick, center)
shps.append(shp)
#fusedshp = shps[0].fuse(shps[1:])
#Part.show(fusedshp, sel.Name + "_frame")
lnk = doc.addObject('App::Link',sel.Name)
lnk.setLink(sel)
lnk.Label = sel.Name
lnk.Scale = 1 + radialDist/radius # try to avoid coplanar issues
lnk.Placement.Base = -(radialDist/radius)*center #compensate for scaling moving center
lnk.ViewObject.Visibility = False
shpscut = []
for s in shps:
shpscut.append(lnk.Shape.common(s))
cmpd = Part.makeCompound(shpscut)
cmpddoc = Part.show(cmpd, sel.Name + "_struts")
cmpddoc.ViewObject.Visibility = False
if fuse:
fusion = doc.addObject("Part::MultiFuse",sel.Name + '_frame')
fusion.Shapes = cmpddoc
fusion.Refine = True
doc.recompute()
junk = 0 #provides end breakpoint for debugger
-
- Posts: 522
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Re: Request for help from newbie regarding converting polyhedron to wireframe
Just an interested observer of this thread who happens to like structures. Call me crazy if you wish but when I saw the models on this page I immediately thought of Buckminster Fuller and his geodesic domes.
https://www.archdaily.com/572135/ad-cla ... ter-fuller
I was wondering if you could model something of this magnitude using the methods described above?
If I have wandered too far off topic please let me know and I will remove my post.
https://www.archdaily.com/572135/ad-cla ... ter-fuller
I was wondering if you could model something of this magnitude using the methods described above?
If I have wandered too far off topic please let me know and I will remove my post.
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Request for help from newbie regarding converting polyhedron to wireframe
If you keep the struts separate. Fusing them together at that scale would be verrry slow.Laurie Hartley wrote: ↑Tue Jul 12, 2022 4:06 am Just an interested observer of this thread who happens to like structures. Call me crazy if you wish but when I saw the models on this page I immediately thought of Buckminster Fuller and his geodesic domes.