Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

SW Configuration Check 3

Status
Not open for further replies.

rkam

Mechanical
Oct 30, 2007
26
Hi,

I have a part with 180 configurations.

Is there a macro available which will run thru all the configurations and give a list in case there are errors in any of the configurations?

Thanks,
RKam
 
Replies continue below

Recommended for you

There are API calls that do this, but they do not do a complete job of getting all of the information.

Another way to check is to create a new design table. A new design table wil automatically detect all config-specific parameters.
 
You mean something like this?

Code:
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swConfigMgr As SldWorks.ConfigurationManager
Dim swConfig As SldWorks.Configuration
Dim swConfigs As Variant
Dim swFM As SldWorks.FeatureManager
Dim swFeat As SldWorks.Feature
Dim i As Long
Dim sMsg As String
Dim Wait As Long
Dim errCnt As Long
Dim bHadErr As Boolean



Sub main()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swConfigMgr = swDoc.ConfigurationManager
swConfigs = swDoc.GetConfigurationNames
Set swFM = swDoc.FeatureManager

sMsg = "Errors found in configurations:"
swDoc.Visible = False
On Error GoTo SEEMEAGAIN
For i = 0 To UBound(swConfigs)
    swDoc.ShowConfiguration2 swConfigs(i)
    'Debug.Print swConfigs(i)
    Set swFeat = swDoc.FirstFeature
    bHadErr = False
    errCnt = 0
    While Not swFeat Is Nothing
        If swFeat.GetErrorCode <> swFeatureErrorNone Then
            bHadErr = True
            errCnt = errCnt + 1
        End If
        Set swFeat = swFeat.GetNextFeature
    Wend
    If bHadErr Then
        sMsg = sMsg & vbCrLf & swConfigs(i) & " - " & errCnt & " error(s)"
    End If
    'Wait = Timer
    'While Timer < Wait + 1
    '    DoEvents
    'Wend
Next i

If Right(sMsg, 1) = ":" Then
    MsgBox "No configurations had errors."
Else
    MsgBox sMsg
End If
SEEMEAGAIN:
swDoc.Visible = True
End Sub

-handleman, CSWP (The new, easy test)
 
Sorry. I misread the OP.

Anyhoo, beware the API call "ConfigurationManager::GetConfigurationParams" that lists the difference between configs. It misses a lot. As I recall, it does not list config-specific suppression states.
 
Thanks Handleman.
Your Macro was exact and works wonderfully.

Is there a macro available which will run thru the configs and we are able to see the model updates as it goes thru the configs.
 
Yes. This is actually a modification of that macro. If you want to do both:

Code:
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swConfigMgr As SldWorks.ConfigurationManager
Dim swConfig As SldWorks.Configuration
Dim swConfigs As Variant
Dim swFM As SldWorks.FeatureManager
Dim swFeat As SldWorks.Feature
Dim i As Long
Dim sMsg As String
Dim errCnt As Long
Dim bHadErr As Boolean
Dim Delay As Double
Dim Wait As Double



Sub main()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swConfigMgr = swDoc.ConfigurationManager
swConfigs = swDoc.GetConfigurationNames
Set swFM = swDoc.FeatureManager

sMsg = "Errors found in configurations:"
'swDoc.Visible = False
Delay = CDbl(InputBox("How long would you like to display each config. in seconds?"))
On Error GoTo SEEMEAGAIN
For i = 0 To UBound(swConfigs)
    swDoc.ShowConfiguration2 swConfigs(i)
    Wait = Timer
    While Timer < Wait + Delay
        DoEvents
    Wend
    'Debug.Print swConfigs(i)
    Set swFeat = swDoc.FirstFeature
    bHadErr = False
    errCnt = 0
    While Not swFeat Is Nothing
        If swFeat.GetErrorCode <> swFeatureErrorNone Then
            bHadErr = True
            errCnt = errCnt + 1
        End If
        Set swFeat = swFeat.GetNextFeature
    Wend
    If bHadErr Then
        sMsg = sMsg & vbCrLf & swConfigs(i) & " - " & errCnt & " error(s)"
    End If
    'Wait = Timer
    'While Timer < Wait + 1
    '    DoEvents
    'Wend
Next i

If Right(sMsg, 1) = ":" Then
    MsgBox "No configurations had errors."
Else
    MsgBox sMsg
End If
SEEMEAGAIN:
'swDoc.Visible = True
End Sub

-handleman, CSWP (The new, easy test)
 
Sooperb Handleman.
This was a very good one, more than what I wanted, with the time setting for each config view. Very useful, though I did not think of this when I asked you this.
Excellent, Thank you very much!!!
 
Howdy,

I totally agree - Sooperb Handleman!

It's a very useful time saver for those that use (or administer) configurations. I'm sure it would be used by many. You should finish it and post it.

Thanks rkam for asking about this.

Thanks

Tobin Sparks
 
Tobin1 said:
You should finish it and post it.

What sort of finishing do you mean? Additional functionality?

-handleman, CSWP (The new, easy test)
 
handleman,

It already functions better than expected :) . I just meant 1) put your name on it 2) add a description 3) Maybe add "Option Explicit" statement. Those were the only things I did in order to add it in my list of useful macros. I named the file CheckConfigs.swp.

Thanks Again

Tobin Sparks
 
Oh. I don't really "post" stuff anywhere but here, and I usually figure that the thread gives description enough. As far as "Option Explicit" goes, adding it to code that already has properly defined variables really performs no function.

There's really not much here that hasn't been posted in previous threads. I think the bulk of the config changing code came from some example in the API help.

-handleman, CSWP (The new, easy test)
 
handleman,

Okay - thanks for putting this together for us. ""I don't really "post" stuff anywhere but here"" - maybe this could go in FAQ.

Thanks Again

Tobin Sparks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor