1 Reply Latest reply on Aug 9, 2017 5:21 PM by Jacob Corder

    How to Show a specific Features Display Dimensions in a Part Document

    Jacob Corder

      I am in need of programmatically showing the Display dimensions of a specific feature in a Part Document.

       

      I have tried using selectbyid2,  ISelectionManager.AddSelectionListObject, ISelectionManager.AddSelectionListObjects,

      All of the above select the feature, but the feature dimensions do not display the same way if i select it in the Feature Tree.


      The features i am trying to Select Programmatically have No Faces.

      They are MacroFeatures

      They have Display Dimensions

       

      See the attached screenshots.

       

      The Code to do this is:

      Sub SelectParentFeature(ByVal ModDoc As ModelDoc2)

              If IsNothing(ModDoc) = False Then

                  Dim SelMgr As SelectionMgr = ModDoc.SelectionManager

                  Dim SelCt As Integer = SelMgr.GetSelectedObjectCount2(-1)

                  If SelCt = 1 Then

                      Dim SelFeat As Feature = Nothing

                      Select Case SelMgr.GetSelectedObjectType3(1, -1)

                          Case swSelectType_e.swSelFACES

                              Dim ThisFace As Face2 = SelMgr.GetSelectedObject6(1, -1)

                              If IsNothing(ThisFace) = False Then

                                  SelFeat = ThisFace.GetFeature

                              End If

                              ThisFace = Nothing

                          Case swSelectType_e.swSelBODYFEATURES

                              SelFeat = SelMgr.GetSelectedObject6(1, -1)

                      End Select

                      If IsNothing(SelFeat) = False Then

                              'Get the Parent Feature (Owner Feature)

                               Dim ParFeat As Feature = SelFeat.GetOwnerFeature

                               If IsNothing(ParFeat) = False Then

                                   ModDoc.Extension.SelectByID2(ParFeat.Name, "BODYFEATURE", 0, 0, 0, False, -1, Nothing, swSelectOption_e.swSelectOptionDefault)

                                   ParFeat = Nothing

                               End If

                               SelData = Nothing

                               SelFeat = Nothing

                           End If

                      SelMgr = Nothing

                  End If

              End If

          End Sub

      All this Sub Does is gets the Selected feature by either SwSelecttype_e.SwSelBodyFeatures or SwSelType_e.SwSelFaces.

      then it gets the Owner Feature which is the Feature i want to Show the DisplayDimensions of.

       

      i have tried getting all of the IDisplayDimensions using IFeature.GetFirstDisplayDimension and getting the Annotation from The IDisplayDimension using IDisplayDimension.GetAnnotation

      Then Setting the IAnnotation.Visibility to SwAnnotationVisibility_e.swAnnotationVisible which does nothing.

       

      I can make an IAnnotationView and show that but i dont like doing that because it would involve making a new one every time. you cannot name them so getting a special annotationview and clearing the IAnnotations from it seems like too much work. if i have to, i will though.

       

      But i would like to see if there is an easier route.

       

      Thanks

       

      So Basically all i want to do is show the displayDimensions of a feature without having to select anything.


      So Like IFeature.ShowDimensions would be sweet, or something to Achieve this goal

        • Re: How to Show a specific Features Display Dimensions in a Part Document
          Jacob Corder

          The code for this is

           

          Function ShowFeatureDimensions(ByVal ModDoc As ModelDoc2, ByVal ThisFeature As Feature) As Boolean

                  If IsNothing(ThisFeature) = False And IsNothing(ModDoc) = False Then

                      Dim Selmgr As SelectionMgr = CType(ModDoc.SelectionManager, SelectionMgr)

                      Dim DidSuspend As Boolean = False

                      If Selmgr.GetSelectedObjectCount2(-1) > 0 Then

                          Selmgr.SuspendSelectionList()

                          DidSuspend = True

                      End If

                      Try

                          If ThisFeature.Select2(True, 1) = True Then

                              ModDoc.ActivateSelectedFeature()

                              CType(ModDoc.ActiveView, ModelView).GraphicsRedraw(Nothing)

                              ModDoc.DeSelectByID(ThisFeature.GetID.ToString, "BODYFEATURE", 0, 0, 0)

                          End If

                      Catch ex As Exception

                      Finally

                          If DidSuspend = True Then

                              Selmgr.ResumeSelectionList()

                          End If

                          Selmgr = Nothing

                          CType(ModDoc.ActiveView, ModelView).GraphicsRedraw(Nothing)

                      End Try

                      Return True

                  End If

                  Return False

              End Function