I've been having no success with the follow piece of code designed to split a part in half. It runs through fine, but 'myFeature' at the end is null and no split occurs in the model. Can anyone suggest what's wrong?
1: public void SplitAllBodies()
2: {
3: // Select the split plane
4: swDoc.ClearSelection2(true);
5: bool boolstatus = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, true, 0, null, 0);
6:
7: // Establish the result of split
8: object[] bodyArray = (object[])(swDoc.FeatureManager.PreSplitBody());
9: swDoc.ClearSelection2(true);
10:
11: // Mark bodies to create
12: object[] vBodyNames = new object[2];
13: object[] vBodyOrigins = new object[2];
14:
15: vBodyNames[0] = "";
16: vBodyNames[1] = "";
17: vBodyOrigins[0] = null;
18: vBodyOrigins[1] = null;
19:
20: DispatchWrapper[] bodiesToMark = (DispatchWrapper[])ObjectArrayToDispatchWrapperArray(bodyArray);
21: DispatchWrapper[] bodyOrigins = (DispatchWrapper[])ObjectArrayToDispatchWrapperArray(vBodyOrigins);
22: DispatchWrapper[] bodyNames = (DispatchWrapper[])ObjectArrayToDispatchWrapperArray(vBodyNames);
23:
24: // Create new bodies
25: Feature myFeature = ((Feature)(swDoc.FeatureManager.PostSplitBody(bodiesToMark, true, bodyOrigins, bodyNames)));
26: Console.WriteLine(myFeature);
27: }
28:
29: public DispatchWrapper[] ObjectArrayToDispatchWrapperArray(object[] SwObjects)
30: {
31: int arraySize = 0;
32: arraySize = SwObjects.GetUpperBound(0);
33: DispatchWrapper[] dispwrap = new DispatchWrapper[arraySize + 1];
34:
35: int arrayIndex = 0;
36: for (arrayIndex = 0; arrayIndex <= arraySize; arrayIndex++)
37: {
38: dispwrap[arrayIndex] = new DispatchWrapper(SwObjects[arrayIndex]);
39: }
40: return dispwrap;
41: }