Hi Guys
I've been working on a macro that's been working great, but then it started crashing when I added an InsertAxis Feature.
The axis is added perfectly, it is only later when the second new configuration is added that the crash happens.
I've written a simpler example that illustrates the problem..
this works just fine
As Does This
But run both together and I get this splendid error
and then a hard crash!
full code below
TIA
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDocSub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
Dim RightPlane As SldWorks.Feature
Dim TopPlane As SldWorks.FeatureSet RightPlane = swPart.FeatureByName("Right Plane")
Set TopPlane = swPart.FeatureByName("Top Plane")
Dim newPlane As SldWorks.Feature
Set newPlane = RightPlane
Dim swConfig As SldWorks.Configuration
Dim i As Long
For i = 1 To 10
Set swConfig = swModel.AddConfiguration3("C" & CStr(i), "", "", swConfigOption_SuppressByDefault)
newPlane.Select2 Append:=False, Mark:=0
Set newPlane = swModel.FeatureManager.InsertRefPlane(swRefPlaneReferenceConstraint_Distance, 0.01, 0, 0#, 0, 0#)
newPlane.Select2 Append:=False, Mark:=0
TopPlane.Select2 Append:=True, Mark:=0
swModel.InsertAxis2 TrueNext i
End Sub
Well I've got it working but not sure exactly why..
My hunch was that I shouldn't hang on to the feature objects, so I rewrote it using feature IDs and it works.
Here's my revised code.