1 Reply Latest reply on Dec 10, 2015 8:16 PM by James Hall

    Change a contour defining a feature

    James Hall

      Hi all,

       

      We are having trouble replacing the defining contour of an extruded feature body.

      We have generated a new set of SketchSegments, found the SketchContour containing these segments and

      are attempting to replace a previously specified contour with the new contour we have created.

      • Is it possible to change the contour of an extruded feature, a "BossThin" feature in this case?
        • If so what are the prerequisites for a contour to be applied to an extruded feature, a "BossThin" feature in this case?
        • Can a PropertyManagment page be open while making the change?
        • Can a sketch be active while making the change

       

       

      Here is a snippet of what we think should achieve our goal but is not working.

      No sketch is active.

      This is in the OnClose of a PropertyManagmentPage.

       

      Where selectedFeature is the feature to modify

      Where foundContour is the contour we would like to define the ExtrudeFeature

       

      ExtrudeFeatureData2 fd = selectedFeature.GetDefinition() as ExtrudeFeatureData2;
      fd.AccessSelections(targetDocument, null);
      int contourCount = fd.GetContoursCount();
      object[] sketchContours = fd.Contours;
      if (null == fd.Contours) {
      fd.Contours = new object[1];
      }
      fd.Contours[0] = foundContour;
      bool result = selectedFeature.ModifyDefinition(fd, targetDocument, null);

       

      Any suggestions would be greatly appreciated

      Thanks

        • Re: Change a contour defining a feature
          James Hall

          Note if the selected contour is determined unsuitable by the ModifyDefinition call it will not work

           

           

          1. moved to after_close event of PMP. It was required to cache any objects/control states needed from PMP controls

           

          2. Implemented

          private static DispatchWrapper[] ObjectArrayToDispatchWrapperArray(object[] Objects) {

                      int ArraySize = 0;

                      ArraySize = Objects.GetUpperBound(0);

                      DispatchWrapper[] d = new DispatchWrapper[ArraySize + 1];

                      int ArrayIndex = 0;

                      for (ArrayIndex = 0; ArrayIndex <= ArraySize; ArrayIndex++) {

                          d[ArrayIndex] = new DispatchWrapper(Objects[ArrayIndex]);

                      }

                      return d;

           

                  }

           

          3. Changed the code

                                      ExtrudeFeatureData2 fd = selectedFeature.GetDefinition() as ExtrudeFeatureData2;

                                      fd.AccessSelections(targetDocument, null);

                                      fd.Contours = null;

                                      fd.Contours = ObjectArrayToDispatchWrapperArray(new object[1] { foundContour });

                                      bool result = selectedFeature.ModifyDefinition(fd, activeModelDoc2, activeAssem.GetEditTargetComponent());

                                      fd.ReleaseSelectionAccess();

                                      fd = null;