14 Replies Latest reply on Jun 7, 2017 5:57 PM by Andrew Johnson

    Hole callout problem, SW 2017 SP 2.0

    George Holdcroft

      I just changed to Solidworks 2017 Sp 2.0 from 2016, and all of my hole callouts on drawings show up with a strange tolerance.  This is with a plain hole that is thru with both near side and far side countersinks.  I have it set to "limits" tolerance, and it used to come through with the diameters set to limits, and the angles just the angle measurement with no tolerance.  When I changed to 2017, the diameters still come in as limits, and the angles come in as limits as well.  I manually fixed it in some drawings, but after re-opening the drawings, it went back to exactly what it was.  Even worse, it is set to 0.007 degrees as the default.  I am looking for where to fix this, and I can't find it anywhere.11220-01.JPG

        • Re: Hole callout problem, SW 2017 SP 2.0
          George Holdcroft

          A little update on this, not only does it revert back to what it was after re-opening the file, it does after saving the file.  below is a picture of what I want the text to look like.

          11220-01-2.JPG

          • Re: Hole callout problem, SW 2017 SP 2.0
            Andrew Johnson

            George, have you found any solution for this?

             

            We are having a very similar problem. All hole callouts on previously-created drawings are being assigned the 'Fit with Tolerance' tolerance type.

             

            SolidWorks 2016 SP5

            SLDWORKS_2017-06-05_12-06-50.png

             

            SolidWorks 2017 SP3

            mstsc_2017-06-05_12-06-19.png

            • Re: Hole callout problem, SW 2017 SP 2.0
              Dan Pihlaja

              2017 SP3 is out.  What happens if you upgrade to that?

              • Re: Hole callout problem, SW 2017 SP 2.0
                Gian Flavio Violi

                Looking into the Knowledge base I found a couple of SPR that might cover your problem. They haven't been fixed though, but since this is a regression I'm sure its getting attention.

                 

                Regards,

                GF

                • Re: Hole callout problem, SW 2017 SP 2.0
                  Andrew Johnson

                  As a workaround, I've got this code firing when a drawing is loaded.

                   

                  public static void RepairHoleCallouts(ModelDoc2 swModel) {     if (swModel.GetType() != (int)swDocumentTypes_e.swDocDRAWING)     {         throw new Exception("Invalid document type. Document must be a drawing.");     }      //Get ModelDoc Extension and Drawing Document     var swModelExt = swModel.Extension;     var swDraw = (DrawingDoc)swModel;      //Set Document Properties -> Dimensions -> Hole Callout -> Tolerance type to 'None'     swModelExt.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swDetailingToleranceStyle, (int)swUserPreferenceOption_e.swDetailingHoleDimension, (int)swTolType_e.swTolNONE);      // Get a list of all views in the drawing document, from all sheets.     var views = new List<View>();     var sheets = (object[])swDraw.GetViews();     foreach (var sheet in sheets)     {         var sheetViews = (object[])sheet;         foreach (var sheetView in sheetViews)         {             var view = sheetView as View;             if (view != null)             {                 views.Add(view);             }         }     }      //Loop through all views     foreach (var swView in views)     {         // Get first display dimension in view         var swDisplayDimension = swView.GetFirstDisplayDimension5();          //Loop through display dimensions.         while (swDisplayDimension != null)         {             // Get display dimension associated annotation object.             var swAnn = (Annotation)swDisplayDimension.GetAnnotation();              //Get the selected hole callout             var holeCalloutVariables = (object[])swDisplayDimension.GetHoleCalloutVariables();             if (holeCalloutVariables != null)             {                 // Initialize 'repair' flag as false.                 var needsRepair = false;                  // Loop through hole callout variables                 foreach (var holeVariable in holeCalloutVariables)                 {                     var swCalloutVariable = (CalloutVariable)holeVariable;                     var tolMin = swCalloutVariable.ToleranceMin;                     var tolMax = swCalloutVariable.ToleranceMax;                     var tolType = (swTolType_e)swCalloutVariable.ToleranceType;                      // Tolerance Type is 'Fit with Tolerance' and Tolerance Min/Max = 0                     // set Tolerance Type to 'None' and mark the dimension as requiring repair.                     if (tolType == swTolType_e.swTolFITWITHTOL && Math.Abs(tolMin) < .00001 && Math.Abs(tolMax) < .00001)                     {                         swCalloutVariable.ToleranceType = (int)swTolType_e.swTolNONE;                         needsRepair = true;                     }                 }                  // If dimension is flagged as needing repair, create temporary style from dimension, remove style and delete.                 if (needsRepair)                 {                     var tempStyleName = "TEMP";                      // Create style from dimension                     var addUpdateSuccess = swAnn.AddOrUpdateStyle(tempStyleName, true);                      // Set dimension style to 'NONE'                     var setNameSuccess = swAnn.SetStyleName(string.Empty);                      // Delete temporary style                     var deleteSuccess = swAnn.DeleteStyle(tempStyleName);                 }             }              //Get next display dimension             swDisplayDimension = (DisplayDimension)swDisplayDimension.GetNext3();         }     } }
                  

                   

                  public static void RepairHoleCallouts(ModelDoc2 swModel)
                  {
                      if (swModel.GetType() != (int)swDocumentTypes_e.swDocDRAWING)
                      {
                          throw new Exception("Invalid document type. Document must be a drawing.");
                      }

                      //Get ModelDoc Extension and Drawing Document
                      var swModelExt = swModel.Extension;
                      var swDraw = (DrawingDoc)swModel;

                      //Set Document Properties -> Dimensions -> Hole Callout -> Tolerance type to 'None'
                      swModelExt.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swDetailingToleranceStyle, (int)swUserPreferenceOption_e.swDetailingHoleDimension, (int)swTolType_e.swTolNONE);

                      // Get a list of all views in the drawing document, from all sheets.
                      var views = new List<View>();
                      var sheets = (object[])swDraw.GetViews();
                      foreach (var sheet in sheets)
                      {
                          var sheetViews = (object[])sheet;
                          foreach (var sheetView in sheetViews)
                          {
                              var view = sheetView as View;
                              if (view != null)
                              {
                                  views.Add(view);
                              }
                          }
                      }

                      //Loop through all views
                      foreach (var swView in views)
                      {
                          // Get first display dimension in view
                          var swDisplayDimension = swView.GetFirstDisplayDimension5();

                          //Loop through display dimensions.
                          while (swDisplayDimension != null)
                          {
                              // Get display dimension associated annotation object.
                              var swAnn = (Annotation)swDisplayDimension.GetAnnotation();

                              //Get the selected hole callout
                              var holeCalloutVariables = (object[])swDisplayDimension.GetHoleCalloutVariables();
                              if (holeCalloutVariables != null)
                              {
                                  // Initialize 'repair' flag as false.
                                  var needsRepair = false;

                                  // Loop through hole callout variables
                                  foreach (var holeVariable in holeCalloutVariables)
                                  {
                                      var swCalloutVariable = (CalloutVariable)holeVariable;
                                      var tolMin = swCalloutVariable.ToleranceMin;
                                      var tolMax = swCalloutVariable.ToleranceMax;
                                      var tolType = (swTolType_e)swCalloutVariable.ToleranceType;

                                      // Tolerance Type is 'Fit with Tolerance' and Tolerance Min/Max = 0
                                      // set Tolerance Type to 'None' and mark the dimension as requiring repair.
                                      if (tolType == swTolType_e.swTolFITWITHTOL && Math.Abs(tolMin) < .00001 && Math.Abs(tolMax) < .00001)
                                      {
                                          swCalloutVariable.ToleranceType = (int)swTolType_e.swTolNONE;
                                          needsRepair = true;
                                      }
                                  }

                                  // If dimension is flagged as needing repair, create temporary style from dimension, remove style and delete.
                                  if (needsRepair)
                                  {
                                      var tempStyleName = "TEMP";

                                      // Create style from dimension
                                      var addUpdateSuccess = swAnn.AddOrUpdateStyle(tempStyleName, true);

                                      // Set dimension style to 'NONE'
                                      var setNameSuccess = swAnn.SetStyleName(string.Empty);

                                      // Delete temporary style
                                      var deleteSuccess = swAnn.DeleteStyle(tempStyleName);
                                  }
                              }

                              //Get next display dimension
                              swDisplayDimension = (DisplayDimension)swDisplayDimension.GetNext3();
                          }
                      }
                  }