Cancel
Showing results for 
Search instead for 
Did you mean: 

In API, make a copy of "Resource"folder of object tree

Pioneer
Pioneer

hello, 

 

I have made a Windows Form named resource Editor in VS. I want to make visible "Resource" folder to that form.

 

Thanx 

1 REPLY

Re: In API, make a copy of "Resource"folder of object tree

Siemens Legend Siemens Legend
Siemens Legend

Using the API you cannot access the "Resources" folder directly.
What you can do is query all objects directly under the physical root, filter it to get only resources and then query each object for it's children and construct the hierarchy.

        public void BuildResourceTree(ITxObjectCollection compound)
        {
            //create node for compound in tree
            TxTypeFilter filter = new TxTypeFilter();
            filter.AddIncludedType(typeof(ITxComponent));
            filter.AddIncludedType(typeof(TxCompoundResource));
            TxObjectList childResources = compound.GetDirectDescendants(filter);
            //TODO: handle sub-compound resources
            foreach (TxCompoundResource childCompound in childResources)
            {
                BuildResourceTree(childCompound);
            }

            foreach (TxComponent childComponent in childResources)
            {
                if (childComponent.PlanningRepresentation is TxPlanningResource)
                {
                    //TODO: create node for child components in tree
                }
            }
        }

Then use this function on the physical root:

BuildResourceTree(TxApplication.ActiveDocument.PhysicalRoot);