Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

ForceRebuild3 is not returning FALSE if there are rebuild errors.

Status
Not open for further replies.

rustynissan

New member
Dec 2, 2008
24
So I am trying to cycle through each configuration of an assembly document and check whether there are any rebuild errors. I intentionally added a mate to one configuration that causes errors, but the ForceRebuild3 method does not appear to catch it. My code is attached below. Any suggestions?

Code:
Sub main(myStr As String)
    
    Dim SW_APP          As SldWorks.SldWorks
    Dim SW_DOC          As SldWorks.ModelDoc2
    Dim boolstatus      As Boolean
    
    Debug.Print "**** START ****"
    Debug.Print myStr
    
    Set SW_APP = CreateObject("SldWorks.Application")
    Set SW_DOC = SW_APP.ActiveDoc
    
    SW_DOC.ShowConfiguration2 myStr
    boolstatus = SW_DOC.ForceRebuild3(True)
    
    Debug.Print "Succesful Rebuild?: " & boolstatus
    
    Set SW_DOC = Nothing
    Set SW_APP = Nothing
    
    Debug.Print "***** END *****"
    
End Sub

SW2009 x64 SP4.1, Vista Business x64, Intel Core i7 920 @4.2GHz, Quadro FX580, 2x 147GB 15K-rpm SAS HDs (RAID 0), 6GB DDR3 1600MHz RAM
 
Replies continue below

Recommended for you

Wow, haven't updated my signature in a while... it should read: "SW2011 x64 SP3.0, Windows 7 x64"

SW2011 x64 SP3.0, Windows 7 x64
 
Code:
...
value = instance.ForceRebuild3(TopOnly)
...
Parameters

TopOnly
True rebuilds the top-level assembly only; false rebuilds the top-level assembly and all subassemblies

Return Value

True if the rebuild is successful, false if not

Are you expecting the sub-assemblies to be rebuilding too? You have passed "True" in to the Parameters for ForceRebuild3.

Devon Murray, EIT [Mechanical]
Solidworks 2011 SP 2.0
 
No, I actually have "False" in there now. I was trying both cases. Not necessary to rebuild that deep.

ForceRebuild3 appears to be returning "True" (-1) no matter what... I have tried declaring boolstatus as Variant type, passing it to a variable of type Long, then checking the numeric value and it still returns "-1" when there are rebuild errors in the document.

SW2011 x64 SP3.0, Windows 7 x64
 
Sorry, let me clarify. I have mates in the top-level assembly that are conflicting, causing rebuild errors. Does SolidWorks' definition of the successful rebuild of an assembly document exclude the Mates Folder?

SW2011 x64 SP3.0, Windows 7 x64
 
Well, after contacting someone at SolidWorks, it turns out that IModelDoc2::ForceRebuild3 does in fact IGNORE the mates folder. A workaround in my case was to use IModelDocExtension::GetWhatsWrongCount. If this value = 0 (after a rebuild, of course) then the rebuild is completely successful.

SW2011 x64 SP3.0, Windows 7 x64
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor