Is there a method/way to see what folder an object is in by only looking at the object?
benfielder
Member Posts: 4
**
in Structures
For example, here is a folder called Strikers. I want to be able to apply a method to one of the beams inside this folder, and for it to tell me the name of the folder that it is in. Is this possible?
0
Answers
-
Hi
Do not think there is an inbuilt method, but perhaps this can be done in different ways - one idea that does not use any possible internalobjects, is to get the folders (either geometry or connections folders see code below and change as needed), and then look through them to find the name of the object:
for connections
name='beam2' # name of beam object to look for/ change as needed folders=ExtAPI.DataModel.Project.Model.Connections.GetChildren(DataModelObjectCategory.TreeGroupingFolder, True) for folder in folders: for ch in folder.Children: if ch.Name.Split(" ")[0]==name: print(folder.Name)
for geometry:
name='sg1' # name of geom. object to look for/ change as needed folders=ExtAPI.DataModel.Project.Model.Geometry.GetChildren(DataModelObjectCategory.TreeGroupingFolder, True) for folder in folders: for ch in folder.Children: for ci in ch.Children: if ci.Name==name: print(folder.Name)
Perhaps the above is of some help.
1 -
This helps, thank you!
1 -
Thank you for the feedback. Very glad to hear that it helped.
Erik0