4 Replies Latest reply on Oct 23, 2018 4:36 PM by Grega Jerin

    Finding same instances of dimensions on drawings or fetaures in parts / assemblies

    Grega Jerin

      I had a case with my last project and I solved it manaually, but I was wondering if it is possible to automate this task.


      I had a big project with 1000 drawings and after manufacturing we usually check what was altered during manufacturing and we make the changes. The case here was that some of M10 threads have to be replaced with fine pitch thread M10 x 1,0. As I said, one can check whole project and then replace the needed threads. There is also a possibility for missing some. So, I was wondering if it is possible to check all drawings for all instances of M10 dimension? The other way is to check all parts and assemblies for feature of M10 hole made with Hole wizard.


      Is this possible and has anyone tried something similar?

        • Re: Finding same instances of dimensions on drawings or fetaures in parts / assemblies
          Rob Edwards

          Hi Grega

          Weirdly I'm working on a macro today that looks through all the dimensions..  I've just started so haven't got much further than creating a collection of features that have dimensions and then collecting all dimensions.  I've literally just added a loop to print out the names where the value is 0.01


          Dim swFeature As SldWorks.Feature
          Dim swDisplayDimension As SldWorks.DisplayDimension
          Dim swDimension As SldWorks.Dimension
          Dim colDispDims As Collection
          Dim colFeaturesWithDims As Collection
          Sub main()
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set colFeaturesWithDims = New Collection
              Set swFeature = swModel.FirstFeature
              Do While Not swFeature Is Nothing
              On Error Resume Next
                  If HasDisplayDimensions(swFeature) Then colFeaturesWithDims.Add Item:=swFeature, key:=swFeature.Name
                  Set swFeature = swFeature.GetNextFeature
              Dim i As Integer
              Set colDispDims = New Collection
              For i = 1 To colFeaturesWithDims.Count
                  Set swFeature = colFeaturesWithDims(i)
                  Set swDisplayDimension = swFeature.GetFirstDisplayDimension
                  Do While Not swDisplayDimension Is Nothing
                      Call colDispDims.Add(Item:=swDisplayDimension, key:=swDisplayDimension.GetDimension.FullName)
                      Set swDisplayDimension = swFeature.GetNextDisplayDimension(swDisplayDimension)
            'Check if value is 10
            For i = 1 To colDispDims.Count
              Set swDimension = colDispDims(i).GetDimension
                  If swDimension.SystemValue = 0.01 Then
                    Debug.Print swDimension.FullName
                  End If
          End Sub
          Private Function HasDisplayDimensions(swFeature As SldWorks.Feature) As Boolean
              HasDisplayDimensions = Not swFeature.GetFirstDisplayDimension Is Nothing
          End Function


          This is very basic, just prints the dimension names to the immediate window...


          what would you like it to do? automatically update the values.  I've never really used HoleWizard in the API


          however if you're just checking for a specific dimension value, you can already use the filter in the equations dialog

          I know you're probably looking for something to go through your entire assembly,,, but this is all I have so far.  It's quite fun writing these macros, but I've a long way to go