Optimizing a Macro

Hi all.

I use a VBA command that I had developed with a colleague. This macro allows, from a drawing, to convert the file into different formats: .dwg / .dxf and .pdf

It also allows you to convert the 3D file to .step.

The problem is that at that time, we couldn't find the VBA command that allowed us to open a 3D file from the drawing.

We therefore had to rewrite the address in which the 3D file is located (the same as the 2D file except in case of configuration and exceptional case)

If anyone knows the VBA command that allows you to open a 3D file from the drawing, it could allow me to make my code more reliable.

Thank you.


export_2020-11-04_test.swp

Hello

A somewhat similar topic here.

Kind regards

1 Like

Or something like the following:

Sub main()

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swSheet As SldWorks.Sheet
    Dim swView As SldWorks.View
    Dim bRet As Boolean

    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swSheet = swDraw.GetCurrentSheet
    Set swView = swDraw.GetFirstView

    While Not swView Is Nothing
        Debug.Print swView.GetReferencedModelName
        Set swView = swView.GetNextView
    Wend

End Sub

Kind regards

2 Likes