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
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
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
CODE
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
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
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
CODE
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
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
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
What sort of finishing do you mean? Additional functionality?
-handleman, CSWP (The new, easy test)
RE: SW Configuration Check
It already functions better than expected
Thanks Again
Tobin Sparks
www.nov.com
RE: SW Configuration Check
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
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