[CONNECT .net c#] How to copy ECInstance from cell to all its subelements

need a little bit of direction/help. I have a dgn file with 10000s of elements that came from different shape files. to be clear these are elements in the model. It is not a shape file reference. 

the attributes from the shape file turned into an item on the element. 

my problem is the shape file did some weird things when importing it. some of the linear line strings came in as a cell comprised of several line strings. i need to drop those cells but i don't want to lose the attribute data that came from the shape file.

So i want to get the item on the cell and then loop the sub elements and apply that item to all the sub elements.

finding the cells and looping the sub-elements is not a problem, its how to copy the item.

i normally deal with item types but quickly found out these items are not an item type and i cant use the sdk calls im used it using.

im able to see the item on a given cell by looping the ECInstances.

but im struggling with the next step. 

im thinking i need to get the schema for this item and then attach it as a new ECInstance to each sub-element and then apply the property values from the item on the cell to each new ec instance on each sub-element.

if i was dealing with item types i would create a customitemhost and applycustomitem. but not sure how do to this at at the ec level???

using (DgnECInstanceCollection dgnECInstances = DgnECManager.Manager.GetElementProperties(el, ECQueryProcessFlags.SearchAllClasses))
                {
                    foreach (IDgnECInstance ecInstance in dgnECInstances)
                    {
                        if (ecInstance.ClassDefinition.Name == "OhioRailLinesSelect")
                        {
                            //get schema from instance
                            IECSchema schema = ecInstance.ClassDefinition.Schema;
                            //
                            ChildElementCollection subElements = (el as CellHeaderElement).GetChildren();
                            foreach (Element subElement in subElements)
                            {
                                //add new EC instance to subelement??

                                //loop and apply value to each property 
                                
                            }
                        }
                    }
                }

any help/direction would be great! thanks

Parents Reply Children
No Data