1 Reply Latest reply on May 23, 2018 5:51 AM by Chiao Yang Chang

    How to get center coordinate values of a circle with reference to assembly origin?

    Chiao Yang Chang

      I use the following code to get center coordinate of circle01 (C01) and circle02 (C02).

      But the values are reference with part origin (see Fig1) rather than assembly origin (see Fig2).


      There are two questions:

      1. In the Measure Interface (see Fig3), there are no properties to get the center coordinate of cirle by selecting circle.

          But I can use Measure to get center coordinate with reference to assembly origin manually (see Fig2).

          How to use API like manual method in Fig2 ?

      2. How to modify the following code to change the coordinate values with reference to assembly origin ?

          e.g. change C01(-130,130,330) in Fig1 to C01(-130,116,-208.5) in Fig2


      【Code using VB.NET】

      Private Sub btnGetCenterPt_Click(sender As Object, e As EventArgs) Handles btnGetCenterPt.Click

              swModel = swApp.ActiveDoc
              swDocExt = swModel.Extension
              swSelMgr = swModel.SelectionManager

              Dim swMeasure As IMeasure
              Dim swSel01, swSel02 As Object

              Dim swCurve01, swCurve02 As Curve
              swCurve01 = swSel01.GetCurve
              swCurve02 = swSel02.GetCurve

              Dim C01(6), C02(6) As Double
              Dim i As Long
              For i = 0 To 6
                  C01(i) = swCurve01.CircleParams(i)
                  C02(i) = swCurve02.CircleParams(i)
              MsgBox("C01  X= " & C01(0) * 1000 & ", C01  Y= " & C01(1) * 1000 & Chr(13) & "C02  X= " & C02(0) * 1000 & ", C02  Y= " & C02(1) * 1000)
      End Sub










      2018-05-23 16_59_04-API Help.png