3 Replies Latest reply on Mar 31, 2016 8:10 AM by Artem Taturevych

    change reference entities for an axis (API)

    Erik Söderby

      Hi there! I'm trying to change the reference entities for an axis, but somehow it doesn't work. I store the current entities in an array (GetSelections), and replace entity by entity in that array. Then I use SetSelection to execute the changes. Here's my code:

       

                      Dim ReferenceData As SldWorks.RefAxisFeatureData = referenceentity.GetDefinition

                      Dim types() As Integer = Nothing

                      SelCounter = ReferenceData.GetSelectionsCount

                      Dim AxisArray(SelCounter - 1) As Object

       

                      boolstatus = ReferenceData.AccessSelections(part, Nothing)

                      AxisArray = ReferenceData.GetSelections(types) 'store the current entities in an array

       

                      For L = 0 To SelCounter - 1

                          OldReference = AxisArray(L)

                          If OldReference.GetTypeName2 = replacemententity.GetTypeName2 Then

                          AxisArray(L) = replacemententity 'the new entity

       

                      Next L

                      boolstatus = ReferenceData.SetSelections(AxisArray)

       

                      boolstatus = referenceentity.ModifyDefinition(ReferenceData, part, Nothing)

                      ReferenceData.ReleaseSelectionAccess()

       

       

      For a plane it is simple:

      For L = 0 To SelCounter - 1

      OldReference = ReferenceData.Reference(L)

      If OldReference.GetTypeName2 = replacemententity.GetTypeName2 Then

      ReferenceData.Reference(L) = replacemententity

       

      ...but for axes, the function Reference(Index) does not exist, therefore the usage of GetSelections and SetSelections. Which does not work...  Any ideas?