Open the toolkit ↗
← All tools
SolidWorks · Inventor

Macro library

Copy-ready VBA macros: STEP export, batch save, show properties.

CALCULATED LIVE · FORMULA & ASSUMPTIONS IN VIEW

Sample code

Macro library

VBA macros for SolidWorks (SldWorks API): STEP export, save all and showing custom properties. The code below is exactly the content of the downloadable .bas file — not a separate, potentially diverging copy. Always test macros on a copy of your files first — API method signatures can vary slightly between SolidWorks versions. Inventor uses a different object model (iLogic / Inventor API via VB.NET) — see the supplementary macros for Inventor examples.

STEP export

Saves the active document as STEP (.step), next to the source file. Checks first that the document already has a file path.

Download .bas
Attribute VB_Name = "ExportActiefNaarSTEP"
'
' SolidWorks 2024 VBA-macro — Exporteer actief document naar STEP
' https://www.mechify.nl/cad/macros
'
' Wat: slaat het actieve part of assembly op als .step, naast het
' bestaande bestand, met dezelfde naam.
' Vereist: het document is al minstens één keer opgeslagen (heeft een pad).
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    If swModel.GetType <> swDocPART And swModel.GetType <> swDocASSEMBLY Then
        MsgBox "Deze macro is alleen bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If

    Dim docPath As String
    docPath = swModel.GetPathName

    If docPath = "" Then
        MsgBox "Sla het document eerst één keer op (nog geen bestandspad).", vbExclamation
        Exit Sub
    End If

    If InStrRev(docPath, ".") = 0 Then
        MsgBox "Bestandspad heeft geen extensie.", vbExclamation
        Exit Sub
    End If

    Dim stepPath As String
    stepPath = Left(docPath, InStrRev(docPath, ".")) & "step"

    Dim saveErrors As Long
    Dim saveWarnings As Long

    Dim ok As Boolean
    ' swSaveAsOptions_Copy: exporteer een kopie zonder het open document aan
    ' het nieuwe bestand te koppelen. Zonder deze vlag kan SolidWorks het
    ' geopende document laten verwijzen naar het geëxporteerde bestand.
    ok = swModel.Extension.SaveAs(stepPath, swSaveAsCurrentVersion, swSaveAsOptions_Silent Or swSaveAsOptions_Copy, Nothing, saveErrors, saveWarnings)

    If ok And saveErrors = 0 Then
        MsgBox "Opgeslagen als:" & vbCrLf & stepPath, vbInformation
    Else
        MsgBox "Exporteren mislukt (foutcode " & saveErrors & ").", vbCritical
    End If

End Sub

Save all

Loops through every open document and saves each one with unsaved changes. Reports how many were saved and how many were skipped (no changes, or no file path yet).

Download .bas
Attribute VB_Name = "SlaAllesOp"
'
' SolidWorks 2024 VBA-macro — Sla alle gewijzigde open documenten op
' https://www.mechify.nl/cad/macros
'
' Wat: loopt door alle op dit moment geopende documenten en slaat elk
' document met niet-opgeslagen wijzigingen op. Documenten zonder
' wijzigingen, of die nog geen bestandspad hebben, worden overgeslagen.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks

Sub main()

    Set swApp = Application.SldWorks

    Dim swDoc As SldWorks.ModelDoc2
    Set swDoc = swApp.GetFirstDocument

    Dim saved As Integer
    Dim skipped As Integer
    saved = 0
    skipped = 0

    Do While Not swDoc Is Nothing

        If swDoc.GetSaveFlag Then

            If swDoc.GetPathName = "" Then
                skipped = skipped + 1
            Else
                Dim saveErrors As Long
                Dim saveWarnings As Long
                Dim ok As Boolean
                ok = swDoc.Save3(swSaveAsOptions_Silent, saveErrors, saveWarnings)

                If ok And saveErrors = 0 Then
                    saved = saved + 1
                Else
                    skipped = skipped + 1
                End If
            End If

        Else
            skipped = skipped + 1
        End If

        Set swDoc = swDoc.GetNext

    Loop

    MsgBox saved & " document(en) opgeslagen." & vbCrLf & _
           skipped & " overgeslagen (geen wijzigingen, of nog niet opgeslagen).", vbInformation

End Sub

Show properties

Shows all custom properties of the active document in a message box. Read-only, changes nothing.

Download .bas
Attribute VB_Name = "ToonCustomProperties"
'
' SolidWorks 2024 VBA-macro — Toon custom properties van het actieve document
' https://www.mechify.nl/cad/macros
'
' Wat: leest alle custom properties (configuratie-onafhankelijk, "") van
' het actieve document en toont ze in een berichtvenster. Alleen-lezen,
' wijzigt niets.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    Dim swCustProp As SldWorks.CustomPropertyManager
    Set swCustProp = swModel.Extension.CustomPropertyManager("")

    Dim propNames As Variant
    propNames = swCustProp.GetNames

    If IsEmpty(propNames) Then
        MsgBox "Geen custom properties gevonden.", vbInformation
        Exit Sub
    End If

    Dim msg As String
    Dim i As Long

    For i = 0 To UBound(propNames)
        Dim valOut As String
        Dim resolvedVal As String
        Dim wasResolved As Boolean
        swCustProp.Get5 propNames(i), False, valOut, resolvedVal, wasResolved
        msg = msg & propNames(i) & " = " & resolvedVal & vbCrLf
    Next i

    MsgBox msg, vbInformation, "Custom properties — " & swModel.GetTitle

End Sub

Downloadable macros

VBA modules and additional report macros for SolidWorks and Inventor. Inspect the code and test on a copy; Mechify never runs these files.

14 downloadable VBA macros

Import .bas files through File > Import File in the VBA editor. When pasting manually, omit the first Attribute VB_Name line; it belongs to the import format.

What ‘reviewed’ means here

Manual source review plus automated static checks for file coverage, separation of SolidWorks/Inventor identifiers and metadata. No compile or runtime test in CAD.

A target version identifies the API documentation used; it is not proof that the macro runs in that CAD version. Test every macro on a copy in your own CAD installation first.

SolidWorks 2024

Install: Tools > Macro > New, paste the code into the module — or import the .bas file directly via the VBA editor (File > Import File).

Export to STEP

Saves the active part or assembly as .step, next to the existing file.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Saved parts/assemblies only; an existing STEP may be overwritten without confirmation. Export options and references were not tested in SolidWorks.

SOLIDWORKS API 2024 — SaveAs ↗

Download .bas

SHA-256: ba6572cf3d012446399bd361c6f2268f73cf1931edd2642fdb1bbec2b685fce8

View VBA code for Export to STEP
Attribute VB_Name = "ExportActiefNaarSTEP"
'
' SolidWorks 2024 VBA-macro — Exporteer actief document naar STEP
' https://www.mechify.nl/cad/macros
'
' Wat: slaat het actieve part of assembly op als .step, naast het
' bestaande bestand, met dezelfde naam.
' Vereist: het document is al minstens één keer opgeslagen (heeft een pad).
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    If swModel.GetType <> swDocPART And swModel.GetType <> swDocASSEMBLY Then
        MsgBox "Deze macro is alleen bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If

    Dim docPath As String
    docPath = swModel.GetPathName

    If docPath = "" Then
        MsgBox "Sla het document eerst één keer op (nog geen bestandspad).", vbExclamation
        Exit Sub
    End If

    If InStrRev(docPath, ".") = 0 Then
        MsgBox "Bestandspad heeft geen extensie.", vbExclamation
        Exit Sub
    End If

    Dim stepPath As String
    stepPath = Left(docPath, InStrRev(docPath, ".")) & "step"

    Dim saveErrors As Long
    Dim saveWarnings As Long

    Dim ok As Boolean
    ' swSaveAsOptions_Copy: exporteer een kopie zonder het open document aan
    ' het nieuwe bestand te koppelen. Zonder deze vlag kan SolidWorks het
    ' geopende document laten verwijzen naar het geëxporteerde bestand.
    ok = swModel.Extension.SaveAs(stepPath, swSaveAsCurrentVersion, swSaveAsOptions_Silent Or swSaveAsOptions_Copy, Nothing, saveErrors, saveWarnings)

    If ok And saveErrors = 0 Then
        MsgBox "Opgeslagen als:" & vbCrLf & stepPath, vbInformation
    Else
        MsgBox "Exporteren mislukt (foutcode " & saveErrors & ").", vbCritical
    End If

End Sub

Batch-export drawings to PDF

Exports every open, already-saved drawing to PDF.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Open, saved drawings only; PDF settings, fonts and references were not tested in SolidWorks.

SOLIDWORKS API 2024 — SaveAs ↗

Download .bas

SHA-256: 57e6df2ec24663650da4834816daa9c164bc1aeeb062623c2944ef055ddf7dc3

View VBA code for Batch-export drawings to PDF
Attribute VB_Name = "BatchExportTekeningenNaarPDF"
'
' SolidWorks 2024 VBA-macro — Batch-export open tekeningen naar PDF
' https://www.mechify.nl/cad/macros
'
' Wat: loopt door alle op dit moment geopende documenten, en exporteert
' elke tekening (.SLDDRW) die al een bestandspad heeft naar PDF, naast
' het bestaande bestand, met dezelfde naam.
' Parts en assemblies worden overgeslagen.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks

Sub main()

    Set swApp = Application.SldWorks

    Dim swDoc As SldWorks.ModelDoc2
    Set swDoc = swApp.GetFirstDocument

    Dim exported As Integer
    Dim skipped As Integer
    exported = 0
    skipped = 0

    Do While Not swDoc Is Nothing

        If swDoc.GetType = swDocDRAWING Then

            Dim docPath As String
            docPath = swDoc.GetPathName

            If docPath = "" Or InStrRev(docPath, ".") = 0 Then
                skipped = skipped + 1
            Else
                Dim pdfPath As String
                pdfPath = Left(docPath, InStrRev(docPath, ".")) & "pdf"

                Dim saveErrors As Long
                Dim saveWarnings As Long
                Dim ok As Boolean

                ' Eén beschadigd of vergrendeld document mag de rest van de
                ' batch niet afbreken — vang fouten per document af, net als
                ' de Inventor-twin.
                On Error Resume Next
                ok = swDoc.Extension.SaveAs(pdfPath, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, saveErrors, saveWarnings)
                If Err.Number <> 0 Then
                    ok = False
                    Err.Clear
                End If
                On Error GoTo 0

                If ok And saveErrors = 0 Then
                    exported = exported + 1
                Else
                    skipped = skipped + 1
                End If
            End If

        End If

        Set swDoc = swDoc.GetNext

    Loop

    MsgBox exported & " tekening(en) geëxporteerd naar PDF." & vbCrLf & _
           skipped & " overgeslagen (geen tekening, of nog niet opgeslagen).", vbInformation

End Sub

Show custom properties

Reads the configuration-independent custom properties of the active document. Read-only.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Reads document-level properties only, not configuration-specific values; not tested in SolidWorks.

SOLIDWORKS API 2024 — CustomPropertyManager ↗

Download .bas

SHA-256: c4b33c0e8a133ac0fb63b8aca88b6428deb4c73b3dc725bed5344bbb32888416

View VBA code for Show custom properties
Attribute VB_Name = "ToonCustomProperties"
'
' SolidWorks 2024 VBA-macro — Toon custom properties van het actieve document
' https://www.mechify.nl/cad/macros
'
' Wat: leest alle custom properties (configuratie-onafhankelijk, "") van
' het actieve document en toont ze in een berichtvenster. Alleen-lezen,
' wijzigt niets.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    Dim swCustProp As SldWorks.CustomPropertyManager
    Set swCustProp = swModel.Extension.CustomPropertyManager("")

    Dim propNames As Variant
    propNames = swCustProp.GetNames

    If IsEmpty(propNames) Then
        MsgBox "Geen custom properties gevonden.", vbInformation
        Exit Sub
    End If

    Dim msg As String
    Dim i As Long

    For i = 0 To UBound(propNames)
        Dim valOut As String
        Dim resolvedVal As String
        Dim wasResolved As Boolean
        swCustProp.Get5 propNames(i), False, valOut, resolvedVal, wasResolved
        msg = msg & propNames(i) & " = " & resolvedVal & vbCrLf
    Next i

    MsgBox msg, vbInformation, "Custom properties — " & swModel.GetTitle

End Sub

Save all

Saves every open document that has unsaved changes.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Saves modified, previously saved open documents; error handling and reference updates were not tested in SolidWorks.

SOLIDWORKS API 2024 — GetSaveFlag ↗

Download .bas

SHA-256: 29e3603980f3c8fa9b9550de249f74476445159dcd9e60c5d1ff430a1f96cd33

View VBA code for Save all
Attribute VB_Name = "SlaAllesOp"
'
' SolidWorks 2024 VBA-macro — Sla alle gewijzigde open documenten op
' https://www.mechify.nl/cad/macros
'
' Wat: loopt door alle op dit moment geopende documenten en slaat elk
' document met niet-opgeslagen wijzigingen op. Documenten zonder
' wijzigingen, of die nog geen bestandspad hebben, worden overgeslagen.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks

Sub main()

    Set swApp = Application.SldWorks

    Dim swDoc As SldWorks.ModelDoc2
    Set swDoc = swApp.GetFirstDocument

    Dim saved As Integer
    Dim skipped As Integer
    saved = 0
    skipped = 0

    Do While Not swDoc Is Nothing

        If swDoc.GetSaveFlag Then

            If swDoc.GetPathName = "" Then
                skipped = skipped + 1
            Else
                Dim saveErrors As Long
                Dim saveWarnings As Long
                Dim ok As Boolean
                ok = swDoc.Save3(swSaveAsOptions_Silent, saveErrors, saveWarnings)

                If ok And saveErrors = 0 Then
                    saved = saved + 1
                Else
                    skipped = skipped + 1
                End If
            End If

        Else
            skipped = skipped + 1
        End If

        Set swDoc = swDoc.GetNext

    Loop

    MsgBox saved & " document(en) opgeslagen." & vbCrLf & _
           skipped & " overgeslagen (geen wijzigingen, of nog niet opgeslagen).", vbInformation

End Sub

Export flat pattern to DXF

Saves a sheet metal part's flat pattern as .dxf.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Requires a saved sheet-metal part with a Flat-Pattern feature. Generic SaveAs does not guarantee a reliable flat-pattern result; inspect every DXF. Not tested in SolidWorks.

SOLIDWORKS API 2024 — SaveAs ↗

Download .bas

SHA-256: 7a229f39f5caa630ac2a914bf57a6461944ac9419e8db113c48a2b91e105c130

View VBA code for Export flat pattern to DXF
Attribute VB_Name = "ExporteerVlakPatroonNaarDXF"
'
' SolidWorks 2024 VBA-macro — Exporteer vlak patroon naar DXF
' https://www.mechify.nl/cad/macros
'
' Wat: zoekt de Flat-Pattern-feature van het actieve plaatwerk-part,
' schakelt die tijdelijk in (unsuppress) als dat nodig is, slaat het
' vlakke patroon op als .dxf naast het bestaande bestand, en zet de
' feature daarna terug naar de oorspronkelijke staat.
' Vereist: het actieve document is een plaatwerk-part met een
' Flat-Pattern-feature, en is al minstens één keer opgeslagen.
' Zie ook de rekenhulp Richtlijnen kanten op deze site voor Ri,
' beenlengte en Z-buiging bij het plaatwerkontwerp zelf.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Tools > Macro > New, plak deze code in de module (of
' importeer dit .bas-bestand direct via VBA-editor > File > Import File).
'
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    If swModel.GetType <> swDocPART Then
        MsgBox "Geen part-document. Open een plaatwerk-part.", vbExclamation
        Exit Sub
    End If

    Dim docPath As String
    docPath = swModel.GetPathName

    If docPath = "" Then
        MsgBox "Sla het document eerst één keer op (nog geen bestandspad).", vbExclamation
        Exit Sub
    End If

    ' Zoek de Flat-Pattern-feature op type, niet op naam (naam kan
    ' afwijken door taal of hernoemen).
    Dim swFeat As SldWorks.Feature
    Set swFeat = swModel.FirstFeature

    Dim swFlatFeat As SldWorks.Feature
    Do While Not swFeat Is Nothing
        If swFeat.GetTypeName2 = "FlatPattern" Then
            Set swFlatFeat = swFeat
            Exit Do
        End If
        Set swFeat = swFeat.GetNextFeature
    Loop

    If swFlatFeat Is Nothing Then
        MsgBox "Geen Flat-Pattern-feature gevonden. Is dit een plaatwerk-part?", vbExclamation
        Exit Sub
    End If

    Dim wasSuppressed As Boolean
    wasSuppressed = swFlatFeat.IsSuppressed

    If wasSuppressed Then
        swFlatFeat.SetSuppression2 swUnSuppressFeature, swThisConfiguration, Nothing
        ' Unsuppress alleen markeert de feature als te herbouwen; zonder een
        ' expliciete rebuild kan SaveAs de VORIGE (verouderde) geometrie
        ' exporteren. Forceer daarom een rebuild voordat we wegschrijven.
        swModel.EditRebuild3
    End If

    If InStrRev(docPath, ".") = 0 Then
        MsgBox "Bestandspad heeft geen extensie.", vbExclamation
        Exit Sub
    End If

    Dim dxfPath As String
    dxfPath = Left(docPath, InStrRev(docPath, ".")) & "dxf"

    Dim saveErrors As Long
    Dim saveWarnings As Long
    Dim ok As Boolean
    ' swSaveAsOptions_Copy: exporteer een kopie zonder het open document aan
    ' het nieuwe bestand te koppelen (zie ook export-step.bas).
    '
    ' LET OP — dit is SaveAs op het part-document zelf, niet de documenteerde
    ' ExportToDWG2-route (met bSelectedFeature op de Flat-Pattern-feature) of
    ' ExportFlatPatternView. Met de Flat-Pattern-feature unsuppressed
    ' exporteert SaveAs in de praktijk meestal het vlakke patroon, maar dat
    ' gedrag is per SolidWorks-versie en tekeningsjabloon niet gegarandeerd.
    ' Controleer het geëxporteerde bestand altijd zelf: open de DXF en
    ' bevestig dat je het UITGEVOUWEN vlakke patroon ziet (rechte omtrek +
    ' buiglijnen), niet een projectie van het gevouwen deel. Stuur nooit
    ' ongecontroleerd naar de laser.
    ok = swModel.Extension.SaveAs(dxfPath, swSaveAsCurrentVersion, swSaveAsOptions_Silent Or swSaveAsOptions_Copy, Nothing, saveErrors, saveWarnings)

    If wasSuppressed Then
        swFlatFeat.SetSuppression2 swSuppressFeature, swThisConfiguration, Nothing
    End If

    If ok And saveErrors = 0 Then
        MsgBox "Opgeslagen als:" & vbCrLf & dxfPath & vbCrLf & vbCrLf & _
            "Controleer de DXF vóór gebruik: dit moet het uitgevouwen vlakke " & _
            "patroon zijn, niet een projectie van het gevouwen deel.", vbInformation
    Else
        MsgBox "Exporteren mislukt (foutcode " & saveErrors & ").", vbCritical
    End If

End Sub

Mass and center of gravity

Reports kg, mm³ and center of mass in mm for the active configuration. Requires an up-to-date part or resolved assembly with correct materials. Clears selection; does not save. Run main.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Output depends on resolved geometry, materials and active configuration; units/API calls were statically reviewed only.

SOLIDWORKS API — CreateMassProperty ↗

Download .bas

SHA-256: 38a80bd6340c604ce190d117cbce1d6a6bcb72d4e3cf68a3126b412da5c92688

View VBA code for Mass and center of gravity
Attribute VB_Name = "MechifyMassReport"
' Mechify - massa en zwaartepunt, actieve configuratie.
' SolidWorks VBA: importeer via File > Import File en start main.
' Vereist opgelost, actueel part/assembly en juiste materiaalgegevens.
' Geen opslag of rebuild. Selectie wordt gewist om het volledige model te meten.
' Systeemwaarden: kg, m en m^3. Model-origin als referentie.
' API: https://help.solidworks.com/2017/english/api/sldworksapi/SOLIDWORKS.Interop.sldworks~SOLIDWORKS.Interop.sldworks.IModelDocExtension~CreateMassProperty.html
Option Explicit
Sub main()
    On Error GoTo Failed
    Dim app As SldWorks.SldWorks
    Dim doc As SldWorks.ModelDoc2
    Set app = Application.SldWorks
    Set doc = app.ActiveDoc
    If doc Is Nothing Then
        MsgBox "Open eerst een part of assembly.", vbExclamation
        Exit Sub
    End If
    If doc.GetType <> swDocPART And doc.GetType <> swDocASSEMBLY Then
        MsgBox "Deze macro is bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If
    doc.ClearSelection2 True
    Dim props As SldWorks.MassProperty
    Set props = doc.Extension.CreateMassProperty
    If props Is Nothing Then
        MsgBox "Geen massa-eigenschappen beschikbaar. Controleer de solid bodies.", vbExclamation
        Exit Sub
    End If
    props.UseSystemUnits = True
    Dim center As Variant
    center = props.CenterOfMass
    If IsEmpty(center) Then
        MsgBox "Geen zwaartepunt beschikbaar.", vbExclamation
        Exit Sub
    End If
    Dim report As String
    report = "Massa: " & Format(props.Mass, "0.000") & " kg" & vbCrLf
    report = report & "Volume: " & Format(props.Volume * 1000000000#, "0.000") & " mm^3" & vbCrLf
    report = report & "Zwaartepunt t.o.v. oorsprong (mm):" & vbCrLf
    report = report & "X: " & Format(center(0) * 1000#, "0.000") & vbCrLf
    report = report & "Y: " & Format(center(1) * 1000#, "0.000") & vbCrLf
    report = report & "Z: " & Format(center(2) * 1000#, "0.000") & vbCrLf
    report = report & "Controleer materialen en eventuele massa-overrides."
    MsgBox report, vbInformation, "Mechify - " & doc.GetTitle
    Exit Sub
Failed:
    MsgBox "Rapport kon niet worden gemaakt: " & Err.Description, vbExclamation, "Mechify"
End Sub

Configuration overview

Lists part or assembly configurations and marks the active one. Long lists use multiple dialogs. Does not activate or modify configurations. Run main.

Validation status: source statically reviewed

Target environment
SolidWorks 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Reports names and the active configuration; suppression, display states and derived configurations are outside this check.

SOLIDWORKS API — GetConfigurationNames ↗

Download .bas

SHA-256: cfc25611d4052256972484a6117d123b624c1380a7cd52bdb0bb284925f29916

View VBA code for Configuration overview
Attribute VB_Name = "MechifyConfigurations"
' Mechify - alle configuratienamen, zonder activeren of rebuild.
' Importeer deze module via File > Import File en start main.
' De actieve configuratie is gemarkeerd. Lange lijsten worden verdeeld.
' API: https://help.solidworks.com/2019/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IModelDoc2~GetConfigurationNames.html
Option Explicit
Sub main()
    On Error GoTo Failed
    Dim app As SldWorks.SldWorks
    Dim doc As SldWorks.ModelDoc2
    Set app = Application.SldWorks
    Set doc = app.ActiveDoc
    If doc Is Nothing Then
        MsgBox "Open eerst een part of assembly.", vbExclamation
        Exit Sub
    End If
    If doc.GetType <> swDocPART And doc.GetType <> swDocASSEMBLY Then
        MsgBox "Deze macro is bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If
    Dim names As Variant
    names = doc.GetConfigurationNames
    If IsEmpty(names) Then
        MsgBox "Geen configuraties gevonden.", vbInformation
        Exit Sub
    End If
    Dim activeName As String
    activeName = doc.ConfigurationManager.ActiveConfiguration.Name
    Dim report As String, line As String, i As Long
    report = "Configuraties (* = actief):" & vbCrLf
    For i = LBound(names) To UBound(names)
        line = CStr(names(i))
        If line = activeName Then line = "* " & line
        If Len(report) + Len(line) > 850 Then
            MsgBox report, vbInformation, "Mechify - configuraties"
            report = "Vervolg:" & vbCrLf
        End If
        report = report & line & vbCrLf
    Next i
    MsgBox report, vbInformation, "Mechify - configuraties"
    Exit Sub
Failed:
    MsgBox "Rapport kon niet worden gemaakt: " & Err.Description, vbExclamation, "Mechify"
End Sub

Inventor 2024

Install: Alt+F11 (VBA editor) > Insert > Module, paste the code.

Export to STEP

Saves the active part or assembly as .stp, next to the existing file.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Saved parts/assemblies only; translator options and references were not tested in Inventor.

Inventor API 2024 — TranslatorAddIn ↗

Download .bas

SHA-256: f313741700cbfe2f02938215479a7e10509053056bd3e72b4d419a0fcdc9aac8

View VBA code for Export to STEP
Attribute VB_Name = "ExportActiefNaarSTEP"
'
' Inventor 2024 VBA-macro — Exporteer actief document naar STEP
' https://www.mechify.nl/cad/macros
'
' Wat: slaat het actieve part of assembly op als .stp, naast het
' bestaande bestand, met dezelfde naam.
' Vereist: het document is al minstens één keer opgeslagen (heeft een pad).
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Alt+F11 (VBA-editor) > Insert > Module > plak deze code.
'
Option Explicit

Sub ExportActiefNaarSTEP()

    ' ActiveDocument raises when no document is open (it does not return
    ' Nothing), so check Documents.Count first rather than testing the
    ' result of ActiveDocument for Nothing.
    If ThisApplication.Documents.Count = 0 Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    If oDoc.DocumentType <> kPartDocumentObject And oDoc.DocumentType <> kAssemblyDocumentObject Then
        MsgBox "Deze macro is alleen bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If

    If oDoc.FullFileName = "" Then
        MsgBox "Sla het document eerst één keer op (nog geen bestandspad).", vbExclamation
        Exit Sub
    End If

    If InStrRev(oDoc.FullFileName, ".") = 0 Then
        MsgBox "Bestandspad heeft geen extensie.", vbExclamation
        Exit Sub
    End If

    ' Vaste, door Autodesk gedocumenteerde AddIn-id van de STEP-vertaler.
    Dim oStepTranslator As TranslatorAddIn
    ' ItemById RAISES wanneer de AddIn ontbreekt — het geeft geen Nothing terug.
    ' Zonder On Error is de vriendelijke melding hieronder onbereikbaar en
    ' krijgt de gebruiker een VBA-foutdialoog.
    On Error Resume Next
    Set oStepTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
    On Error GoTo 0

    If oStepTranslator Is Nothing Then
        MsgBox "STEP-vertaler niet gevonden. Controleer of deze AddIn actief is.", vbCritical
        Exit Sub
    End If

    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = kFileBrowseIOMechanism

    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

    Dim oData As DataMedium
    Set oData = ThisApplication.TransientObjects.CreateDataMedium

    Dim stepPath As String
    stepPath = Left(oDoc.FullFileName, InStrRev(oDoc.FullFileName, ".")) & "stp"
    oData.FileName = stepPath

    ' Application protocol wordt hier vast gezet — anders bepaalt de laatst
    ' gebruikte UI-instelling stilzwijgend welk protocol de export gebruikt.
    ' Kies AP242 (moderne standaard) of AP214 (breder ondersteund, ouder);
    ' controleer de exacte enum-naam in de Inventor Object Browser (VBA-editor,
    ' F2) onder ApplicationProtocolTypeEnum voor jouw Inventor-versie.
    If oStepTranslator.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
        oOptions.Value("ApplicationProtocolType") = kAP242ApplicationProtocolType
    End If

    Call oStepTranslator.SaveCopyAs(oDoc, oContext, oOptions, oData)

    MsgBox "Opgeslagen als:" & vbCrLf & stepPath, vbInformation

End Sub

Save all

Saves every open document that has unsaved changes.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Saves modified, previously saved open documents; error handling and dependencies were not tested in Inventor.

Inventor API 2024 — Document.Save ↗

Download .bas

SHA-256: d6583222f1173d8e806ac26dab6d7e0cbb3163959edfda60912dd09863db2e34

View VBA code for Save all
Attribute VB_Name = "SlaAllesOp"
'
' Inventor 2024 VBA-macro — Sla alle gewijzigde open documenten op
' https://www.mechify.nl/cad/macros
'
' Wat: loopt door alle op dit moment geopende documenten en slaat elk
' document met niet-opgeslagen wijzigingen (Dirty) op. Documenten zonder
' wijzigingen worden overgeslagen.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Alt+F11 (VBA-editor) > Insert > Module > plak deze code.
'
Option Explicit

Sub SlaAllesOp()

    Dim oDoc As Document
    Dim saved As Integer
    Dim skipped As Integer
    saved = 0
    skipped = 0

    For Each oDoc In ThisApplication.Documents
        If oDoc.Dirty Then
            If oDoc.FullFileName = "" Then
                skipped = skipped + 1
            Else
                oDoc.Save
                saved = saved + 1
            End If
        Else
            skipped = skipped + 1
        End If
    Next

    MsgBox saved & " document(en) opgeslagen." & vbCrLf & _
           skipped & " overgeslagen (geen wijzigingen, of nog niet opgeslagen).", vbInformation

End Sub

Show iProperties

Reads title, author, subject and keywords from the active document. Read-only.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Reads four Summary Information fields; other iProperties and localization behavior were not tested in Inventor.

Inventor API 2024 — PropertySets ↗

Download .bas

SHA-256: d772e9edfac3b07386cf7fa7b542b02c90391f395dbc797406fd183ca0965c94

View VBA code for Show iProperties
Attribute VB_Name = "ToonIProperties"
'
' Inventor 2024 VBA-macro — Toon iProperties van het actieve document
' https://www.mechify.nl/cad/macros
'
' Wat: leest Titel, Auteur, Onderwerp en Trefwoorden uit de
' samenvattingsgegevens (Summary) van het actieve document en toont ze
' in een berichtvenster. Alleen-lezen, wijzigt niets.
'
' Installeren: Alt+F11 (VBA-editor) > Insert > Module > plak deze code.
'
Option Explicit

Sub ToonIProperties()

    ' ActiveDocument raises when no document is open (it does not return
    ' Nothing), so check Documents.Count first.
    If ThisApplication.Documents.Count = 0 Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    Dim oSummary As PropertySet
    Set oSummary = oDoc.PropertySets.Item("Inventor Summary Information")

    Dim msg As String
    msg = "Titel: " & oSummary.Item("Title").Value & vbCrLf
    msg = msg & "Auteur: " & oSummary.Item("Author").Value & vbCrLf
    msg = msg & "Onderwerp: " & oSummary.Item("Subject").Value & vbCrLf
    msg = msg & "Trefwoorden: " & oSummary.Item("Keywords").Value

    MsgBox msg, vbInformation, "iProperties — " & oDoc.DisplayName

End Sub

Batch-export drawings to PDF

Exports every open, already-saved drawing to PDF.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Open, saved drawings only; PDF AddIn, sheets, fonts and references were not tested in Inventor.

Inventor API 2024 — PDF Translator sample ↗

Download .bas

SHA-256: 3b49f1b913ffe83c9e09d8d051d4573e4d5eed8d7a00931264b92ff1620ba406

View VBA code for Batch-export drawings to PDF
Attribute VB_Name = "BatchExportTekeningenNaarPDF"
'
' Inventor 2024 VBA-macro — Batch-export open tekeningen naar PDF
' https://www.mechify.nl/cad/macros
'
' Wat: loopt door alle op dit moment geopende documenten, en exporteert
' elke tekening (.idw/.dwg) die al een bestandspad heeft naar PDF, naast
' het bestaande bestand, met dezelfde naam.
' Parts en assemblies worden overgeslagen.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Alt+F11 (VBA-editor) > Insert > Module > plak deze code.
'
Option Explicit

Sub BatchExportTekeningenNaarPDF()

    ' Vaste, door Autodesk gedocumenteerde AddIn-id van de PDF-vertaler.
    Dim oPDFAddIn As TranslatorAddIn
    ' ItemById RAISES wanneer de AddIn ontbreekt (geeft geen Nothing terug),
    ' dus zonder On Error is de melding hieronder onbereikbaar.
    On Error Resume Next
    Set oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
    On Error GoTo 0

    If oPDFAddIn Is Nothing Then
        MsgBox "PDF-vertaler niet gevonden. Controleer of deze AddIn actief is.", vbCritical
        Exit Sub
    End If

    Dim oDoc As Document
    Dim exported As Integer
    Dim skipped As Integer
    Dim failures As String
    exported = 0
    skipped = 0
    failures = ""

    For Each oDoc In ThisApplication.Documents

        If oDoc.DocumentType = kDrawingDocumentObject Then

            If oDoc.FullFileName = "" Or InStrRev(oDoc.FullFileName, ".") = 0 Then
                skipped = skipped + 1
            Else

                Dim pdfPath As String
                pdfPath = Left(oDoc.FullFileName, InStrRev(oDoc.FullFileName, ".")) & "pdf"

                Dim oContext As TranslationContext
                Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
                oContext.Type = kFileBrowseIOMechanism

                Dim oOptions As NameValueMap
                Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

                Dim oData As DataMedium
                Set oData = ThisApplication.TransientObjects.CreateDataMedium
                oData.FileName = pdfPath

                If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
                    ' Standaardopties van de vertaler.
                End If

                On Error Resume Next
                Call oPDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oData)
                If Err.Number = 0 Then
                    exported = exported + 1
                Else
                    ' Bewaar WAAROM dit document faalde. Zonder dit wordt elke
                    ' oorzaak — vergrendeld bestand, ontbrekende referentie,
                    ' volle schijf — hetzelfde nietszeggende "overgeslagen".
                    skipped = skipped + 1
                    failures = failures & vbCrLf & "- " & oDoc.DisplayName & ": " & Err.Description
                    Err.Clear
                End If
                On Error GoTo 0

            End If

        End If

    Next oDoc

    Dim msg As String
    msg = exported & " tekening(en) geëxporteerd naar PDF." & vbCrLf & _
          skipped & " overgeslagen (geen tekening, of nog niet opgeslagen)."
    If Len(failures) > 0 Then
        msg = msg & vbCrLf & vbCrLf & "Mislukt:" & failures
    End If
    MsgBox msg, vbInformation

End Sub

Export flat pattern to DXF

Saves a sheet metal part's flat pattern as .dxf.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Requires a saved sheet-metal part; DXF options, layer mapping and recovery after errors were not tested in Inventor.

Inventor API 2024 — DataIO.WriteDataToFile ↗

Download .bas

SHA-256: 64e700e07b6e8f5f79d080abb9bb7db9cf695b3d1fc0a3e1a12bf9ade4a824d1

View VBA code for Export flat pattern to DXF
Attribute VB_Name = "ExporteerVlakPatroonNaarDXF"
'
' Inventor 2024 VBA-macro — Exporteer vlak patroon naar DXF
' https://www.mechify.nl/cad/macros
'
' Wat: van het actieve plaatwerk-part wordt het vlakke patroon (Flat
' Pattern) opgeslagen als .dxf naast het bestaande bestand, met dezelfde
' naam. Ontvouwt het vlakke patroon automatisch als dat nog niet bestaat.
' Vereist: het actieve document is een plaatwerk-part (Sheet Metal), en
' is al minstens één keer opgeslagen.
' Zie ook de rekenhulp Richtlijnen kanten op deze site voor Ri,
' beenlengte en Z-buiging bij het plaatwerkontwerp zelf.
' Basis-hulpmiddel, geen productiecode. Test eerst op een kopie.
'
' Installeren: Alt+F11 (VBA-editor) > Insert > Module > plak deze code.
'
Option Explicit

' Vertaleropties hier aanpassen, niet verderop in de functie.
Private Const ACAD_VERSION As String = "2010"
Private Const OUTER_PROFILE_LAYER As String = "IV_OUTER_PROFILE"

Sub ExporteerVlakPatroonNaarDXF()

    ' ActiveDocument raises when no document is open (it does not return
    ' Nothing), so check Documents.Count first.
    If ThisApplication.Documents.Count = 0 Then
        MsgBox "Geen actief document.", vbExclamation
        Exit Sub
    End If

    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    If oDoc.DocumentType <> kPartDocumentObject Then
        MsgBox "Geen part-document. Open een plaatwerk-part.", vbExclamation
        Exit Sub
    End If

    If oDoc.FullFileName = "" Then
        MsgBox "Sla het document eerst één keer op (nog geen bestandspad).", vbExclamation
        Exit Sub
    End If

    Dim oPartDoc As PartDocument
    Set oPartDoc = oDoc

    ' Vaste, door Autodesk gedocumenteerde subtype-id van een
    ' plaatwerk-part (Sheet Metal).
    If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
        MsgBox "Geen plaatwerk-part (Sheet Metal).", vbExclamation
        Exit Sub
    End If

    Dim oCompDef As SheetMetalComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition

    ' Onthoud of het vlakke patroon al bestond — zo niet, ruim het na export
    ' weer op zodat het document niet gewijzigd (dirty) achterblijft, net als
    ' de SolidWorks-twin die de suppress-staat terugzet.
    Dim createdFlatPattern As Boolean
    createdFlatPattern = Not oCompDef.HasFlatPattern

    If createdFlatPattern Then
        oCompDef.Unfold
    End If

    Dim oFlatPattern As FlatPattern
    Set oFlatPattern = oCompDef.FlatPattern

    If InStrRev(oDoc.FullFileName, ".") = 0 Then
        MsgBox "Bestandspad heeft geen extensie.", vbExclamation
        GoTo Cleanup
    End If

    Dim dxfPath As String
    dxfPath = Left(oDoc.FullFileName, InStrRev(oDoc.FullFileName, ".")) & "dxf"

    Dim sOptions As String
    sOptions = "FLAT PATTERN DXF?AcadVersion=" & ACAD_VERSION & "&OuterProfileLayer=" & OUTER_PROFILE_LAYER

    ' On Error Resume Next + explicit Err check, not On Error GoTo, so the
    ' Cleanup label below always runs next regardless of success or failure —
    ' a raised error here used to skip straight past oFlatPattern.Delete,
    ' leaving a flat pattern this macro created (and the document marked
    ' dirty) behind on export failure (E17, 16 sept 2026 review).
    Dim exportErrorDescription As String
    On Error Resume Next
    oFlatPattern.DataIO.WriteDataToFile sOptions, dxfPath
    If Err.Number <> 0 Then exportErrorDescription = Err.Description
    On Error GoTo 0

    If exportErrorDescription = "" Then
        MsgBox "Opgeslagen als:" & vbCrLf & dxfPath, vbInformation
    Else
        MsgBox "Exporteren mislukt: " & exportErrorDescription, vbCritical
    End If

Cleanup:
    If createdFlatPattern Then
        On Error Resume Next
        oFlatPattern.Delete
        On Error GoTo 0
    End If

End Sub

Mass and center of gravity

Reports kg, mm³ and center of mass in mm for the active part or assembly model state. Indicates mass overrides. Check materials; does not save the document. Run MassaRapport.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Output depends on current geometry, materials, overrides and model state; units/API calls were statically reviewed only.

Inventor API 2024 — MassProperties ↗

Download .bas

SHA-256: e2b1099d918d0ab1d1301a1eb2d6f6de12813ba5ced14db1b04353b59ead0fd3

View VBA code for Mass and center of gravity
Attribute VB_Name = "MechifyMassaRapport"
' Mechify - massa, volume en zwaartepunt van actieve modeltoestand.
' Inventor VBA: importeer .bas via de VBA-editor en start MassaRapport.
' Vereist actueel part/assembly met juist toegewezen materialen.
' Geen documentopslag; berekende massa wordt niet gecachet.
' Database-eenheden: kg, cm en cm^3; afstanden worden mm.
' API: https://help.autodesk.com/cloudhelp/2024/ENU/Inventor-API/files/MassProperties.htm
Option Explicit
Sub MassaRapport()
    On Error GoTo Failed
    If ThisApplication.Documents.Count = 0 Then
        MsgBox "Open eerst een part of assembly.", vbExclamation
        Exit Sub
    End If
    Dim doc As Object
    Set doc = ThisApplication.ActiveDocument
    If doc.DocumentType <> kPartDocumentObject And doc.DocumentType <> kAssemblyDocumentObject Then
        MsgBox "Deze macro is bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If
    Dim props As MassProperties
    Set props = doc.ComponentDefinition.MassProperties
    props.CacheResultsOnCompute = False
    Dim center As Point
    Set center = props.CenterOfMass
    Dim report As String
    report = "Massa: " & Format(props.Mass, "0.000") & " kg" & vbCrLf
    report = report & "Volume: " & Format(props.Volume * 1000#, "0.000") & " mm^3" & vbCrLf
    report = report & "Zwaartepunt t.o.v. oorsprong (mm):" & vbCrLf
    report = report & "X: " & Format(center.X * 10#, "0.000") & vbCrLf
    report = report & "Y: " & Format(center.Y * 10#, "0.000") & vbCrLf
    report = report & "Z: " & Format(center.Z * 10#, "0.000") & vbCrLf
    report = report & "Massa overschreven: " & CStr(props.MassOverridden) & vbCrLf
    report = report & "Controleer materialen en actieve modeltoestand."
    MsgBox report, vbInformation, "Mechify - " & doc.DisplayName
    Exit Sub
Failed:
    MsgBox "Rapport kon niet worden gemaakt: " & Err.Description, vbExclamation, "Mechify"
End Sub

User parameter report

Reads UserParameter names, expressions and units from the active part or assembly, including text and booleans. Excludes model parameters. Long lists use multiple dialogs. Run ParameterRapport.

Validation status: source statically reviewed

Target environment
Inventor 2024
Source review
2026-09-27
Next review due
2027-03-27
Executed in CAD
No

Part/assembly UserParameters only; model parameters, locale formatting and long reports were not tested in Inventor.

Inventor API 2024 — UserParameter.Expression ↗

Download .bas

SHA-256: 2c804627fa8e63a6a7934216d0c85228e5151f07b847ee97db1c994d55c11f6a

View VBA code for User parameter report
Attribute VB_Name = "MechifyParameters"
' Mechify - overzicht gebruikersparameters, formules en eenheden.
' Inventor VBA: importeer via File > Import File, start ParameterRapport.
' Leest UserParameters van actief part/assembly; geen modelparameters.
' Expression blijft intact, ook voor tekst en booleans. Geen conversie.
' Lange lijsten worden verdeeld; geen waarden aangepast of opgeslagen.
' API: https://help.autodesk.com/cloudhelp/2024/ENU/Inventor-API/files/UserParameter_Expression.htm
Option Explicit
Sub ParameterRapport()
    On Error GoTo Failed
    If ThisApplication.Documents.Count = 0 Then
        MsgBox "Open eerst een part of assembly.", vbExclamation
        Exit Sub
    End If
    Dim doc As Object
    Set doc = ThisApplication.ActiveDocument
    If doc.DocumentType <> kPartDocumentObject And doc.DocumentType <> kAssemblyDocumentObject Then
        MsgBox "Deze macro is bedoeld voor een part of assembly.", vbExclamation
        Exit Sub
    End If
    Dim params As UserParameters
    Set params = doc.ComponentDefinition.Parameters.UserParameters
    If params.Count = 0 Then
        MsgBox "Geen gebruikersparameters gevonden.", vbInformation
        Exit Sub
    End If
    Dim param As UserParameter
    Dim report As String, line As String
    report = "Naam = expressie [eenheid]" & vbCrLf
    For Each param In params
        line = param.Name & " = " & param.Expression & " [" & param.Units & "]"
        If Len(report) + Len(line) > 850 Then
            If Len(report) > 0 Then MsgBox report, vbInformation, "Mechify - parameters"
            report = ""
        End If
        ' Ook een uitzonderlijk lange expressie blijft volledig beschikbaar.
        Do While Len(line) > 850
            MsgBox Left$(line, 850), vbInformation, "Mechify - parameter (vervolg)"
            line = Mid$(line, 851)
        Loop
        report = report & line & vbCrLf
    Next param
    If Len(report) > 0 Then MsgBox report, vbInformation, "Mechify - parameters"
    Exit Sub
Failed:
    MsgBox "Rapport kon niet worden gemaakt: " & Err.Description, vbExclamation, "Mechify"
End Sub

Questions

Why .bas files?+

That's the standard text format for a VBA module. Open the VBA editor, add a module and paste the code, or import the .bas file directly.

Does this work in older versions?+

Written for 2024, but the APIs used have been stable for years. Likely works in 2021–2023 too; not tested.

Are these production macros?+

No. Basic utilities with no edge-case error handling. Test on a copy first, not on a critical file.

Do I need to enable macros?+

Yes, via the Trust Center (SolidWorks) or macro settings (Inventor). Macros from an unknown source are disabled by default.