Greetings all,
We have code, seen below, that pulls the Revision of the Drawing. Since there is no object that actually represents the drawing we are pulling the value from a specific sheet. Since users have complete control of the Sheet names we are forced to check for "Sheet1" then since AutoCAD has a similar situation we search for "SH1" next and if neither exist we just grab the next config, ie sheet, from the end.
We had a situation where a user renamed the sheets later in the drawing lifecycle. The current version is 85 and does not contain "Sheet1" but a much older version does contain "Sheet1"
What this has brought to light is that the GetVar, since we are specifically looking for Sheet1 config will seek out that config in the "newest available". How do we force GetVar to only pull from the current, or latest, version of the drawing? In our problem case it should have found nothing for "Sheet1" because that does not exist any longer.
Code:
Public Function ParGetProperty(ByVal configNames As String(), ByVal propertyName As String, ByRef value As Object, ByRef exception As ProcessException, Optional ByVal preferredConfigs As String() = Nothing) As Boolean
value = Nothing
exception = Nothing
Try
Dim properties As IEdmEnumeratorVariable5 = m_File.GetEnumeratorVariable()
If preferredConfigs IsNot Nothing Then '<-- preferredConfigs is a string array with 2 values: "Sheet1" and "SH1"
For Each configName As String In preferredConfigs
If properties.GetVar(propertyName, configName, value) Then '<-- property name in this case is "Revision". This is the problem line!!
Return True
End If
Next
End If
For Each configName As String In configNames
If properties.GetVar(propertyName, configName, value) Then
Return True
End If
Next
Return False
Catch pe As ProcessException
exception = pe
exception.SendAlertAndLog("EPDM")
Return False
Catch ex As Exception
exception = New ProcessException(ex)
exception.SendAlertAndLog("EPDM")
Return False
End Try
End Function
Danny,
That is indeed interesting -- something I have not run into yet.
However, you could try using the variables attached to the document (non configuration specific properties) by using the configurations "@" for SOLIDWORKS and "Model" for AutoCAD (I am pretty certain that AutoCAD configuration is a constant).
If those configurations do not have values (or are not maintained), you can get the list of configurations from PDM using something like IEdmFile5.GetConfigurations and feed that to the GetVar method. According to documentation, you can optionally add a parameter value of 0 or an empty string to get only configurations for the latest version of the file.