0 Replies Latest reply on Dec 5, 2014 9:48 AM by Mohammad Isnaini

    Coincident InsertRefPlane using non sketched reference point

    Mohammad Isnaini

      Hello,

       

      I am trying to create a coincident reference plane from a bounding box of a non-planar face. I am planning to use directly the corner points of the bounding box without making the sketch point first. Is it correct to use POINTREF as my selection type when marking the reference using SelectByID2? If so, I have tried the following code but always get the false return for my SelectionStatus. Or, I have to create a sketch point first instead of using non sketch point? Please give me some insight. Thanks.

       

      public RefPlane SetupRefPlane(Face2 ThisFace, ModelDoc2 ThisModelDoc)

              {

                  Object BoxFaceArray = null;

                  Double[] BoxVerticesArray = null;

                  Double DepthZ;           

                  ModelDocExtension SwExt = null;

                  FeatureManager SwFM = null;

                  Boolean SelectionStatus = false;

                  RefPlane RefPlaneInstance = null;

                 

                  BoxFaceArray = (Object)ThisFace.GetBox();

                  BoxVerticesArray = (Double[])BoxFaceArray;

       

                  //get the lowest Z level

                  if (BoxVerticesArray[2] < BoxVerticesArray[5]) { DepthZ = BoxVerticesArray[2]; }

                  else { DepthZ = BoxVerticesArray[5]; }

       

                  SwExt = ThisModelDoc.Extension;

                  SwFM = ThisModelDoc.FeatureManager;

       

                  SelectionStatus = SwExt.SelectByID2("", "POINTREF", BoxVerticesArray[0], BoxVerticesArray[1], DepthZ, true, 0, null, 0);

                  SelectionStatus = SwExt.SelectByID2("", "POINTREF", BoxVerticesArray[3], BoxVerticesArray[4], DepthZ, true, 1, null, 0);

       

                  RefPlaneInstance = (RefPlane)SwFM.InsertRefPlane(4, 0, 4, 0, 0, 0);

       

                  if (RefPlaneInstance != null) { return RefPlaneInstance; }

                  return null;

               }