Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

translate SolidWorks Assembly from foreign language to English

Status
Not open for further replies.

Christopher Torres

Mechanical
Apr 17, 2020
1
I currently working on a huge assembly that has multiple subassemblies and I was wondering if somebody could help modify this code (below) to translate all the features, planes, material, etc... to English.
I found this code in another previous tread and for some reason, I did not let me reply to it.
Thank you in advance.

Hi Deepak,

I've missed the material issue.

Please take a look at this modified macro which considers the material name as well as standard reference geometry names. I've created four constants for their names.

Please do not hesitate to as a question if you have ones.

- - - - - - - - - - - - - -
Dim swApp As SldWorks.SldWorks
Dim swPart As SldWorks.PartDoc
Dim swFeat As SldWorks.Feature
Dim newName As String

Dim dicFeatsCount As Object

Dim collFeatsNonIncr As Collection
Dim dicBaseNames As Object

Const FrontPlane = "Front Plane"
Const TopPlane = "Top Plane"
Const RigthPlane = "Rigth Plane"
Const Origin = "Origin"

Dim isRefGeom As Boolean

Sub main()

Set dicFeatsCount = CreateObject("Scripting.Dictionary")

Set collFeatsNonIncr = New Collection

Set dicBaseNames = CreateObject("Scripting.Dictionary")

isRefGeom = False

'Add the list of features which shouldn't be incremented
'- - - - - - - - - - - - - - - - - - - -
collFeatsNonIncr.Add "SensorFolder"
collFeatsNonIncr.Add "DocsFolder"
collFeatsNonIncr.Add "DetailCabinet"
collFeatsNonIncr.Add "MaterialFolder"
collFeatsNonIncr.Add "OriginProfileFeature"
'- - - - - - - - - - - - - - - - - - - -

'Add the list of predefined base names
'- - - - - - - - - - - - - - - - - - - -
dicBaseNames.Add "MaterialFolder", "Material <not specified>"
dicBaseNames.Add "OriginProfileFeature", "Origin"
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

Dim i As Integer

Dim isIncremented As Boolean
isIncremented = True
For i = 1 To collFeatsNonIncr.Count
If collFeatsNonIncr(i) = swFeat.GetTypeName2() Then
isIncremented = False
Exit For
End If
Next

If isIncremented Then
newName = newName & dicFeatsCount.Item(swFeat.GetTypeName2())
End If

If swFeat.GetTypeName2 = "MaterialFolder" Then

isRefGeom = True

Dim sMatName As String

sMatName = swPart.GetMaterialPropertyName2("", "")

If sMatName <> "" Then
newName = sMatName
End If

End If

swFeat.Name = newName

Set swFeat = swFeat.GetNextFeature

If isRefGeom Then

swFeat.Name = FrontPlane

Set swFeat = swFeat.GetNextFeature
swFeat.Name = TopPlane

Set swFeat = swFeat.GetNextFeature
swFeat.Name = RigthPlane

Set swFeat = swFeat.GetNextFeature
swFeat.Name = Origin

Set swFeat = swFeat.GetNextFeature
isRefGeom = False
End If

Wend

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor