3 Replies Latest reply on Mar 14, 2018 2:17 PM by Hepzibah Chandranand

    CoordinateSystemFeatureData

    Wilfried Pietz

      Hello,

      i write a new Function to bring me back the Origin of the selected CoordinateSystem. But i do not work

       

      Public Function SetCoordSys(ByVal csys As String) As Boolean

           If m_ModelDoc Is Nothing Then

                Me.ErrTextKomp(My.Resources.FehlerTexte.DF_SwModeldocNothing, "SetCoordSys", ErrText)

                Return False

           End If

           SetCoordSys = False

           Dim boolstatus As Boolean

           Dim cSysData As CoordinateSystemFeatureData

           Dim CoordSys As Feature

           Dim geo As SldWorks.Entity

           'Koordinatensystem selektieren

           Dim swSelmgr As SldWorks.SelectionMgr = m_ModelDoc.SelectionManager

           boolstatus = m_ModelDoc.Extension.SelectByID2(csys, "COORDSYS", 0, 0, 0, False, 0, Nothing, 0)

           If boolstatus = True Then

                CoordSys = swSelmgr.GetSelectedObject6(1, -1) 'CoordSys is OK, i can see the right information

                cSysData = CoordSys.GetDefinition()

                geo = cSysData.OriginEntity()' This entry is nothing why???

           End If

           SetCoordSys = True

      End Function

       

      I want this information

       

      Thank you for your support

      Wilfried

       

      Nachricht geändert durch Wilfried Pietz marked wrong line

        • Re: CoordinateSystemFeatureData
          Artem Taturevych

          Try

           

          cSysData.AccessSelections(m_ModelDoc, Nothing)

          geo = cSysData.OriginEntity

            • Re: CoordinateSystemFeatureData
              Wilfried Pietz

              Yes, you're right, correct answer for the code.
              But not for my problem. My approach was just completely wrong

               

              Here is my solution

               

              Public Function GetCoordSysInfo(ByVal csys As String) As List(Of List(Of String))

                      GetCoordSysInfo = New List(Of List(Of String))

                      If m_ModelDoc Is Nothing Or csys.Length < 1 Then

                          Me.ErrTextKomp(My.Resources.FehlerTexte.DF_SwModeldocNothing, "GetCoordSysInfo", ErrText)

                      Else

                          Dim boolstatus As Boolean

                          Dim CoordSys As SldWorks.Feature

                          Dim swFeature As SldWorks.Feature

                          Dim swSelmgr As SldWorks.SelectionMgr = m_ModelDoc.SelectionManager

                          'Koordinatensystem suchen

                          boolstatus = m_ModelDoc.Extension.SelectByID2(csys, "COORDSYS", 0, 0, 0, False, 0, Nothing, 0)

                          If boolstatus = True Then

                              'Koordinatensystem selektieren

                              CoordSys = swSelmgr.GetSelectedObject6(1, -1)

               

                              ' Eltern und Kinderelemente auslesen

                              Dim Parents As Object = CoordSys.GetParents

                              Dim Children As Object = CoordSys.GetChildren

                              Dim PLST As New List(Of String)

                              Dim CLST As New List(Of String)

               

                              Dim varobj As Object

                              For Each varobj In Parents

                                  swFeature = varobj

                                  PLST.Add(swFeature.Name)

                              Next varobj

                              GetCoordSysInfo.Add(PLST)

               

                              If Not IsNothing(Children) Then

                                  For Each varobj In Children

                                      swFeature = varobj

                                      CLST.Add(swFeature.Name)

                                  Next varobj

                                  GetCoordSysInfo.Add(CLST)

                              End If

                          End If

                      End If

                  End Function

               

              Reslt:

               

              Thanke you for your support

              Wilfried

            • Re: CoordinateSystemFeatureData
              Hepzibah Chandranand

              How do you get the full names of the entities in the coordinate system data