1 Reply Latest reply on Sep 21, 2015 12:56 PM by Trevor Wunn

    Getting Line Length Using API

    Trevor Wunn

      Is it possible to grab a dimension from a selected line? I have been trying to use the API to get a dimension off of the bounding box line but have been unable to.

       

      I have this line where I am grabbing one of the bounding box lines.

      boolStatus = swModel.Extension.SelectByID2("Line2@Bounding-Box2", "EXTSKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)

       

      I have tried to measure it using the swModel.Extension.CreateMeasure code but it doesn't give me a value for some reason.

       

      Any help would be greatly appreciated.

       

      Thanks in advance,

       

      Trevor

        • Re: Getting Line Length Using API
          Trevor Wunn

          I figured it out, i think i had the wrong name selected for the bounding box so i added in some code to check through some possible names.

          Hopefully this helps anyone trying to get values from the bounding box.

           

          boolStatus = False

          i = 1

           

          Do While boolStatus = False

              line = "Line2@Bounding-Box" & i

              boolStatus = swModel.Extension.SelectByID2(line, "EXTSKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)

              i = i + 1

              If i > 100 Then

                  boolStatus = False

                  Exit Do

              End If

          Loop

           

          If boolStatus = False Then

              MsgBox "Please check your bounding box", vbOKOnly, "Error, Son!"

              End

          End If

           

          Set swMeasure = swModel.Extension.CreateMeasure

          boolStatus = swMeasure.Calculate(Nothing)

           

          'changes value to IN from system units

          length = swMeasure.length / 0.0254

          Debug.Print "Length: " &  length