8 Replies Latest reply on Sep 24, 2018 6:15 AM by Jim Moses

    Language Converter For Assemblies

    Jim Moses

      Hi all,

       

      Ref:Using SW2016 SP 5.0

       

      Downloaded a customer file and everything in a language other than English, I found a 2 converters on the forum that will do the part files, yet get a run time error as it appears both are designed to only do part files.

       

      So has anyone made one for an assembly file, if not any suggestions on modifying the following to do just that?

       

       

      Regards,

        • Re: Language Converter For Assemblies
          Glenn Schroeder

          Jim,

           

          I'm not trying to be the forum police, but the people that can help with this would be more likely to see it if you'll move it to the API section. 

           

          • Re: Language Converter For Assemblies
            Deepak Gupta

            You can use codes form this example Traverse Assembly at Component Level Example (VBA) and set if condition to check if the component is part. If yes then run the converter.

             

            OR if you can share the converter macro codes (as SWP attachment, text file or copy paste the codes but not picture), then I might be able to write something for you.

              • Re: Language Converter For Assemblies
                Jim Moses

                Deepak,

                 

                Here is the code, I would not mind if I have to do the parts separately and the assembly separate, just a pain to figure constraints if you can't read them and trying to remember icons isn't exactly the best thing.

                 

                let me know what you come up with as I am sure I am not the only one who would like this, I saw in another post about making a language setting as a wish feature for solidworks which would be nice as well, especially with things being sent overseas and designed in other countries.

                 

                Dim swApp As SldWorks.SldWorks

                Dim swPart As SldWorks.PartDoc

                Dim swFeat As SldWorks.Feature

                Dim newName As String

                 

                 

                Dim dicFeatsCount As Object

                 

                 

                Dim dicBaseNames As Object

                 

                 

                Sub main()

                 

                 

                    Set dicFeatsCount = CreateObject("Scripting.Dictionary")

                   

                    Set dicBaseNames = CreateObject("Scripting.Dictionary")

                   

                    'Add the list of predefined base names

                   

                    '- - - - - - - - - - - - - - - - - - - -

                    dicBaseNames.Add "ProfileFeature", "Sketch"

                    dicBaseNames.Add "Extrusion", "Extrude"

                    dicBaseNames.Add "RefPlane", "Plane"

                  '- - - - - - - - - - - - - - - - - - - -

                 

                  Set swApp = Application.SldWorks

                 

                  Set swPart = swApp.ActiveDoc

                 

                  Set swFeat = swPart.FirstFeature

                 

                  While Not swFeat Is Nothing

                 

                    If dicFeatsCount.exists(swFeat.GetTypeName2()) Then

                        dicFeatsCount.Item(swFeat.GetTypeName2()) = dicFeatsCount.Item(swFeat.GetTypeName2()) + 1

                    Else: dicFeatsCount.Add swFeat.GetTypeName2(), 1

                    End If

                   

                    If dicBaseNames.exists(swFeat.GetTypeName2()) Then

                        newName = dicBaseNames.Item(swFeat.GetTypeName2())

                    Else: newName = swFeat.GetTypeName2()

                    End If

                   

                    newName = newName & dicFeatsCount.Item(swFeat.GetTypeName2())

                   

                    swFeat.Name = newName

                   

                    Set swFeat = swFeat.GetNextFeature

                 

                 

                Wend

                 

                 

                 

                 

                Set swApp = Application.SldWorks

                End Sub

                 

                 

                Regards,