2 Replies Latest reply on Sep 15, 2014 10:48 PM by Sonen Saji

    How to get parent folder for using MoveToFolder

    Sonen Saji

      Hello

       

      How to get parent folder for using MoveToFolder?

       

      How to use MoveToFolder is the following

       

      Function MoveToFolder( _

         ByVal MoveToFeat As System.String, _

         ByVal MoveFromFeat As System.String, _

         ByVal IsFolder As System.Boolean _

      ) As System.Boolean

       

      I want to get 2th argument more easily.

      But I cannot find api to get parent folder of body.

      Is there no api? I have to traverse feature tree?

        • Re: How to get parent folder for using MoveToFolder
          Jesse Seger

          The help file is not very helpful on this one.  I tried a quick sample, and MoveToFolder is not working as I would expect.

          I can put any value I want for the second parameter, and the body will not move folders.  However, if I preselect the body, it will move the folder.

           

          Capture4.PNG

           

          So here is an example.  I want to move Structural Member1[2] to folder Cut-List-Item5.  If I was the code below, nothing will happen.  I can change the text to the parent folder, to name of the body, to the name of my first born, nothing will happen.

           

           

           

          Sub main()

             

              Dim swModel As ModelDoc2

              Dim swApp As SldWorks.SldWorks

              Dim featMgr As FeatureManager

              Dim bStatus As Boolean

             

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set featMgr = swModel.FeatureManager

             

              bStatus = featMgr.MoveToFolder("Cut-List-Item5", "Structural Member1[2]", False)

              Debug.Print bStatus

             

          End Sub

           

           

          But If I select the body I want to move.  The code will work.  Even if I put giberish in the second parameter. 

           

          bStatus = featMgr.MoveToFolder("Cut-List-Item5", "This is stupid", False)

           

          Will return True!!

           

          Capture5.PNG