2 Replies Latest reply on Jan 18, 2013 6:16 PM by Nozze Feduti

    Traversing Simple Part File

    Nozze Feduti

      Hi guys, I really need your help.

      I'm using this tutorial:




      It's for traversing assembly features using recursion. Well, I really don't know how to adapt it for being used with a single part file

      like just example.sldprt. When i run the code I get an exception 'cause the method getChildren obviously returns null and the recursion

      cannot start. I've tried placing an if.


      Recursion starts with:



      TraverseComponent(swRootComp, 1);




      private void TraverseComponent(Component2 swComp, int level)
      object[] vchildComp = (object[])swcomp.GetChildren();
      Component2 swChildComp;
      // Add
      if (vChildcomp == null)
      TraverseComponentFeatures(swComp, level);
      TraverseComponent(swChildComp, level + 1);
      for (int i=0; i< vChildComp.Length; i++)
      swChildComp = (Component2)vChildComp[i];
      TraverseComponentFeatures(swChildComp, level);
      TraverseComponent(swChildComp, level + 1);


      But I get a stackoverflow exception...should I divide it in two distinct methods?

      Many thanks in advance.