5 Replies Latest reply on Apr 26, 2013 5:00 AM by Ali Rashidikamjani

    Split Body C#

    David Homar

      Please tell me why don't work this programfor splitting body.

      Why don't get the two bodies from this part.

       

       

       

       

      using SolidWorks.Interop.sldworks;

      using SolidWorks.Interop.swconst;

      using System;

      using System.Diagnostics;

      namespace CreateCutExtrudeCSharp.csproj

      {

       

          public partial class SolidWorksMacro

          {

       

              public void Main()

              {

       

                  ModelDoc2 swModel = default(ModelDoc2);

                  ModelDocExtension swModelDocExt = default(ModelDocExtension);

                  FeatureManager swFeatureManager = default(FeatureManager);

                  Feature swFeature = default(Feature);

                  SelectionMgr swSelMgr = default(SelectionMgr);

       

                  bool boolstatus = false;

       

                  swModel = (ModelDoc2)swApp.ActiveDoc;

                  swModelDocExt = (ModelDocExtension)swModel.Extension;

                  swFeatureManager = (FeatureManager)swModel.FeatureManager;

                  swSelMgr = (SelectionMgr)swModel.SelectionManager;

       

                  object[] vResultingBodies;

                  object vBodiesToMark;

                  object vOrigins;

                  object vBodyName;

       

                  object[] BodiesToMark = new object[2];

                  object[] Origins = new object[2];

                  object[] BodyName = new object[2];

       

                  boolstatus = swModelDocExt.SelectByID2("", "PLANE", 0, 0, 0.1, true, 1, null, 0);

       

                  vResultingBodies = (object[])swModel.FeatureManager.PreSplitBody();

       

                  BodiesToMark[0] = vResultingBodies[0];

                  BodiesToMark[1] = vResultingBodies[1];

       

                  BodyName[0] = "";

                  BodyName[1] = "";

       

                  Origins[0] = null;

                  Origins[1] = null;

       

                  vBodiesToMark = BodiesToMark;

                  vOrigins = Origins;

                  vBodyName = BodyName;

       

                  swFeature = (Feature)swModel.FeatureManager.PostSplitBody((BodiesToMark), (false), (Origins), (BodyName));

                 

              }

              /// <summary>

              /// The SldWorks swApp variable is pre-assigned for you.

              /// </summary>

              public SldWorks swApp;

          }

      }