[ ArchWall ] - Part.getSortedCluster, Part.sortEdges(), again
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
The py files use different EOL (end of line) characters. I have updated the ZIP file in my previous post.
-
- Posts: 14
- Joined: Fri Dec 30, 2022 6:11 pm
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
How would I use the modified ArchWall.py in Freecad or replace the default one with it? Simply adding it as a macro and executing doesn't seem to do anything.Roy_043 wrote: ↑Tue Jan 03, 2023 10:34 am Attached is a ZIP with a modified ArchWall.py file and a FCStd test file. The original ArchWall.py is included in the Org folder. The modified code works on the 4 Xed rectangles (Sketch, Binder, Shape2DView and Link). But if you edit the Sketch and change the arc to normal geometry the results are less satisfactory. :mrgreen:
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
Backup: <installation_folder>/Mod/Arch/ArchWall.py and copy the new file in its place.
-
- Posts: 14
- Joined: Fri Dec 30, 2022 6:11 pm
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
please tell me if this is off topic, but I found this might be useful for anybody using the realthunder branch. When trying to use the modified python script I got following error:
Checking Draft/draftgeoutils/faces.py the bind() function in the latest realthunder release does indeed not contain a per_segment argument. Using the faces.py from the latest official branch fixes the issue, archwalls.py now works as expected.
Huge thanks to Roy for the modified script :)
Code: Select all
File "/Users/username/Applications/FreeCAD.app/Contents/Mod/Arch/ArchWall.py", line 1451, in getExtrusionData
face = DraftGeomUtils.bind(w1, w2, per_segment=True)
<class 'TypeError'>: bind() got an unexpected keyword argument 'per_segment'
07:20:01 9.7e-08 <App> ArchWall.py(341)|Document.cpp(4327): Failed to recompute type1_schablone#Wall: bind() got an unexpected keyword argument 'per_segment'
07:20:01 Recompute failed! Please check report view.
Huge thanks to Roy for the modified script :)
- Attachments
-
- Screenshot 2023-01-06 at 07.41.03.png (146.9 KiB) Viewed 950 times
-
- Posts: 14
- Joined: Fri Dec 30, 2022 6:11 pm
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
although interestingly on this example the original archwall.py produces a better result.
original: Roy's version:
original: Roy's version:
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
Thanks @eigenwertnotfound for testing, can share the model file ?
-
- Posts: 14
- Joined: Fri Dec 30, 2022 6:11 pm
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
Hi paullee, archwall_gridtest is the sketch I originally broke it with. I tried to provide a minimal example where it breaks and now the crossed box which worked for me originally doesn't work either (although it breaks in a different way than the original python script). Very confused right now...
- Attachments
-
- archwall_gridtest1.FCStd
- (35.59 KiB) Downloaded 23 times
-
- archwall_gridtest.FCStd
- (29.77 KiB) Downloaded 22 times
Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again
Interesting grid test. Need to avoid multiple edges with ends coincidence - though it may be natural to layout like this.
May have an idea how to tackle this.
Test result on my FC 0.21.0.31391, AppImage on Fedora 36
May have an idea how to tackle this.
Test result on my FC 0.21.0.31391, AppImage on Fedora 36
Code: Select all
OS: Fedora Linux 36 (Workstation Edition) (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.21.0.31391 (Git)
Build type: Release
Branch: master
Hash: 0ab2608a429f3a5ee9a63da9b66d13557655d7e4
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods:
* dodo 1.0.0
* DynamicData 2.46.0
* ArchTextures
* BOLTSFC.backup1666323893.5041647
* BOLTSFC
* FreeCAD-BlenderBIM.backup1666328110.015535
* FreeCAD-BlenderBIM.backup1666737837.420096
* FreeCAD-BlenderBIM 2022.10.20
* BIM.backup1670731522.690569
* BIM 2021.12.0
* 3rd link to Paul
* 3rd link to SketchArchPlus
Re: [ ArchWall ] - Part.getSortedCluster, Part.sortEdges(), again
OK, tests to see different in behaviour in sorting edges in Sketch by :
Test 1 : Used Part.getSortedCluster()
- Part.getSortedCluster()
- Part.sortEdges() (Not Part.__sortEdges__(), which return only 1st edge)
Test 1 : Used Part.getSortedCluster()
- Steps - Run below codes after file opened
- Result - 2 shapes created (1st 5 edges with the diagonal one ('self-intersecting'), 2nd with the opposite diagonal edge)
( 2nd screencapture )
- Steps - Codes remark out line 14, un-remark line 15; run revised codes after file opened
- Result - 3 shapes created ( 1st 4 edges, 2nd with the diagonal one, 3rd with the opposite diagonal edge)
( 3rd screencapture )
Code: Select all
obj = FreeCAD.ActiveDocument.getObject('Sketch')
skGeom = obj.GeometryFacadeList
skGeomEdges = []
skPlacement = obj.Placement # Get Sketch's placement to restore later
basewires = []
for i in skGeom:
if not i.Construction:
# support Line, Arc, Circle for Sketch as Base at the moment
if isinstance(i.Geometry, (Part.LineSegment, Part.Circle, Part.ArcOfCircle)):
skGeomEdgesI = i.Geometry.toShape()
skGeomEdges.append(skGeomEdgesI)
for cluster in Part.getSortedClusters(skGeomEdges):
#for cluster in Part.sortEdges(skGeomEdges):
clusterTransformed = []
for edge in cluster:
edge.Placement = edge.Placement.multiply(skPlacement) ## TODO add attribute to skip Transform...
clusterTransformed.append(edge)
# Only use cluster of edges rather than turning into wire
basewires.append(clusterTransformed)
c = [App.Placement(App.Vector(6000.0,2000.0,0.0),App.Rotation(App.Vector(0.0,0.0,1.0),0.0)), App.Placement(App.Vector(6000.0,-2000.0,0.0),App.Rotation(App.Vector(0.0,0.0,1.0),0.0)) , App.Placement(App.Vector(12000.0,0000.0,0.0),App.Rotation(App.Vector(0.0,0.0,1.0),0.0)) ]
print(basewires)
len(basewires)
for i in range(len(basewires)):
w=Part.Wire(basewires[i])
w.Placement = c[i]
Part.show(w)