Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Super Ctrl-Q 3

Status
Not open for further replies.

handleman

Automotive
Jan 7, 2005
3,411
Code:
Sub main()
Application.SldWorks.ActiveDoc.ForceRebuild3 (False)
End Sub

I think this is the smallest macro I've ever written. Depending on the assembly, it can also take very long to run. Its function is that it does a Ctrl-Q type forced rebuild on the active document and all referenced documents, either subassemblies or parts. Ctrl-Q only force-rebuilds the top level current document. This code doesn't rebuild the parent of a derived/mirrored part, though, unless of course the parent is also in the assembly. Anyway, might come in handy sometime.
 
Thanks handleman, this is a very useful macro, great tip!
 
Yes... I used this for a benchmark macro once... tried it on a 10k part assembly, the amount of errors popping up kept me busy for a day...

Stefan Hamminga
EngIT Solutions
CSWP/Mechanical designer
Searching Eng-Tips forums
 
Is this like having the Verification on rebuild option activated?

starfishingqa0.gif
 
Here it is:

Code:
Option Explicit

Public Enum swUserPreferenceIntegerValue_e
    swAutoSaveInterval = 3
End Enum

Sub main()
    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim nStart                      As Single
    Dim i                           As Long
    Dim bRet                        As Boolean
    Dim propRet                     As Boolean
    Dim runTime                     As String
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
    ' Turn off automatic save
    bRet = swApp.SetUserPreferenceIntegerValue(swAutoSaveInterval, 0)

    nStart = Timer

    bRet = swModel.ForceRebuild3(False)
    runTime = Timer - nStart & " seconds"
    propRet = swModel.AddCustomInfo3("", "LastRebuildTime", swCustomInfoText, runTime)
End Sub

Stefan Hamminga
EngIT Solutions
CSWP/Mechanical designer
Searching Eng-Tips forums
 
CBL,
It's different from Verification On Rebuild. I'm not really sure what exactly VOR does, though. The way I tested to see what this macro actually rebuilds was to put this equation in various parts:

"Test" = MsgBox("Rebuilt " & Part.GetPathName)

If you put this equation into a part, then Ctrl-Q the assembly containing that part (whether or not VOR is on), you will get no message box. However, using ForceRebuild3(False) on that same assembly will give you the message box.

FYI, using this macro will also increase the time required to save an assembly, since the forced rebuild of all the referenced docs marks them as dirty even if you didn't actually change them.
 
A new definition called "Micro Macro".

Chris
SolidWorks 08 0.0/PDMWorks 08
AutoCAD 06
ctopher's home (updated 10-07-07)
ctopher's blog
 
FYI - You should never have "verification of Rebuild" turned on. Only VAR's and support reps should use this for the most part... unless as a user you want to use it... if you do use it it will cause slow downs on the machine.

Regards,

Scott Baugh, CSWP [pc2]
"If it's not broke, Don't fix it!"
faq731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor