2 Replies Latest reply on Dec 30, 2015 8:00 PM by Michael Spens

    How to select with SW API the last created dimension on the SW drawing sheet?

    Milan Wendl

      Please help,

      I wish to get into the selection set 'ModelDoc2.SelectionManager' without manually set any dimension, the last created dimension of the SW drawing sheet for modification of its tolerance values.

      I could not find any trick to do that.

       

      Thanks fro the suggestions.

        • Re: How to select with SW API the last created dimension on the SW drawing sheet?
          roberto gennari

          Hallo,

          I have the same problem, once you have created a dimension, I saw that GetSelectObject returns nothing.

          I think the solution is to catch the event SldWorks_OnIdleNotify immediately after the insertion of the dimension.

          Let me know if you can find the solution, it might be useful to me.

           

          Thanks

           

           

          • Re: How to select with SW API the last created dimension on the SW drawing sheet?
            Michael Spens

            Hello Milan,

                 If a user creates a reference dimension in a drawing, it is still selected unless they hit esc or click away from it in the UI.  GetSelectedObject will return the dimension in that case.  Otherwise, there's no way to read a history of user-created dimensions.

                 If your code is creating the dimension, make sure you're using a method that returns a DisplayDimension interface.  For example, ModelDocExtension.AddDimension will return the DisplayDimension.  No need for it to be selected, you can operate directly on its properties and members from there.  If you have to select it, get its Annotation (GetAnnotation) and use the Select method.

                 Roberto has a good idea with event monitoring.  From IDrawingDoc, you could use UserSelectionPreNotify to trigger evaluation of the currently selected object before a new selection is made.  If it is a dimension that doesn't have expected tolerances, process as needed.

             

            Hope that helps!

             

            Mike