Witam, Chcę automatycznie utworzyć arkusz technologiczny z solidwokrs. Zacząłem więc od wyszukania informacji o grubości, głębokości, długości, kącie cięcia...
Właśnie natknąłem się na cienkie wyciągnięcie, które jest definiowane przez odniesienie do powierzchni w zespole. W sztuce nie ma więc zapisanego numeru telefonu. Czy istnieje sposób na odzyskanie tej głębokości?
Miałem też inny przypadek, w którym zaokrąglenie rury jest tworzone bezpośrednio ze szkicu związanego z wytłaczaniem. Tak więc, gdy wyświetlam wymiary, nie jestem w stanie rozróżnić wymiaru zaokrąglenia od wymiaru grubości.
Oto mój kod
Sub GetExtrusionDimensions()
//Initialize SolidWorks application and get the active document
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim Feature As Feature
Dim ExtrudeFeat As ExtrudeFeatureData
Dim DisplayDim As DisplayDimension
Dim DimVal As Dimension
Dim MsgStr As String
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
// Check if the active document is a part file
If Part Is Nothing Or Part.GetType <> swDocPART Then
MsgBox "Veuillez ouvrir une pièce avant d'exécuter ce script.", vbCritical
Exit Sub
End If
//Start with the first feature in the part
Set Feature = Part.FirstFeature
MsgStr = "Dimensions des extrusions :" & vbNewLine & vbNewLine
//Loop through each feature in the feature tree
Do While Not Feature Is Nothing
//Check if the feature is an extrusion
If Feature.GetTypeName2 = "Extrusion" Then
//Access extrusion-specific data
Set ExtrudeFeat = Feature.GetDefinition
If Not ExtrudeFeat Is Nothing Then
MsgStr = MsgStr & "Fonction : " & Feature.Name & vbNewLine
//Access display dimensions
Set DisplayDim = Feature.GetFirstDisplayDimension
Do While Not DisplayDim Is Nothing
//Get the linked dimension object
Set DimVal = DisplayDim.GetDimension
Depth = ExtrudeFeat.GetDepth(True)
Debug.Print Depth
If Not DimVal Is Nothing Then
MsgStr = MsgStr & " Dimension : " & DimVal.FullName & " = " & DimVal.Value & " mm" & vbNewLine
End If
//Move to the next display dimension
Set DisplayDim = Feature.GetNextDisplayDimension(DisplayDim)
Loop
MsgStr = MsgStr & vbNewLine
End If
End If
//Move to the next feature in the tree
Set Feature = Feature.GetNextFeature
Loop
//Display the extracted information
MsgBox MsgStr, vbInformation, "Résultats"
End Sub