bernd wrote: ↑Thu Aug 10, 2017 8:12 pm
BTW:
Code: Select all
for i in nodefaces.items():
if not i:
print("found node without faces")
returns:
Code: Select all
>>>
>>> for i in nodefaces.items():
... if not i:
... print("found node without faces")
...
>>>
means all nodes have at least one face ...
Not really, items() returns a tuple of key/value pair from the dictionary.
if you run:
Code: Select all
for n in nodefaces.items():
print(n)
the output will be:
...
(1377L, [])
(1378L, [])
(1379L, [])
(1380L, [])
(1381L, [])
(1382L, [])
(1383L, [])
(1384L, [])
(1385L, [])
(1386L, [])
(1387L, [])
(1388L, [])
(1389L, [])
(1390L, [])
(1391L, [])
(1392L, [])
As you see the last nodes have an empty list, no faces.
bernd wrote: ↑Thu Aug 10, 2017 7:57 pm
when I load your file and run the following code I get an error:
...
Would you post the code you used to get the 978
When I run the code it works in my version of FreeCAD.
I don't understand why there is different behaviour, but I rewrote the code to have a flat list instead of a nested one.
Please try again.
Code: Select all
import numpy as np
femmesh = App.ActiveDocument.getObject("FEMMeshGMSH001").FemMesh
len(np.unique([id for f in femmesh.Faces for id in femmesh.getElementNodes(f) ]))
This should give the same output (978)
I think I found something which could explain the output (978)
Code: Select all
shape = App.ActiveDocument.Fusion001001.Shape
len(np.unique(( [ node_ids for f in shape.Faces for node_ids in (femmesh.getNodesByFace(f))])))
also returns 978
on an unrelated note:
My part is called
Fusion001001, which, for code clarity, is not a good name.
But when I rename the part in the project (using F2 or right click rename) the label changes but the name used to acces the shape through code stays the same. Is this intended behavior?
When I change the label, it changes in the property view, but there's no code generated in the python console, maybe that's the problem?