//creates a cutout
        private void Create_Cutout(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face,
                                   int[] face_norm, string selected_face_normal)
        {
            PartDocument _doc = _application.ActiveDocument as PartDocument;

            RefPlanes refPlanes = null;
            RefPlane  refPlane  = null;

            refPlanes = _doc.RefPlanes;
            //Adding parallel refplane to the selected face
            refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false);

            Relations2d     relations2D     = null;
            ProfileSets     profileSets     = null;
            ProfileSet      profileSet      = null;
            Profiles        profiles        = null;
            Profile         profile         = null;
            Lines2d         lines2D         = null;
            Models          models          = null;
            Model           model           = null;
            Sketchs         sketchs         = null;
            Sketch          sketch          = null;
            ExtrudedCutouts extrudedCutouts = null;


            sketchs = _doc.Sketches;
            sketch  = sketchs.Add();

            profileSets = _doc.ProfileSets;
            profileSet  = profileSets.Add();
            profiles    = sketch.Profiles;

            profile     = profiles.Add(refPlane);
            lines2D     = profile.Lines2d;
            relations2D = (Relations2d)profile.Relations2d;

            //adding a 2D profile for the cutout
            lines2D.AddBy2Points(0.03, -0.055, 0.045, -0.055);
            lines2D.AddBy2Points(0.045, -0.055, 0.045, -0.04);
            lines2D.AddBy2Points(0.045, -0.04, 0.03, -0.04);
            lines2D.AddBy2Points(0.03, -0.04, 0.03, -0.055);

            profile.End(ProfileValidationType.igProfileClosed);

            models = _doc.Models;
            model  = models.Item(1);

            extrudedCutouts = model.ExtrudedCutouts;

            //adding a new extruded cutout
            extrudedCutouts.AddThroughNext(Profile: profile,
                                           ProfileSide: FeaturePropertyConstants.igLeft,
                                           ProfilePlaneSide: FeaturePropertyConstants.igLeft
                                           );
        }
        //creates a slot
        private void Create_Slot(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face,
                                 int[] face_norm, string selected_face_normal)
        {
            PartDocument _doc = _application.ActiveDocument as PartDocument;

            RefPlanes refPlanes = null;
            RefPlane  refPlane  = null;

            refPlanes = _doc.RefPlanes;
            //Adding a parallel refplane to the selected face
            refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false);

            ProfileSets profileSets = null;
            ProfileSet  profileSet  = null;
            Profiles    profiles    = null;
            Profile     profile     = null;
            Lines2d     lines2D     = null;
            Models      models      = null;
            Model       model       = null;
            Sketchs     sketchs     = null;
            Sketch      sketch      = null;
            Slots       slots       = null;
            Slot        slot        = null;

            sketchs = _doc.Sketches;
            sketch  = sketchs.Add();

            profileSets = _doc.ProfileSets;
            profileSet  = profileSets.Add();
            profiles    = sketch.Profiles;

            //Adding the refplane to the profile
            profile = profiles.Add(refPlane);
            lines2D = profile.Lines2d;


            lines2D.AddBy2Points(0.02, 0, 0.02, 0.02);

            profile.End(ProfileValidationType.igProfileClosed);

            models = _doc.Models;
            model  = models.Item(1);

            slots = model.Slots;

            //Adding a new slot
            slots.Add(Profile: profile,
                      SlotType: FeaturePropertyConstants.igRegularSlot,
                      SlotEndCondition: FeaturePropertyConstants.igFormedEnd,
                      SlotWidth: 0.005,
                      SlotOffsetWidth: 0,
                      SlotOffsetDepth: 0,
                      ExtentType: FeaturePropertyConstants.igThroughAll,
                      ExtentSide: FeaturePropertyConstants.igLeft,
                      FiniteDistance: 0,
                      KeyPointFlags: KeyPointExtentConstants.igTangentNormal,
                      KeyPointOrTangentFace: null,
                      ExtentType2: FeaturePropertyConstants.igNone,
                      ExtentSide2: FeaturePropertyConstants.igNone,
                      FiniteDistance2: 0,
                      KeyPointFlags2: KeyPointExtentConstants.igTangentNormal,
                      KeyPointOrTangentFace2: null,
                      FromFaceOrPlane: null,
                      FromOffsetSide: OffsetSideConstants.seOffsetNone,
                      FromOffsetDistance: 0,
                      ToFaceOrPlane: null,
                      ToOffsetSide: OffsetSideConstants.seOffsetNone,
                      ToOffsetDistance: 0
                      );
        }
        //creates a hole
        private void create_hole(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face,
                                 int[] face_norm, string selected_face_normal)
        {
            // var selected_face = pGraphicDispatch as SolidEdgeGeometry.Face;
            PartDocument _doc = _application.ActiveDocument as PartDocument;

            RefPlanes refPlanes = null;
            RefPlane  refPlane  = null;

            refPlanes = _doc.RefPlanes;
            //Adding parallel refplane to the selected face
            refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false);



            //Running windows form application
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.Run(new Form1());

            MessageBox.Show("Cancel Hole Dimension?");
            Form1 form1 = new Form1();

            //Hole diameter from user input
            double cc = form1.Hole_dia;

            while (cc < 0.0)
            {
                MessageBox.Show("Enter valid dimension");
                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.Run(new Form1());
                Form1  form2 = new Form1();
                double dd    = form2.Hole_dia;
                MessageBox.Show("Cancel diamension?");
                if (cc == dd)
                {
                    MessageBox.Show("invalid argument");
                    dd = 0.0;
                }
                cc = dd;
            }

            ProfileSets        profileSets        = null;
            ProfileSet         profileSet         = null;
            Profiles           profiles           = null;
            Profile            profile            = null;
            Models             models             = null;
            HoleDataCollection holeDataCollection = null;
            HoleData           holeData           = null;
            Holes2d            holes2D            = null;
            Holes   holes   = null;
            Sketchs sketchs = null;
            Sketch  sketch  = null;


            Array ref_dir = new double[3] as Array;

            //getting the unit vector of the reference direction
            refPlane.GetReferenceDirection(ref ref_dir);
            var Ref_dirX = ref_dir as double[];

            Array root_point = new double[3] as Array;

            refPlane.GetRootPoint(ref root_point);
            var Root_point = root_point as double[];

            //calculating the cross-product between ref_dir and normal vector
            double[] Ref_dirY = new double[3]
            {
                Ref_dirX[2] * face_norm[1] - Ref_dirX[1] * face_norm[2],
                Ref_dirX[0] * face_norm[2] - Ref_dirX[2] * face_norm[0],
                Ref_dirX[1] * face_norm[0] - Ref_dirX[0] * face_norm[1]
            };

            double Xcenter = -0.06; //local coordinates
            double Ycenter = -0.06;

            //calculating global coordinates from local coordinates
            double[] X_bar = new double[3]
            {
                Xcenter *Ref_dirX[0] + Ycenter * Ref_dirY[0] + Root_point[0],
                     Xcenter *Ref_dirX[1] + Ycenter * Ref_dirY[1] + Root_point[1],
                     Xcenter *Ref_dirX[2] + Ycenter * Ref_dirY[2] + Root_point[2]
            };

            //Calculating the angle between vectors root_point and global
            double[] OX = new double[3]
            {
                PointOnGraphic_X - Root_point[0],
                PointOnGraphic_Y - Root_point[1],
                PointOnGraphic_Z - Root_point[2]
            };

            //calculating the modulus of vector OX
            double OX_Mod = Math.Sqrt(Math.Pow(OX[0], 2) + Math.Pow(OX[1], 2) + Math.Pow(OX[2], 2));

            //calculating the modulus of vector Ref_dirX
            double Ref_dirX_Mod = Math.Sqrt(Math.Pow(Ref_dirX[0], 2) + Math.Pow(Ref_dirX[1], 2) + Math.Pow(Ref_dirX[2], 2));

            //calculating the modulus of the vector ReF_dirY
            double Ref_dirY_Mod = Math.Sqrt(Math.Pow(Ref_dirY[0], 2) + Math.Pow(Ref_dirY[1], 2) + Math.Pow(Ref_dirY[2], 2));

            //calculating the dot product between vector OX and Ref_dirY
            double dotY = (OX[0] * Ref_dirY[0]) + (OX[1] * Ref_dirY[1]) + (OX[2] * Ref_dirY[2]);

            //calculating the dot product between vector OX and Ref_dirX
            double dotX = (OX[0] * Ref_dirX[0]) + (OX[1] * Ref_dirX[1]) + (OX[2] * Ref_dirX[2]);

            //calculating the angle between vector OX and Ref_dirY
            double angleY = Math.Acos(dotY / (OX_Mod * Ref_dirY_Mod));

            //calculating the angle between vector OX and Ref_dirX
            double angleX = Math.Acos(dotX / (OX_Mod * Ref_dirX_Mod));

            double X_dir = 0.0;
            double Y_dir = 0.0;


            if (angleY > Math.PI / 2)
            {
                X_dir = OX_Mod * Math.Cos(-angleX);

                Y_dir = OX_Mod * Math.Sin(-angleX);
            }
            else
            {
                X_dir = OX_Mod * Math.Cos(angleX);
                Y_dir = OX_Mod * Math.Sin(angleX);
            }

            if (OX_Mod == 0.0)
            {
                X_dir = 0.0;
                Y_dir = 0.0;
            }

            if (cc > 0.0)
            {
                sketchs = _doc.Sketches;
                sketch  = sketchs.Add();

                holeDataCollection = _doc.HoleDataCollection;

                //Defining hole properties
                holeData = holeDataCollection.Add(
                    HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole,
                    HoleDiameter: cc / 1000);

                profileSets = _doc.ProfileSets;
                profileSet  = profileSets.Add();
                //profiles = profileSet.Profiles;
                profiles = sketch.Profiles;

                profile = profiles.Add(refPlane);
                holes2D = profile.Holes2d;

                var dd = holes2D.Add(X_dir, Y_dir);


                profile.End(ProfileValidationType.igProfileClosed);

                // dd.Move(X_dir, Y_dir, 0.0, 0.0);
                //_application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewLookatFace);

                //getting the hole collection and creating a simple hole
                Model model = _doc.Models.Item(1);
                holes = model.Holes;
                holes.AddThroughNext(
                    Profile: profile,
                    ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igBoth,
                    Data: holeData);
            }
        }