×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro Question

Macro Question

Macro Question

(OP)
I am using the following macro to rebuild all configs of a model and return me any false values in a desktop file.  I thought this would give me any configurations with rebuild errors, but apparently that is not the case.  I have found on several instances that I have features with errors but have been retruned a true value for the rebuild.  Does anyone have any ideas:

Sub main()
    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim vConfNameArr            As Variant
    Dim sConfigName             As String
    Dim nStart                  As Single
    Dim i                       As Long
    Dim bShowConfig             As Boolean
    Dim bRebuild                As Boolean
    Dim bRet                    As Boolean

    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Debug.Print "File = " + swModel.GetPathName

    vConfNameArr = swModel.GetConfigurationNames

Open "C:\Documents and Settings\user\Desktop\Config RB.txt"

For Output As #1    ' Open file for output.
    For i = 0 To UBound(vConfNameArr)

        sConfigName = vConfNameArr(i)
        bShowConfig = swModel.ShowConfiguration2(sConfigName)
 
        nStart = Timer

        bRebuild = swModel.ForceRebuild3(False)
       
        Debug.Print "  Config       = " & sConfigName

        'Debug.Print "    ShowConfig = " & bShowConfig

        Debug.Print "    Rebuild    = " & bRebuild
 
        'Debug.Print "    Time       = " & Timer - nStart & " s"

'This example uses the Print # statement to write data to a file.

If bRebuild = False Then Print #1, sConfigName; bRebuild, 'Else Print #1, "    Rebuild Successful   = " & bRebuild


Next i
Close #1    ' Close file.
End Sub


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources