ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
AHAxel Hedman14/02/2017

Hi, I have a number of parts and assemblies i need to make drawings of.

There is a monotone task of writing properties in all models and then make a drawing on each one.

I want to make this process somewhat automated. So far I have managed to make this macro (I have no idea what Im doing, much copy and paste from this forum, but it seems to work.)

I have found that schedule manager can make drawings from all parts, that sound good.

However, I still don´t get how I make this macro run on all the files in one folder.

Can someone help me?

This is the code I want to run on all files:

Dim swApp As SldWorks.SldWorks

Dim swModel As ModelDoc2

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    'Check and Add/Update Number Property

    If swModel.CustomInfo("Number") = "" Then

      swModel.AddCustomInfo2 "Number", swCustomInfoText, (swModel.GetTitle)

    Else

        swModel.CustomInfo("Number") = (swModel.GetTitle)

    End If

   

    If swModel.CustomInfo("DrawnBy") = "" Then

      swModel.AddCustomInfo2 "DrawnBy", swCustomInfoText, "AHe / Devex"

    Else

        swModel.CustomInfo("DrawnBy") = "AHe / Devex"

    End If

   

    If swModel.CustomInfo("Surface finish") = "" Then

      swModel.AddCustomInfo2 "Surface finish", swCustomInfoText, "Ready for paint"

    Else

        swModel.CustomInfo("Surface finish") = "Ready for paint"

    End If

   

    If swModel.CustomInfo("General Tolerances") = "" Then

      swModel.AddCustomInfo2 "General Tolerances", swCustomInfoText, "SS-ISO 2768-1-m"

    Else

        swModel.CustomInfo("General Tolerances") = "SS-ISO 2768-1-m"

    End If

    If swModel.CustomInfo("Project") = "" Then

      swModel.AddCustomInfo2 "Project", swCustomInfoText, "P0988"

    Else

        swModel.CustomInfo("Project") = "P0988"

    End If

End Sub