6 Replies Latest reply on Jan 11, 2019 11:26 AM by Conner Davis

    Hole Wizard API changing the Standard drop down and the Hole Spec Size?

    Conner Davis

      I attached a photo below to show the two combo-boxes I am attempting to change with the solidworks api. I have the hole wizard feature in an object as shown in the code below, but how could I change the Standard to ANSI Inch and how could I for instance change the M5x0.8 to M4x 0.7? Any help would be great, and thank you!

       

       

       

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swFeatMgr As SldWorks.FeatureManager

      Dim swSelMgr As SldWorks.SelectionMgr

      Dim swFeat As SldWorks.Feature

      Dim swSelectionManager As SldWorks.SelectionMgr

      Dim swDim As SldWorks.Dimension

      Dim swWzdHole As WizardHoleFeatureData2

      Dim filename As String

       

       

       

       

      sub main()

       

       

      Set swApp = Application.SldWorks

      'UserForm1.Show

       

       

       

      fileName = "C:\Engineering\Admin_Macros\NUT-MASTER.SLDPRT"

      Set swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_Silent, "", errors, warnings)

      Set swFeatMgr = swModel.FeatureManager

      Set swSelMgr = swModel.SelectionManager

      Set swFeat = swModel.FeatureByName("Hole")

      Set swWzdHole = swFeat.GetDefinition

       

      """"""""""""""""

      Manipulate Hole Wizard Here

      """""""""""""""""""""""

       

       

       

       

      End Sub

        • Re: Hole Wizard API changing the Standard drop down and the Hole Spec Size?
          Josh Brady

          ChangeStandard method

          ThreadDiameter property.

           

          However, reading a little bit between the lines, I don't think I would recommend your overall activity here. 

          Sounds like you're trying to build a nut that you can edit using API when people want to use it.  It's usually better to create configurations in a file, especially for standard hardware.

            • Re: Hole Wizard API changing the Standard drop down and the Hole Spec Size?
              Conner Davis

              Josh,

              I am actually taking a "Nut" part file as a basis then taking user input to modify the part to create the nut that the user wants then saving the part off as a user designated new part number into our system. Basically what I discovered was instead of creating parts from scratch it is faster to take a "base" model then modify it to the users input. Does that make sense?

                • Re: Hole Wizard API changing the Standard drop down and the Hole Spec Size?
                  Josh Brady

                  Yes, but...

                  It's much easier, especially for standard parts whose discrete sizes are already known, to go ahead and set up a single part file using a design table to control the dimensions per size.  All acceptable configurations are already generated by the table, although they are not built until activated so the file size doesn't bloat.  Hopefully you don't have different part numbers for every nut that every user uses?

                    • Re: Hole Wizard API changing the Standard drop down and the Hole Spec Size?
                      Conner Davis

                      Josh,

                       

                      If I am understanding you right your saying set up a table to have each thread with the correct correlating diameter then access that table select the dimension and then put that into the design table to change the dimension? I see that would work, but I am just trying to change the thread selection with the drop down in solidworks so I can use all of the attributes of the hole wizard for future automation in drawings

                        • Re: Hole Wizard API changing the Standard drop down and the Hole Spec Size?
                          Josh Brady

                          I'm trying to figure out the context of how to best help you here... Depending on kinda "who you are" the help you need may be different.

                           

                          Based on the fact that (1) you're new here, (2) you figured out at least enough to know you're looking for WizardHoleFeatureData2 and have code to retrieve such, but (3) you didn't find the method and property that you needed to modify, even though they're right there in the help, and (4) it kinda sounds like you aren't familiar with Design Tables, I'm going to guess you're a fairly new SW user who knows his way around VBA to some degree and can see the power and potential of automation, and has some very ambitious plans to automate a bunch of stuff.  So basically me about 15 years ago. 

                           

                          A design table lets you set up a sort of "base" model, and then generate all the different configurations of that model by simply adding lines with dimension values in an Excel sheet.  For nuts and other standard hardware, the size data is readily available in tabular form, so it's easy to paste all the dimensions for every size into an Excel design table.  The Excel table can be saved in a master location or embedded in the part file.  The table can even use Excel functions to generate the part number (assuming the part number has some intelligence) and drive a custom property.  Then, when a user wants an M6 nut, they just open the Nut Master file and select the M6 configuration.  SolidWorks automatically updates the base part with the tabulated dimension data for an M6.  No macro/code needed.

                           

                          Also, as far as I've seen, very few people use Hole Wizard features in nut standard files.  I'm not sure what attributes you're looking to use in your future automation, but there's a good chance there are easier or more efficient ways to go about that.

                           

                          I hope that makes sense... Again, this whole message may be off if my guess about "who you are" is not right. 

                          Conner Davis wrote:

                           

                          Josh,

                           

                          If I am understanding you right your saying set up a table to have each thread with the correct correlating diameter then access that table select the dimension and then put that into the design table to change the dimension? I see that would work, but I am just trying to change the thread selection with the drop down in solidworks so I can use all of the attributes of the hole wizard for future automation in drawings