2 Replies Latest reply on Oct 14, 2014 6:37 AM by M. Z

    showing i's value instead of i itself

    M. Z

      Hi everyone, there is part of my current research that needs to rename the name of each reference I created from Planex to x. Since the problem is hard to explain, I need to post the macro first.

       

      here is the key part of the macro loop:

      i = 1

      Do While i <10

      boolstatus = Part.Extension.SelectByID2("front plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

      Set RefPlane = Part.FeatureManager.InsertRefPlane(8, 1 * i, 0, 0, 0, 0)

      boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "????")

      Part.ClearSelection2 True

      i = i + 1

      Loop

      i = 1

       

      As you could see, I am trying to create 9 reference planes with the macro(in the future there might be a thousand or more). However, the ???? should be the VALUE of i in each loop. But if I enter "i" simply, it will not work cause every plane will be renamed as "i" and the program will not accept this. So how could I express the real value of i in the ???? area?

       

      This is a problem extremely hard to google for a beginner like me, sorry if the problem is too easy.

        • Re: showing i's value instead of i itself
          Deepak Gupta

          Try these:

           

          i = 1

          Do While i < 10

          boolstatus = Part.Extension.SelectByID2("front plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

          Set RefPlane = Part.FeatureManager.InsertRefPlane(8, 1 * i, 0, 0, 0, 0)

          boolstatus = Part.Extension.SelectByID2("Plane" & i, "PLANE", 0, 0, 0, True, 0, Nothing, 0)

          boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, i)

          Part.ClearSelection2 True

          i = i + 1

          Loop

          i = 1

            • Re: showing i's value instead of i itself
              M. Z

              Thank you very much, I have spent the last 5 hours finding the problem and it appeared the problem I found was not the real problem. I don't know what to say.

               

              Let me make a conclusion for other readers:

              1. vb doesn't need little features like those in C++ to infer variable value rather than variable. If you need to combine a word and the variable value, do as the correct answer("text"&i)

              2.After you do a reference plane, it appears that even you don't clear your selection, you still need to select it to do further work on it.