×
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

SW Configuration Check
3

SW Configuration Check

SW Configuration Check

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

RE: SW Configuration Check

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.

RE: SW Configuration Check

3
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)

RE: SW Configuration Check

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.

RE: SW Configuration Check

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

RE: SW Configuration Check

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)

RE: SW Configuration Check

(OP)
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!!!

RE: SW Configuration Check

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

RE: SW Configuration Check

Quote (Tobin1):


You should finish it and post it.

What sort of finishing do you mean?  Additional functionality?

-handleman, CSWP (The new, easy test)

RE: SW Configuration Check

handleman,

It already functions better than expected smile . 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
www.nov.com

RE: SW Configuration Check

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)

RE: SW Configuration Check

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

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