AnsweredAssumed Answered

Edit / Modify a Reference Plane

Question asked by William Cruz on Aug 31, 2016
Latest reply on Sep 1, 2016 by William Cruz

What I'm trying to do:

Edit a Reference Plane in a Component inside an Assembly.

     The Planes inside the component are broken and I'm trying to re-attach them to an external reference within the main Assembly file. See the image.

     I want to edit the "FINISH" refPlane in the component and make it's first reference the "FINISH" plane in the main assembly.

Code:

                      
/*EDIT COMP IN ASSEMBLY*/
                       int EditRefInfo = 0;
                       swModel.ClearSelection2(true);
                       boolstatus = swModel.Extension.SelectByID2(UpdatedCompNameSelectionString, "COMPONENT", 0, 0, 0, true, 0, null, 0);
                       swAssembly = ((AssemblyDoc)(swModel));
                       swAssembly.EditPart2(true, false, ref EditRefInfo);
                       boolstatus = swModel.ShowConfiguration2("Default");

/*SELECT AND MODIFY*/
                       FeatureManager swFeatMgr = swModel.FeatureManager;
                       SelectionMgr swSelMrg = swModel.SelectionManager;
                       ModelDocExtension swModelDocExt = swModel.Extension;
                       Feature FeatureToAdjust = default(Feature);
                       Feature Replacement = default(Feature);

                       IRefPlaneFeatureData swRefPlaneData = default(IRefPlaneFeatureData);
                       IRefPlaneFeatureData NewSwRefPlaneData = default(IRefPlaneFeatureData);

                       boolstatus = swModel.Extension.SelectByID2("FINISH", "PLANE", 0, 0, 0, true, 0, null, 0);
                       Replacement = (Feature)swSelMrg.GetSelectedObject6(1, -1);
                       NewSwRefPlaneData = Replacement.GetDefinition();
                       boolstatus = NewSwRefPlaneData.AccessSelections(swModel, null);

                       swModel.ClearSelection2(true);

                       boolstatus = swModel.Extension.SelectByID2("FINISH@" + UpdatedCompNameSelectionString, "PLANE", 0, 0, 0, true, 0, null, 0);
                       FeatureToAdjust = (Feature)swSelMrg.GetSelectedObject6(1, -1);
                       swRefPlaneData = FeatureToAdjust.GetDefinition();

                       boolstatus = swRefPlaneData.AccessSelections(swModel, null);

                       swRefPlaneData.Reference[0] = Replacement;

                       FeatureToAdjust.ModifyDefinition(swRefPlaneData, swModel, null);

Outcomes