need a program to extract the dimensions of all the parts in an assembly through solid works api SolidworksApi macros
Answers3
SF
SF2010-03-27Best Answer
Dim swApp As SldWorks.SldWorks Dim swAssy As SldWorks.AssemblyDoc Dim vComps As Variant Dim swComp As SldWorks.Component2 Dim swFeat As SldWorks.Feature Dim swDispDim As SldWorks.DisplayDimension Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
Set swAssy = swApp.ActiveDoc
vComps = swAssy.GetComponents(False)
For i = 0 To UBound(vComps)
Set swComp = vComps(i)
Set swFeat = swComp.FirstFeature
While Not swFeat Is Nothing
Set swDispDim = swFeat.GetFirstDisplayDimension
While Not swDispDim Is Nothing
Debug.Print swDispDim.GetNameForSelection Set swDispDim = swFeat.GetNextDisplayDimension(swDispDim)
Dim swApp As SldWorks.SldWorks
Dim swAssy As SldWorks.AssemblyDoc
Dim vComps As Variant
Dim swComp As SldWorks.Component2
Dim swFeat As SldWorks.Feature
Dim swDispDim As SldWorks.DisplayDimension
Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
Set swAssy = swApp.ActiveDoc
vComps = swAssy.GetComponents(False)
For i = 0 To UBound(vComps)
Set swComp = vComps(i)
Set swFeat = swComp.FirstFeature
While Not swFeat Is Nothing
Set swDispDim = swFeat.GetFirstDisplayDimension
While Not swDispDim Is Nothing
Debug.Print swDispDim.GetNameForSelection
Set swDispDim = swFeat.GetNextDisplayDimension(swDispDim)
Wend
Set swFeat = swFeat.GetNextFeature
Wend
Next
End Sub
________________________________________________________________
Hi, i tried this code for an assembly it works great, is it possible to modify the code to run against a part.
I tried to modify the code, but can't find something similar to GetComponents for a part document.
Thanks
Howdy,
The attached might help you find what you are looking for.
This works in SW2010 (maybe 2009).