7 Replies Latest reply on Sep 3, 2015 10:38 AM by Alfonso Cartagena

    What is the correct call out?

    Alfonso Cartagena

      All,

       

      Below is the the initial code I used for reference and it specifically call out a M48 Counter Bore Hole.

       

      swWzdHole.InitializeHole swWzdCounterBore, swStandardISO, swStandardISOHexBolt, "M48", swEndCondBlind

       

       

       

      This is not the correct hole that I will need. I modified the code to reflect a 10-32 tapped hole below.

       

      swWzdHole.InitializeHole swWzdTap, swStandardPCS, swStandardPCSTappedHole, "#10-32", swEndThreadTypeBLIND

       

       

      This code crashes SolidWorks. Is there anything you see here that is causing this issue?

       

      Thank you!

        • Re: What is the correct call out?
          Leon Wurr

          What SW version are you using?

           

          This code works fine for me (SW 2015 SP2.1):

           

          Option Explicit
          
          
          Dim swApp As SldWorks.SldWorks
          Dim swModel As SldWorks.ModelDoc2
          Dim swModelDocExt As SldWorks.ModelDocExtension
          Dim swFeatMgr As SldWorks.FeatureManager
          Dim swFeat As SldWorks.Feature
          Dim swWzdHole As WizardHoleFeatureData2
          Dim swFeatDataObj As Object
          Dim boolstatus As Boolean
           
          Sub main()
          
          
          Set swApp = Application.SldWorks
          Set swModel = swApp.ActiveDoc
          Set swModelDocExt = swModel.Extension
          Set swFeatMgr = swModel.FeatureManager
          
          
          ' Create the hole wizard feature data object
          Set swFeatDataObj = swFeatMgr.CreateDefinition(swFmHoleWzd)
          Set swWzdHole = swFeatDataObj
          
          
          ' Initialize the hole wizard feature
          swWzdHole.InitializeHole swWzdTap, swStandardPCS, swStandardPCSTappedHole, "#10-32", swEndThreadTypeBLIND
          
          
          
          
          'Change the hole wizard feature's depth
          swWzdHole.HoleDepth = 0.15
          
          
          'Change the hole wizard feature's diameter
          swWzdHole.HoleDiameter = 0.0555
          
          
          ' Select the face on which to create the hole
          boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.09000000000003, -0.01278177510699, 0.04695929736232, False, 0, Nothing, 0)
          ' Create the hole wizard feature
          Set swFeat = swFeatMgr.CreateFeature(swWzdHole)
          
          
           
          
          
          End Sub
          
          
            • Re: What is the correct call out?
              Alfonso Cartagena

              Leon Wurr,

               

              I am using SolidWorks 2015 SP4.0.

               

              What I don't understand is why the macro will work just fine until I change that specific line. Any idea why that would happen? Especially if it works for you.

               

              Thank you,

              Alfonso

                • Re: What is the correct call out?
                  Leon Wurr

                       But did you tested the code I've posted?

                       Does it still crashes your SW?

                   

                       If it doesn't, then post the entire code you've wrote, so we can compare both codes and analyze what may be going wrong.

                    • Re: What is the correct call out?
                      Alfonso Cartagena

                      Leon Wurr,

                       

                      Is there somewhere i can send you a Zip file?

                      • Re: What is the correct call out?
                        Alfonso Cartagena

                        Leon Wurr,

                         

                        I'm getting closer but it still makes no sense. The system is crashing when I specify my hole parameters. Below I have underlined a specific section. When I take this portion out the macro runs without crashing SolidWorks.

                         

                         

                        'Tap 10-32 Holes

                         

                        Dim swModel As SldWorks.ModelDoc2

                        Dim swModelDocExt As SldWorks.ModelDocExtension

                        Dim swFeatMgr As SldWorks.FeatureManager

                        Dim swFeat As SldWorks.Feature

                        Dim swWzdHole As WizardHoleFeatureData2

                        Dim swFeatDataObj As Object

                        Set swApp = Application.SldWorks

                        Set swModel = swApp.ActiveDoc

                        Set swModelDocExt = swModel.Extension

                        Set swFeatMgr = swModel.FeatureManager

                         

                         

                        ' Create the hole wizard feature data object

                         

                        Set swFeatDataObj = swFeatMgr.CreateDefinition(swFmHoleWzd)

                        Set swWzdHole = swFeatDataObj

                         

                        ' Initialize the hole wizard feature

                         

                        swWzdHole.InitializeHole swWzdTap, swStandardPCS, swStandardPCSTappedHole, "#10-32", swEndThreadTypeBLIND

                         

                        'Change the hole wizard feature's tap drill diameter

                         

                        swWzdHole.TapDrillDiameter = 0.159

                         

                        'Change the hole wizard feature's tap drill depth

                         

                        swWzdHole.TapDrillDepth = 0.536

                         

                        'Change the hole wizard feature's thread diameter

                         

                        swWzdHole.ThreadDiameter = 0.19

                         

                        'Change the hole wizard feature's thread depth

                         

                        swWzdHole.ThreadDepth = 0.38

                         

                        'Change the hole wizard feature's drill angle

                         

                        swWzdHole.DrillAngle = 118

                         

                        ' Select the face on which to create the hole

                         

                        boolstatus = swModelDocExt.SelectByID2("Point3@Sketch8@PCS PA-200-Side Locks-1@Moldbase/PCS PA-200-Side Locks_side lock male-3@PCS PA-200-Side Locks", "EXTSKETCHPOINT", sketchPointArray(i).X, sketchPointArray(i).Y, 0, False, 0, Nothing, 0)

                         

                        ' Create the hole wizard feature

                         

                        Set swFeat = swFeatMgr.CreateFeature(swWzdHole)

                         

                         

                         

                         

                         

                         

                        After this code is successfully ran, There are still issues because the parameters are not there anymore. I have attached 2 screen caputures of the results.

                         

                         

                        Capture1.PNGCapture2.PNG

                         

                         

                         

                        Thank you,

                        Alfonso

                          • Re: What is the correct call out?
                            Leon Wurr

                                 That's odd, my SW is crashing too, but try this different approach for setting the parameters:

                             

                            Option Explicit
                              
                              
                            Dim swApp As SldWorks.SldWorks
                            Dim swModel As SldWorks.ModelDoc2
                            Dim swModelDocExt As SldWorks.ModelDocExtension
                            Dim swFeatMgr As SldWorks.FeatureManager
                            Dim swFeat As SldWorks.Feature
                            Dim swWzdHole As WizardHoleFeatureData2
                            Dim swFeatDataObj As Object
                            Dim boolstatus As Boolean
                               
                            Sub main()
                                Set swApp = Application.SldWorks
                                Set swModel = swApp.ActiveDoc
                                Set swModelDocExt = swModel.Extension
                                Set swFeatMgr = swModel.FeatureManager
                                  
                                ' Create the hole wizard feature data object
                                Set swFeatDataObj = swFeatMgr.CreateDefinition(swFmHoleWzd)
                                Set swWzdHole = swFeatDataObj
                                boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.09000000000003, -0.01278177510699, 0.04695929736232, False, 0, Nothing, 0)
                                
                                ' Create the hole wizard feature
                                Set swFeat = swFeatMgr.HoleWizard _
                                                    ( _
                                                    swWzdTap, _
                                                    swStandardPCS, _
                                                    swStandardPCSTappedHole, _
                                                    "#10-32", _
                                                    swEndThreadTypeBLIND, _
                                                    0.159 * 25.4 / 1000, _
                                                    0.536 * 25.4 / 1000, _
                                                    0.38 * 25.4 / 1000, _
                                                    118, _
                                                    118#, _
                                                    1#, _
                                                    2.059488517353, _
                                                    0#, _
                                                    0#, _
                                                    0#, _
                                                    0#, _
                                                    0#, _
                                                    0#, _
                                                    0# _
                                                    )
                            
                            
                            End Sub
                            

                             

                                 Remember that on the code all dimensions are in meters, so you will have to use a *(25.4/1000) conversion factor.

                                 For help on setting the parameters refer to 2014 SOLIDWORKS API Help - HoleWizard2 Method (IFeatureManager)