shaise / FreeCAD_SheetMetal

A simple sheet metal workbench for FreeCAD
http://theseger.com/projects/2015/06/sheet-metal-addon-for-freecad/
GNU Lesser General Public License v2.1
190 stars 55 forks source link

Basename of the Unfolded objects #350

Open leoheck opened 2 months ago

leoheck commented 2 months ago

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

shaise commented 2 months ago

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

leoheck commented 2 months ago

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

leoheck commented 2 months ago

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 commented 2 months ago

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

shaise commented 2 months ago

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

leoheck commented 2 months ago

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

leoheck commented 2 months ago

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
shaise commented 2 months ago

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

leoheck commented 2 months ago

it can happen too.

leoheck commented 2 months ago

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

leoheck commented 2 months ago

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

shaise commented 2 months ago

no

leoheck commented 2 months ago

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 commented 2 months ago

The way I implemented works fine.