×
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

Super Ctrl-Q
3

Super Ctrl-Q

Super Ctrl-Q

(OP)

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.

RE: Super Ctrl-Q

Thanks handleman, this is a very useful macro, great tip!

RE: Super Ctrl-Q

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

RE: Super Ctrl-Q

Is this like having the Verification on rebuild option activated?

RE: Super Ctrl-Q

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

RE: Super Ctrl-Q

2
(OP)
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.  

RE: Super Ctrl-Q

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

RE: Super Ctrl-Q

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
www.scottjbaugh.com

Quote:

"If it's not broke, Don't fix it!"
FAQ731-376: Eng-Tips.com Forum Policies

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