We have some assemblies with patterns missing their driving feature information. I don’t know how it was lost, but I’m writing an application that will warn the user if the information is missing. I’m using SolidWorks 2010 SP 5. The following code runs pre-save within an addin:
Imports SolidWorks.Interop.sldworks
Public Class clsPatterns
Private model As IModelDoc2
Public Sub New(ByVal swModel As IModelDoc2)
model = swModel
End Sub
Public Sub FindUndrivenPatterns()
Try
Dim strFeatureName As String
For Each objFeature As IFeature In model.FeatureManager.GetFeatures(True)
If objFeature.Name.ToUpper.Contains("PATTERN") Then
strFeatureName = objFeature.GetTypeName2()
Select Case strFeatureName
Case "DerivedSketchPattern"
Dim objCurrentDefinition As IDerivedPatternFeatureData = objFeature.GetDefinition
Dim objPatternFeature As Feature = objCurrentDefinition.PatternFeature
If objPatternFeature Is Nothing Then
MsgBox("warning1")
End If
Case "LocalLPattern"
Dim objCurrentDefinition As ILocalLinearPatternFeatureData = objFeature.GetDefinition
Dim objAxis As Object = objCurrentDefinition.D1Axis
If objAxis Is Nothing Then
MsgBox("warning2")
End If
Case "LocalCirPattern"
Dim objCurrentDefinition As ILocalCircularPatternFeatureData = objFeature.GetDefinition
Dim objAxis As Object = objCurrentDefinition.Axis
If objAxis Is Nothing Then
MsgBox("warning3")
End If
End Select
End If
Next
Catch ex As Exception
End Try
End Sub
End Class
I am having trouble returning a value for the PatternFeature property within the IDerivedPatternFeatureData interface and the Axis property within the ILocalCircularPatternFeatureData interface. A value of Nothing is returned. I’m using the same process for the D1Axis property in the ILocalLinearPatternFeatureData interface and this value is correctly returned. I don’t seem to have an issue with any other properties of the three pattern interfaces I’m calling.
What might I be doing wrong?
SolidworksApi macros