Hi all
I am working on the automation of a CAD/CAM process and I would like to be able to extract from a part or a Solidworks assembly the dimensions and their dimensions (for each function of the part(s) to an external file.
Thanks to Mr. Boutherand on an old article of ''myCadblog'', I found a macro that allows you to extract this data via an excel file. Only this macro seems to be obsolete (see code below).
Could you help me update it? (FYI: I'm on Solidworks 2014)
Thank you very much in advance for your feedback!
Roman
- Sub AddAllDimensions()
- Dim swDisplayDimension As SldWorks.DisplayDimension
- Dim swDimension As SldWorks.Dimension
- Dim swFeature As SldWorks.Feature
- On Error GoTo SiErr
- 'Retrieves the SolidWorks application
- Set swApp = CreateObject("SldWorks.Application")
- 'We get the active document
- Set swDoc = swApp.ActiveDoc
- 'Retrieves the first function
- Set swFeature = swDoc.FirstFeature
- If swFeature Is Nothing Then
- MsgBox "the document is empty", vbExclamation
- Exit Sub
- End If
- Do
- 'On each function we retrieve the dimensions
- Set swDisplayDimension = swFeature.GetFirstDisplayDimension
- If Not swDisplayDimension Is Nothing Then
- Do
- Set swDimension = swDisplayDimension.GetDimension
- Add to the list
- Call AddDimToSheet(swDisplayDimension)
- Set swDisplayDimension = swFeature.GetNextDisplayDimension(swDisplayDimension)
- Loop Until swDisplayDimension Is Nothing
- End If
- Set swFeature = swFeature.GetNextFeature
- Loop Until swFeature Is Nothing
- Exit Sub
- SiErr:
- Set swDisplayDimension = Nothing
- Summary Next
- End Sub