2 Replies Latest reply on Jun 5, 2015 9:42 AM by Joshua Zastrow

    API for Geometric Tolerances

    Joshua Zastrow
      1. Hi all,


      So I'm writing/building off a program that exports dimensions from a drawing to an excel based inspection sheet (read: formatted list of dimensions). The program loops through annotations, and if it is a dimension, it exports the dimension (plus numerous other sub programs to identify dimension type, tolerance type, formatting for specific tolerancing et etc…) However, to my knowledge there is no way to identify geometric tolerances. I attach geometric tolerances to features or dimensions in the drawing, and would like them to be exported right after the dimension of that feature, but I have no way of identifying them or exporting them in my program. Excel has a font called “SWGDT” which writes in Geometric tolerances, but I need Solidworks to meet Excel halfway. Anyone have a way to help me out on thi? Without it, my program is incomplete and can only go as far as being a slightly handy tool in my own program tool kit and not a robust program that I need it to be for my company.




        • Re: API for Geometric Tolerances
          John Alexander

          There are a few options for grabbing IGtol objects. Take a look at the list of Accessors on this page: 2012 SOLIDWORKS API Help - IGtol Interface. From your description, it sounds like the macro already loops over every annotation and is probably checking if it is a dimension? In addition to checking if it is a dimension, you can check if it is a Gtol.


          I haven't dealt with Dimension or GTol before, but from the documentation, I suspect it would look roughly like this:


          Dim swAnnotation      As SldWorks.IAnnotation

          Dim swDimension      As SldWorks.IDimension

          Dim swGtol                As SldWorks.IGtol

          Dim arrayOfAnnotations As Variant


          'build the arrayOfAnnotations


          'loop over the array of annotations and grab it's interface if it is a dimension or gtol

          For Each swAnnotation in arrayOfAnnotations

               Select Case swAnnotation.GetType

                    Case swAnnotationType_e.swDisplayDimension

                         Set swDimension = swAnnotation.GetSpecificAnnotation

                         'Do things

                    Case swannotationType_e.swGTol

                         Set swGtol = swAnnotation.GetSpecificAnnotation

                         'Do things   

               End Select

          Next swAnnotation