FreeCAD_SheetMetal icon indicating copy to clipboard operation
FreeCAD_SheetMetal copied to clipboard

Basename of the Unfolded objects

Open leoheck opened this issue 1 year ago • 14 comments

Hi @shaise , I would like to suggest to use the base Body name (actually Label) as the basename of the unfolded objects.

For instance, the object name is Bottom Then if I unfold it, it could generate the Bottom_Unfolded and the Bottom_Unfolded_Sketch

image

leoheck avatar Jun 27 '24 13:06 leoheck

Sounds like a good idea. Added to my to do list

shaise avatar Jun 27 '24 13:06 shaise

Nice, thanks. I tried to improve this here https://github.com/shaise/FreeCAD_SheetMetal/pull/352. What do you think?

leoheck avatar Jun 27 '24 14:06 leoheck

The proposal works as you can see in the screenshot below.

I just noticed an interesting thing. I have enabled the Freecad option to allow object with the same Label. So no more 001, 002, 003.. at the end of repeated objects.

However when I repeat the unfolding of the same object. It creates this new Part ending with 001 and a new Sketch with the right name as in my configs. I am not sure if this is an issue with the Sheetmetal or if this is an issue with my latest 0.22-dev build.

What do you think?

image

leoheck avatar Jun 27 '24 14:06 leoheck

Ah nevermind, this looks like a bug on the latest dev.

leoheck avatar Jun 27 '24 14:06 leoheck

of object names are not unique anymore how can you tell them apart?

shaise avatar Jun 27 '24 17:06 shaise

hm did not know, I got the first parent from the Parents list and on my test, it worked. maybe I got lucky.

leoheck avatar Jun 27 '24 17:06 leoheck

Actually all partents are the same, maybe...

This example here: image

Gui.Selection.addSelection('Unnamed','Body001','Bend001.')
>>> ### Begin command Std_SendToPythonConsole
>>> # try:
>>> #     del(doc,lnk,obj,shp,sub,subs)
>>> # except Exception:
>>> #     pass
>>> # 
>>> # doc = App.getDocument("Unnamed")
>>> # obj = doc.getObject("Bend001")
>>> # shp = obj.Shape
>>> ### End command Std_SendToPythonConsole
>>> obj.Label
'Bend001'
>>> obj.Parents
[(<body object>, 'Bend001.'), (<body object>, 'Bend001.')]
>>> obj.Parents[0][1]
'Bend001.'
>>> obj.Parents[0][0].Name
'Body001'
>>> obj.Parents[0][0].Label # <======== Label of the First parent
'my_Body'
>>> obj.Parents[1][0].Label # <======== Label of the Second parent
'my_Body'
>>> 
```python

leoheck avatar Jun 27 '24 17:06 leoheck

I dont think it has to do with object parents. It should be done based on the selected object before the fold.

shaise avatar Jun 27 '24 17:06 shaise

it can happen too.

leoheck avatar Jun 27 '24 17:06 leoheck

the feature is inside a body, the selected body is the same.

leoheck avatar Jun 27 '24 17:06 leoheck

can I select multiple bodies to unfold at the same time?

leoheck avatar Jun 27 '24 17:06 leoheck

no

shaise avatar Jun 27 '24 17:06 shaise

If I select a face to unfold, then there is no selected body. image

What is selected is a face. Which has a parent body, which is the my_Body in this case

leoheck avatar Jun 27 '24 17:06 leoheck

The way I implemented works fine.

leoheck avatar Jun 27 '24 17:06 leoheck