Hello!
I am building a rather complex document spanning down four levels and collecting various neighbouring elements.
I have run into a problem, which I first thought might be a bug, but probably is some error in the code.
I start the documentation with a diagram with elements. For each element I get child elements with the built in sections: package>element>child elements>, and then continue with a custom script.
Elements
Collection
Notes: Read only
Returns a collection of child elements (sub-elements) attached to this element as seen in the tree view.
Collection Class
I had no problem continuing the document documenting relevant neighbours and further child elements. However, we added a child diagram which caused problems and I don't understand why. According to the documentation elem.Elements should only collect child elements, not all childs like child diagrams.
The strange thing also is that some elements which have child diagrams have correct documentation, but one element with child diagram only generates correctly if the child diagram is removed.
Snippet of the code which cause error SOMETIMES when there is a child diagram:
element = Repository.GetElementByID( objectID );
childElems = element.Elements;
for ( i = 0; i < childElems.Count; i++ )
{
currentElement = childElems.GetAt( i );
relatedRoles = getNeighbour( currentElement.ElementID, "stereotype", "ArchiMate_BusinessRole" );
if ( relatedRoles.length == 0 )
{
...
}
...
}
I think the problem is that childElems sometimes include a child diagram. Is that even possible??
Any help where to start debugging is appreciated! Perhaps it is enough to add
if ( childElems.Count == 0 )
? But I doubt that is the problem since there are child elements..