Comments (11)
The unfold is a single one time task and not linked to the object. There is no way to update it, you need to delete the existing and create a new one.
from freecad_sheetmetal.
Do you think this is a wontfix
or might be a feature request?
from freecad_sheetmetal.
There are 2 reason why it is not connected (and probably will not):
- the unfold is not automatic - it involves selecting a base face. Making changes to the original body in many cases changes the base face naming hence breaking the unfold
- the unfold process can be processor intensive, so if the unfold is automatically updated with every change it can lead to annoying cpu hangs.
from freecad_sheetmetal.
the unfold process can be processor intensive, so if the unfold is automatically updated with every change it can lead to annoying cpu hangs.
Based on this reason, it might be an option to handle the update with a button.
the unfold is not automatic - it involves selecting a base face. Making changes to the original body in many cases changes the base face naming hence breaking the unfold
I'm new to FreeCAD, but I think this depends on how correctly you designed a part. So the "update" button might generate an error if name is changed, else it would be performed smoothly.
from freecad_sheetmetal.
If you have to press a button to refresh you can as well press the unfold button again...
and in many cases no mater how correctly you design a part, the naming will change. So I think it does not worth the effort of making it automatic. But this is only my opinion.
from freecad_sheetmetal.
When a TechDraw page is created based on the unfold sketch, the TechDraw requires the same source sketch too. That makes things complex if you have more than one solid to unfold where their TechDraw pages are already generated, because you need to take care of correct namings too.
from freecad_sheetmetal.
This is a good point...
from freecad_sheetmetal.
Making changes to the original body in many cases changes the base face naming hence breaking the unfold
I think this depends on how correctly you designed a part.
I was wrong. The name of the face keeps changing even if you never perform an operation that changes the face geometry. However, there might be a way to go with Assembly3: realthunder/FreeCAD_assembly3#236
from freecad_sheetmetal.
Here is the proof of concept that works only with Assembly3:
- Patch sheetmetal to add
SMUnfoldUnattended
command:
diff --git a/SheetMetalUnfolder.py b/SheetMetalUnfolder.py
index d6b8821..05655c3 100644
--- a/SheetMetalUnfolder.py
+++ b/SheetMetalUnfolder.py
@@ -2456,3 +2456,42 @@ class SMUnfoldCommandClass():
Gui.addCommand('SMUnfold',SMUnfoldCommandClass())
+class SMUnfoldUnattendedCommandClass():
+ """Unfold object"""
+
+ def GetResources(self):
+ __dir__ = os.path.dirname(__file__)
+ iconPath = os.path.join( __dir__, 'Resources', 'icons' )
+ return {'Pixmap' : os.path.join( iconPath , 'SMUnfold.svg') , # the name of a svg file available in the resources
+ 'MenuText': "Unfold" ,
+ 'ToolTip' : "Flatten folded sheet metal object"}
+
+ def Activated(self):
+ SMMessage(["unattended unfold..."])
+ taskd = SMUnfoldTaskPanel()
+ pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/sheetmetal")
+ if pg.GetBool("bendSketch"):
+ taskd.checkSeparate.setCheckState(QtCore.Qt.CheckState.Checked)
+ else:
+ taskd.checkSeparate.setCheckState(QtCore.Qt.CheckState.Unchecked)
+ if pg.GetBool("genSketch"):
+ taskd.checkSketch.setCheckState(QtCore.Qt.CheckState.Checked)
+ else:
+ taskd.checkSketch.setCheckState(QtCore.Qt.CheckState.Unchecked)
+ taskd.bendColor.setColor(pg.GetString("bendColor"))
+ taskd.genColor.setColor(pg.GetString("genColor"))
+ taskd.internalColor.setColor(pg.GetString("intColor"))
+ taskd.accept()
+ return
+
+ def IsActive(self):
+ if len(Gui.Selection.getSelection()) != 1 or len(Gui.Selection.getSelectionEx()[0].SubElementNames) != 1:
+ return False
+ selobj = Gui.Selection.getSelection()[0]
+ selFace = Gui.Selection.getSelectionEx()[0].SubObjects[0]
+ if type(selFace) != Part.Face:
+ return False
+ return True
+
+
+Gui.addCommand("SMUnfoldUnattended",SMUnfoldUnattendedCommandClass())
- Use the following macro to update the unfolded sketches and related TechDraw ProjGroup sources:
"""
Usage:
1. Put your processed object into an assembly container.
2. Create an "Element" for the unfold face
3. Rename the element to "foo_unfold_face"
4. Run this macro
5. See "foo_unfold" sketch is created properly.
6. See any TechDraw ProjGroup source is updated properly
"""
import FreeCAD
import re
echo = FreeCAD.Console.PrintMessage
warn = FreeCAD.Console.PrintWarning
prev_workbench = Gui.activeWorkbench().name()
Gui.activateWorkbench("SMWorkbench")
if prev_workbench:
Gui.activateWorkbench(prev_workbench)
doc = App.ActiveDocument
unfold_sketch_regex = re.compile('.+_unfold_face')
for o in doc.Objects:
if o.TypeId == 'Part::FeaturePython':
match = unfold_sketch_regex.match(o.Label)
if match:
output_name = o.Label[:-5] # remove "_face" postfix
echo("Found unfold job: " + output_name + " \n")
related_views = []
for x in doc.Objects:
if x.TypeId == 'TechDraw::DrawPage':
for view in x.Views:
try:
_src = view.Source[0]
except:
continue
#print("source of ", x.Name, view.Name, " is: ", _src.Label)
if _src.Label == output_name:
# This view uses our unfolded output, update this view at the end
print("Found related TechDraw ProjGroup: " + view.Name)
related_views.append(view)
try:
old = doc.getObjectsByLabel(output_name)[0].Name
doc.removeObject(old)
doc.recompute()
except:
pass
# Get the unfold face id
# TODO: This extraction (achieving `unfold_face_id`) is a very dirty hack. Tidy up ASAP.
face_elem = doc.getObjectsByLabel(output_name + '_face')[0]
asm_container = face_elem.Parents[0][0]
target_obj_path = asm_container.getSubObjects()[0]
unfold_face_id = (asm_container.Name, target_obj_path + face_elem.LinkedObject[1].split('.')[-1])
# Unfold the object
Gui.Selection.clearSelection()
Gui.Selection.addSelection(doc.Name, unfold_face_id[0], unfold_face_id[1])
Gui.runCommand('SMUnfoldUnattended')
# Remove unnecessary unfolded solid
doc.removeObject('Unfold')
# Properly rename the output
sketch = doc.getObjectsByLabel('Unfold_Sketch')[0]
sketch.Label = output_name
sketch.Visibility = False
# Update the source of related views
for view in related_views:
echo("Updating " + view.Name + " source.")
view.Source = [sketch]
doc.recompute()
Gui.Selection.clearSelection()
from freecad_sheetmetal.
- the unfold is not automatic - it involves selecting a base face. Making changes to the original body in many cases changes the base face naming hence breaking the unfold
There is new topo naming algorithm implemented in my branch, which auto tracks the changing face index. For simple usage, just add a App::PropertyLinkSub
as usual, and the face reference inside will auto change when the geometry changes, and it is fully backward compatible with upstream. For advanced use, there is TopoShape.getRelatedElement()
function in case the geometry changes significantly that the new topo name changes as well. In many cases, simple usage is enough.
- the unfold process can be processor intensive, so if the unfold is automatically updated with every change it can lead to annoying cpu hangs.
You can add another property to enable/disable auto update. And maybe offer a context menu action in your ViewObject to let user manually update.
from freecad_sheetmetal.
Screencast
from freecad_sheetmetal.
Related Issues (20)
- why unfold failed HOT 2
- WallForming with wrong thickness HOT 1
- Extra lines on bends in unfold sketch HOT 14
- Bend is expanded far right outward HOT 1
- Changing the workbench's license HOT 34
- fold a wall error at curved sheet HOT 1
- Unfold : export sketch dxf ===> does not create a dxf file HOT 8
- TypeError in generateSketch HOT 3
- PropertyPythonObject::toString(): failed for <class 'SheetMetalCmd.SMViewProviderFlat'> HOT 3
- [feature] Fold non parallel sheet HOT 1
- [feature] refold unfolded sheet HOT 1
- [feature] fold wires (cylindrical surfaces) HOT 2
- Base Shape Tub, Hat and Box size wrong HOT 2
- No easy way to make hems HOT 3
- Extruded cutouts
- Clever bending direction HOT 6
- `SMFormingWall` is too complicated for most cases
- `SMFoldWall` should display an error message if the profile is not colinear lines HOT 5
- Making folded walls on planes or surfaces
- Round bend relief are rectangle if depth ≤ width
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freecad_sheetmetal.