Example #1
0
        public void WriteAttribute(iFeature oiFeature, string YesOrNo)
        {
            AttributeSets oAttributeSets;

            oAttributeSets = oiFeature.AttributeSets;

            AttributeSet oAttributeSet;

            oAttributeSet = oAttributeSets.Add("MyAttribSet", false);

            Inventor.Attribute oPlaneAttrib;
            oPlaneAttrib = oAttributeSet.Add("InternalName", ValueTypeEnum.kStringType, oiFeature.Name);

            Inventor.Attribute oFootprintAttrib;
            oFootprintAttrib = oAttributeSet.Add("Footprint", ValueTypeEnum.kStringType, YesOrNo);

            Inventor.Attribute IndexNameAttrib;
            IndexNameAttrib = oAttributeSet.Add("IndexName", ValueTypeEnum.kStringType, indexname);

            Inventor.Attribute CodeNameAttrib;
            CodeNameAttrib = oAttributeSet.Add("CodeName", ValueTypeEnum.kStringType, codename);

            Inventor.Attribute CodeNumberAttrib;
            CodeNumberAttrib = oAttributeSet.Add("CodeNumber", ValueTypeEnum.kStringType, codenumber);
        }
Example #2
0
        public override void StartCommand()
        {
            base.StartCommand();
            base.SubscribeToEvent(Interaction.InteractionTypeEnum.kSelection);

            //this.InitializePreviewGraphics();

            //create and display the dialog
            m_editNetForm = new EditNetForm(m_inventorApplication, this);

            if (m_editNetForm != null)
            {
                m_editNetForm.Activate();
                m_editNetForm.TopMost       = true;
                m_editNetForm.ShowInTaskbar = false;
                m_editNetForm.Show();
            }

            //initialize this command data members
            m_selectFace     = null;
            m_selectiFeature = null;

            //enable interaction
            EnableInteraction();
        }
Example #3
0
 public RotateRequest(Inventor.Application application, Face face, iFeature ifeature, double angle)
 {
     m_inventorApplication = application;
     m_selectFace          = face;
     m_selectiFeature      = ifeature;
     m_Angle = angle;
 }
Example #4
0
 public RotateCmd()
 {
     m_rotateForm     = null;
     m_selectFace     = null;
     m_selectiFeature = null;
     m_highlightSet   = null;
 }
Example #5
0
        public override void StartCommand()
        {
            base.StartCommand();

            base.SubscribeToEvent(Interaction.InteractionTypeEnum.kSelection);

            //initialize interaction previewgraphics objects

            //create and display the dialog
            m_connectCmdDlg = new ConnectCmdDlg(m_inventorApplication, this);

            if (m_connectCmdDlg != null)
            {
                m_connectCmdDlg.Activate();
                m_connectCmdDlg.TopMost       = true;
                m_connectCmdDlg.ShowInTaskbar = false;
                m_connectCmdDlg.Show();
            }

            //initialize data members
            m_thisSurface      = null;
            m_connectToSurface = null;

            m_thisCav      = null;
            m_connectToCav = null;

            m_UCS = null;

            //enable interaction
            EnableInteraction();
        }
 public EditNetRequest(Inventor.Application application, iFeature ifeature, string portName, string netName)
 {
     m_selectiFeature      = ifeature;
     m_inventorApplication = application;
     m_selectportName      = portName;
     m_netName             = netName;
 }
Example #7
0
        //由选择曲面获取iFeature特征
        private void GetiFeature(ExtrudeFeature surfaceFeature, ref iFeature ifeature)
        {
            string ifeatureName;

            try
            {
                AttributeSets surfAttributeSets;
                surfAttributeSets = surfaceFeature.AttributeSets;

                AttributeSet surfAttibSet;
                surfAttibSet = surfaceFeature.AttributeSets["MyAttribSet"];

                ifeatureName = (string)surfAttibSet["iFeatureName"].Value;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("获取属性集失败!  " + ex.ToString());
                return;
            }

            //获取iFeature
            PartDocument oPartDoc   = (PartDocument)m_inventorApplication.ActiveDocument;
            iFeatures    oiFeatures = oPartDoc.ComponentDefinition.Features.iFeatures;

            ifeature = oiFeatures[ifeatureName];
        }
Example #8
0
        private void GetSelectiFeature(Face face, ref iFeature ifeature)
        {
            PartDocument oPartDoc;

            oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument;

            PartComponentDefinition oPartCompDef;

            oPartCompDef = oPartDoc.ComponentDefinition;

            PartFeatures oFeatures;

            oFeatures = oPartCompDef.Features;

            iFeatures oiFeatures;

            oiFeatures = oFeatures.iFeatures;

            foreach (iFeature oiFeature in oiFeatures)
            {
                Faces oFaces;
                oFaces = oiFeature.Faces;
                foreach (Face oFace in oFaces)
                {
                    if (oFace == face)
                    {
                        ifeature = oiFeature;
                    }
                }
            }
        }
Example #9
0
        private string m_codenumber;//索引编号寻找iFeature特征


        public InsertOutlineCmd()
        {
            m_highlightSet      = null;
            m_insertOutlineForm = null;
            m_selectiFeature    = null;
            m_selectFace        = null;
            m_UCS = null;
        }
Example #10
0
 public DeleteCmd()
 {
     m_selectFace       = null;
     m_selectiFeature   = null;
     m_deleteCavityForm = null;
     m_highlightSet     = null;
     deleteName         = new string[20];
 }
Example #11
0
 public MoveRequest(Inventor.Application application, Face face, iFeature ifeature, double xOffset, double yOffset)
 {
     m_inventorApplication = application;
     m_selectFace          = face;
     m_selectiFeature      = ifeature;
     m_xOffset             = xOffset;
     m_yOffset             = yOffset;
 }
Example #12
0
 public InsertOutlineRequest(Inventor.Application application, Face face, iFeature ifeature, Point2d point1, Point2d point2)
 {
     m_inventorApplication = application;
     m_insertFace          = face;
     m_selectiFeature      = ifeature;
     m_Point1 = point1;
     m_Point2 = point2;
 }
Example #13
0
 public AlignRequest(Inventor.Application application, Face thisFace, Face withThisFace, int direction, UserCoordinateSystem ucs, iFeature thisiFeature, iFeature withthisiFeature)
 {
     m_inventorApplication = application;
     m_thisFace            = thisFace;
     m_withThisFace        = withThisFace;
     m_direction           = direction;
     m_UCS              = ucs;
     m_thisiFeature     = thisiFeature;
     m_withThisiFeature = withthisiFeature;
 }
Example #14
0
        public DeleteRequest(Inventor.Application application, iFeature ifeature, bool outline, string [] name)
        {
            m_inventorApplication = application;
            m_selectiFeature      = ifeature;
            m_outlineDelete       = outline;
            m_deleteName          = new string [20];
            m_deleteName          = name;
            assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileInfo asmFile = new FileInfo(assembly.Location);

            deFaultpath = asmFile.DirectoryName;
        }
Example #15
0
        public EditNetCmd()
        {
            m_editNetForm    = null;
            m_selectFace     = null;
            m_selectiFeature = null;

            m_UCS          = null;
            m_highlightSet = null;
            assembly       = System.Reflection.Assembly.GetExecutingAssembly();
            FileInfo asmFile = new FileInfo(assembly.Location);

            deFaultpath = asmFile.DirectoryName + "\\CavityLibrary";
        }
Example #16
0
        public ConnectCmd()
        {
            m_connectCmdDlg = null;

            m_thisSurface      = null;
            m_connectToSurface = null;

            m_thisCav      = null;
            m_connectToCav = null;

            m_UCS          = null;
            m_highlightSet = null;
        }
Example #17
0
        //获取单独孔IFeature的相对坐标和Dia
        private void GetiFeatureData(iFeature ifeature, ref double Xposition, ref double Yposition, ref double dia8)
        {
            string iFeatureInterName;

            try
            {
                AttributeSets oAttributeSets;
                oAttributeSets = ifeature.AttributeSets;

                AttributeSet oAttibSet;
                oAttibSet = ifeature.AttributeSets["MyAttribSet"];

                iFeatureInterName = (string)oAttibSet["InternalName"].Value;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("获取属性集失败!  " + ex.ToString());
                return;
            }

            //bool flag1 = false;
            //bool flag2 = false;
            //bool flag3 = false;
            foreach (iFeatureInput oInput in ifeature.iFeatureDefinition.iFeatureInputs)
            {
                if (oInput.Name == iFeatureInterName + ":x")
                {
                    iFeatureParameterInput oiFeatureParaInput;
                    oiFeatureParaInput = (iFeatureParameterInput)oInput;
                    Xposition          = oiFeatureParaInput.Parameter.Value;
                    //flag1 = true;
                }
                if (oInput.Name == iFeatureInterName + ":y")
                {
                    iFeatureParameterInput oiFeatureParaInput;
                    oiFeatureParaInput = (iFeatureParameterInput)oInput;
                    Yposition          = oiFeatureParaInput.Parameter.Value;
                    //flag2 = true;
                }
                if (oInput.Name == iFeatureInterName + ":Dia8")
                {
                    iFeatureParameterInput oiFeatureParaInput;
                    oiFeatureParaInput = (iFeatureParameterInput)oInput;
                    dia8 = oiFeatureParaInput.Parameter.Value;
                    //flag3 = true;
                }
                //if (flag1 && flag2 && flag3)
                //    break;
            }
        }
Example #18
0
        public AlignCmd()
        {
            m_alignCmdDlg = null;

            m_thisFace     = null;
            m_withThisFace = null;

            m_thisiFeature     = null;
            m_withThisiFeature = null;

            m_UCS = null;

            m_highlightSet = null;
        }
Example #19
0
        private void HighlightSelectEntity(iFeature ifeature)
        {
            m_highlightSet = m_inventorApplication.ActiveDocument.CreateHighlightSet();

            Inventor.Color green;
            green         = m_inventorApplication.TransientObjects.CreateColor(0, 255, 0);
            green.Opacity = 0.3;

            m_highlightSet.Color = green;

            foreach (Face oFace in ifeature.Faces)
            {
                m_highlightSet.AddItem(oFace);
            }
        }
Example #20
0
        public override void EnableInteraction()
        {
            base.EnableInteraction();

            //clear selection filter
            m_selectEvents.ClearSelectionFilter();

            //reset selections
            m_selectEvents.ResetSelections();

            if (m_connectCmdDlg.checkBoxCav.Checked)
            {
                m_connectToSurface = null;
                m_connectToCav     = null;
                if (m_UCS != null)
                {
                    m_UCS.Visible = false;
                }
                m_selectEvents.Enabled = true;

                //set the selection filer to a cylinder face
                m_selectEvents.AddSelectionFilter(SelectionFilterEnum.kPartSurfaceFeatureFilter);

                //set a cursor to specify face selection
                m_interactionEvents.SetCursor(CursorTypeEnum.kCursorBuiltInCrosshair, null, null);

                //set the status bar message
                m_interactionEvents.StatusBarText = "请选择孔";
            }
            else
            {
                if (m_thisSurface != null)
                {
                    m_selectEvents.AddToSelectedEntities(m_thisSurface);
                }

                m_selectEvents.Enabled = true;

                //set the selection filter to cylinder face
                m_selectEvents.AddSelectionFilter(SelectionFilterEnum.kPartSurfaceFeatureFilter);

                //set a cursor to specify edge selection
                m_interactionEvents.SetCursor(CursorTypeEnum.kCursorBuiltInCrosshair, null, null);

                //set the status bar message
                m_interactionEvents.StatusBarText = "请选择与其相连接的孔";
            }
        }
        private void ColorAllCavPort(iFeature ifeature, Face face)
        {
            AttributeSets oAttributeSets;

            oAttributeSets = ifeature.AttributeSets;

            AttributeSet oAttributeSet;

            try
            {
                oAttributeSet = oAttributeSets["MyPorts"];
            }
            catch
            {
                oAttributeSet = oAttributeSets.Add("MyPorts", false);
            }

            String num        = "1";
            int    portNum    = int.Parse(m_connectToaccess.SelectConnectToAccess("PortNumber"));
            Double PortDepth1 = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("PortDepth" + num));
            Double Depth0     = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("Depth0"));

            string netName = m_dataportView.Rows[0].Cells[1].Value.ToString();

            ColorCavPort1(ifeature, face, PortDepth1, Depth0, netName, portNum);

            oAttributeSet.Add("MyPortsNumber", ValueTypeEnum.kIntegerType, portNum);
            oAttributeSet.Add("Port1", ValueTypeEnum.kStringType, netName);

            int i = 1;

            while (i < portNum)
            {
                num = (++i).ToString();
                Double PortDia   = double.Parse(m_connectToaccess.SelectConnectToAccess("PortDia" + num));
                Double PortDepth = double.Parse(m_connectToaccess.SelectConnectToAccess("PortDepth" + num));

                Double portCenterDepth = ConvertUnit(PortDepth, "mm", "cm") + Depth0;
                Double portDia         = ConvertUnit(PortDia, "mm", "cm");

                netName = m_dataportView.Rows[--i].Cells[1].Value.ToString();
                ColorCavPort(ifeature, face, portDia, portCenterDepth, netName, portNum, i);
                oAttributeSet.Add("Port" + num, ValueTypeEnum.kStringType, netName);
                i++;
            }
        }
Example #22
0
        public MoveCmd()
        {
            m_moveCmdDlg = null;

            m_selectFace     = null;
            m_selectiFeature = null;

            m_UCS = null;

            m_previewClientGraphicsNode = null;
            m_pointGraphics             = null;
            m_graphicsCoordinateSet     = null;
            m_graphicsColorSet          = null;
            m_graphicsColorIndexSet     = null;

            m_highlightSet = null;
        }
Example #23
0
        public void WriteAttribute(iFeature oiFeature, Inventor.Point mPoint, string YesOrNo, double angle)
        {
            //建立该元件的属性集
            AttributeSets oAttributeSets;

            oAttributeSets = oiFeature.AttributeSets;
            AttributeSet oAttributeSet;

            oAttributeSet = oAttributeSets.Add("MyAttribSet", false);

            //存储元件插入时系统分配的内部名称用于后面的移动操作
            Inventor.Attribute oPlaneAttrib;
            oPlaneAttrib = oAttributeSet.Add("InternalName", ValueTypeEnum.kStringType, oiFeature.Name);

            //存储该元件是否具有安装面
            Inventor.Attribute oFootprintAttrib;
            oFootprintAttrib = oAttributeSet.Add("Footprint", ValueTypeEnum.kStringType, YesOrNo);

            //存储该元件插入点的坐标
            double pointx = m_Point.X;

            Inventor.Attribute mPointXAttrib;
            mPointXAttrib = oAttributeSet.Add("PointX", ValueTypeEnum.kDoubleType, pointx);
            double pointy = m_Point.Y;

            Inventor.Attribute mPointYAttrib;
            mPointYAttrib = oAttributeSet.Add("PointY", ValueTypeEnum.kDoubleType, pointy);
            double pointz = m_Point.Z;

            Inventor.Attribute mPointZAttrib;
            mPointZAttrib = oAttributeSet.Add("PointZ", ValueTypeEnum.kDoubleType, pointz);

            //存储该元件再次插入时连接到数据库需要的信息
            Inventor.Attribute IndexNameAttrib;
            IndexNameAttrib = oAttributeSet.Add("IndexName", ValueTypeEnum.kStringType, m_indexname);
            Inventor.Attribute CodeNameAttrib;
            CodeNameAttrib = oAttributeSet.Add("CodeName", ValueTypeEnum.kStringType, m_codename);
            Inventor.Attribute CodeNumberAttrib;
            CodeNumberAttrib = oAttributeSet.Add("CodeNumber", ValueTypeEnum.kStringType, m_codenumber);

            //存储该元件在插入时已经旋转的角度
            Inventor.Attribute AngleAttrib;
            AngleAttrib = oAttributeSet.Add("Angle", ValueTypeEnum.kDoubleType, angle);
        }
        //板式阀拉伸曲面属性集补充
        private void WritePortFaceAttribute(ExtrudeFeature portFace, iFeature ifeature, int portCount, string portName)
        {
            AttributeSets oAttributeSets;

            oAttributeSets = portFace.AttributeSets;

            AttributeSet oAttributeSet;

            try
            {
                oAttributeSet = oAttributeSets["MyAttribSet"];
            }
            catch
            {
                oAttributeSet = oAttributeSets.Add("MyAttribSet", false);
            }
            oAttributeSet.Add("PortCount", ValueTypeEnum.kIntegerType, portCount);
            oAttributeSet.Add("PortName", ValueTypeEnum.kStringType, portName);
        }
        //-----------------------------------------------------------------------------------
        //为拉伸曲面创建属性集,用于获取端口信息
        private void WritePortFaceAttribute(ExtrudeFeature portFace, iFeature ifeature, int portNumber, int index)
        {
            AttributeSets oAttributeSets;

            oAttributeSets = portFace.AttributeSets;

            AttributeSet oAttributeSet;

            try
            {
                oAttributeSet = oAttributeSets["MyAttribSet"];
            }
            catch
            {
                oAttributeSet = oAttributeSets.Add("MyAttribSet", false);
            }

            oAttributeSet.Add("iFeatureName", ValueTypeEnum.kStringType, ifeature.Name);
            oAttributeSet.Add("PortNumber", ValueTypeEnum.kIntegerType, portNumber);
            oAttributeSet.Add("PortIndex", ValueTypeEnum.kIntegerType, index);
        }
        //-----------------------------------------------------------------------------------
        //编写属性集方法用于旋转操作
        public void WriteAttribute(iFeature oiFeature, Inventor.Point mPoint, string YesOrNo, double angle)
        {
            AttributeSets oAttributeSets;

            oAttributeSets = oiFeature.AttributeSets;

            AttributeSet oAttributeSet;

            oAttributeSet = oAttributeSets.Add("MyAttribSet", false);

            Inventor.Attribute oPlaneAttrib;
            oPlaneAttrib = oAttributeSet.Add("InternalName", ValueTypeEnum.kStringType, oiFeature.Name);

            Inventor.Attribute oFootprintAttrib;
            oFootprintAttrib = oAttributeSet.Add("Footprint", ValueTypeEnum.kStringType, YesOrNo);
            double pointx = m_Point.X;

            Inventor.Attribute mPointXAttrib;
            mPointXAttrib = oAttributeSet.Add("PointX", ValueTypeEnum.kDoubleType, pointx);
            double pointy = m_Point.Y;

            Inventor.Attribute mPointYAttrib;
            mPointYAttrib = oAttributeSet.Add("PointY", ValueTypeEnum.kDoubleType, pointy);
            double pointz = m_Point.Z;

            Inventor.Attribute mPointZAttrib;
            mPointZAttrib = oAttributeSet.Add("PointZ", ValueTypeEnum.kDoubleType, pointz);

            Inventor.Attribute IndexNameAttrib;
            IndexNameAttrib = oAttributeSet.Add("IndexName", ValueTypeEnum.kStringType, indexname);

            Inventor.Attribute CodeNameAttrib;
            CodeNameAttrib = oAttributeSet.Add("CodeName", ValueTypeEnum.kStringType, codename);

            Inventor.Attribute CodeNumberAttrib;
            CodeNumberAttrib = oAttributeSet.Add("CodeNumber", ValueTypeEnum.kStringType, codenumber);

            Inventor.Attribute AngleAttrib;
            AngleAttrib = oAttributeSet.Add("Angle", ValueTypeEnum.kDoubleType, angle);
        }
        private void ColorAllFootpPort(iFeature ifeature, Face face)
        {
            //创建myPorts属性集用于记录各油孔的网络信息
            AttributeSets oAttributeSets;

            oAttributeSets = ifeature.AttributeSets;

            AttributeSet oAttributeSet;

            try
            {
                oAttributeSet = oAttributeSets["MyPorts"];
            }
            catch
            {
                oAttributeSet = oAttributeSets.Add("MyPorts", false);
            }

            int portCount  = int.Parse(m_connectToaccess.SelectConnectToAccess("PortCount"));
            int portNumber = 0;

            try
            {
                portNumber = int.Parse(m_connectToaccess.SelectConnectToAccess("PortNumber"));
            }
            catch
            {
                portNumber = 0;
            }
            oAttributeSet.Add("PortsCount", ValueTypeEnum.kIntegerType, portCount);

            for (int j = portNumber; j < (portCount + portNumber); j++)
            {
                string portName = m_dataportView.Rows[j].Cells[0].Value.ToString();
                string netName  = m_dataportView.Rows[j].Cells[1].Value.ToString();
                ColorFootprintPort(ifeature, face, portCount, netName, portName);
                oAttributeSet.Add(portName, ValueTypeEnum.kStringType, netName);
            }
        }
Example #28
0
        public void PortNet(iFeature oifeature)
        {
            AttributeSets atr = oifeature.AttributeSets;

            AttributeSet abs = atr["MyAttribSet"];

            Inventor.Attribute att            = abs["InternalName"];
            Inventor.Attribute footprint      = abs["Footprint"];
            string             footprintCheck = footprint.Value;

            Inventor.Attribute indexAttribute = abs["IndexName"];
            string             indexName      = indexAttribute.Value;

            Inventor.Attribute codeNameAttribute = abs["CodeName"];
            string             codeName          = codeNameAttribute.Value;

            Inventor.Attribute codeNumberAttribute = abs["CodeNumber"];
            string             codeNumber          = codeNumberAttribute.Value;

            m_connectToaccess = new ConnectToAccess(deFaultpath, "CavityLibrary", codeName, indexName, codeNumber);
            string sql        = @"select * from ComponentsDb where ComponentsDb.IndexName='" + indexName + "'";
            string CavityType = m_connectToaccess.GetSingleInformation(sql, "CavityType");

            if (footprintCheck == "No")
            {
                AttributeSet       myPorts       = atr["MyPorts"];
                Inventor.Attribute AttPortNumber = myPorts["MyPortsNumber"];
                int    PortNumber = AttPortNumber.Value;
                int    i          = 0;
                string num;
                while (i < PortNumber)
                {
                    num = (++i).ToString();
                    Inventor.Attribute Port    = myPorts["Port" + num];
                    string             PortNet = Port.Value;
                    i = m_editNetForm.dataportNET.Rows.Add();
                    m_editNetForm.dataportNET.Rows[i].Cells[1].Value = PortNet;
                    m_editNetForm.dataportNET.Rows[i].Cells[0].Value = ++i;
                }
            }
            else if (footprintCheck == "Yes" && CavityType == "二通插装孔")
            {
                AttributeSet       myPorts       = atr["MyPorts"];
                Inventor.Attribute AttPortNumber = myPorts["MyPortsNumber"];
                int    PortNumber = AttPortNumber.Value;
                int    i          = 0;
                string num;
                while (i < PortNumber)
                {
                    num = (++i).ToString();
                    Inventor.Attribute Port    = myPorts["Port" + num];
                    string             PortNet = Port.Value;
                    i = m_editNetForm.dataportNET.Rows.Add();
                    m_editNetForm.dataportNET.Rows[i].Cells[1].Value = PortNet;
                    m_editNetForm.dataportNET.Rows[i].Cells[0].Value = ++i;
                }
                Inventor.Attribute portCountAttribute = myPorts["PortsCount"];
                int portCount = portCountAttribute.Value;
                int j         = 1;
                while (j <= portCount)
                {
                    i = m_editNetForm.dataportNET.Rows.Add();
                    string             portName   = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString());
                    Inventor.Attribute PortsOther = myPorts[portName];
                    string             NetName    = PortsOther.Value;
                    m_editNetForm.dataportNET.Rows[i].Cells[1].Value = NetName;
                    m_editNetForm.dataportNET.Rows[i].Cells[0].Value = portName;
                    j++;
                }
            }
            else
            {
                AttributeSet       myPorts            = atr["MyPorts"];
                Inventor.Attribute portCountAttribute = myPorts["PortsCount"];
                int portCount = portCountAttribute.Value;
                int j         = 1;
                int i         = 0;
                while (j <= portCount)
                {
                    i = m_editNetForm.dataportNET.Rows.Add();
                    string             portName   = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString());
                    Inventor.Attribute PortsOther = myPorts[portName];
                    string             NetName    = PortsOther.Value;
                    m_editNetForm.dataportNET.Rows[i].Cells[1].Value = NetName;
                    m_editNetForm.dataportNET.Rows[i].Cells[0].Value = portName;
                    j++;
                }
            }
        }
Example #29
0
        public override void OnExecute(Document document, NameValueMap context, bool succeeded)
        {
            PartDocument oPartDoc;

            oPartDoc = (PartDocument)document;

            PartComponentDefinition oPartCompDef;

            oPartCompDef = oPartDoc.ComponentDefinition;

            int i = 0;

            while (i < 20)
            {
                if (m_deleteName[i] != null)
                {
                    m_selectiFeature = oPartCompDef.Features.iFeatures[m_deleteName[i]];
                    AttributeSets atr = m_selectiFeature.AttributeSets;

                    AttributeSet abs = atr["MyAttribSet"];

                    Inventor.Attribute att                 = abs["InternalName"];
                    Inventor.Attribute footprint           = abs["Footprint"];
                    string             footprintCheck      = footprint.Value;
                    Inventor.Attribute indexAttribute      = abs["IndexName"];
                    string             indexName           = indexAttribute.Value;
                    Inventor.Attribute codeNameAttribute   = abs["CodeName"];
                    string             codeName            = codeNameAttribute.Value;
                    Inventor.Attribute codeNumberAttribute = abs["CodeNumber"];
                    string             codeNumber          = codeNumberAttribute.Value;
                    m_connectToaccess = new ConnectToAccess(deFaultpath + "\\CavityLibrary", "CavityLibrary", codeName, indexName, codeNumber);
                    string sql = @"select * from ComponentsDb where ComponentsDb.IndexName='" + indexName + "'";
                    CavityType = m_connectToaccess.GetSingleInformation(sql, "CavityType");
                    string num;
                    if (footprintCheck == "Yes" && CavityType == "板式阀通油孔")
                    {
                        PlanarSketch oSketchFootprint = oPartCompDef.Sketches["Footprint" + m_selectiFeature.Name];
                        oSketchFootprint.Delete();
                        AttributeSet       port       = atr["MyPorts"];
                        Inventor.Attribute portNumber = port["PortsCount"];
                        int portcount = portNumber.Value;
                        int j         = 1;
                        while (j <= portcount)
                        {
                            string portName = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString());
                            oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + portName].Delete();
                            j++;
                        }
                    }
                    else if (footprintCheck == "Yes" && CavityType == "二通插装孔")
                    {
                        AttributeSet       port       = atr["MyPorts"];
                        Inventor.Attribute portNumber = port["MyPortsNumber"];
                        int portnum = portNumber.Value;
                        int j       = 1;
                        while (j <= portnum)
                        {
                            num = (j).ToString();
                            oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + num].Delete();
                            j++;
                        }
                        PlanarSketch oSketchFootprint = oPartCompDef.Sketches["Footprint" + m_selectiFeature.Name];
                        oSketchFootprint.Delete();
                        Inventor.Attribute portCountAttribute = port["PortsCount"];
                        int portCount = portCountAttribute.Value;
                        j = 1;
                        while (j <= portCount)
                        {
                            string portName = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString());
                            oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + portName].Delete();
                            j++;
                        }
                    }
                    else if ((footprintCheck == "No" && CavityType == "螺纹孔") || (footprintCheck == "No" && CavityType == "工艺油孔"))
                    {
                        oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-1"].Delete();
                    }
                    else
                    {
                        AttributeSet       port       = atr["MyPorts"];
                        Inventor.Attribute portNumber = port["MyPortsNumber"];
                        int portnum = portNumber.Value;
                        int j       = 1;
                        while (j <= portnum)
                        {
                            num = (j).ToString();
                            oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + num].Delete();
                            j++;
                        }
                    }

                    m_selectiFeature.Delete();

                    if (m_outlineDelete)
                    {
                        PlanarSketch oSketchOutline = oPartCompDef.Sketches["Footprint" + m_selectiFeature.Name];
                        oSketchOutline.Delete();
                    }
                }
                i++;
            }
            MessageBox.Show("元件删除成功");
        }
        public void insertFootFeature(Face selectFace, string indexnumber)//用于插入具有安装面的元件
        {
            string       oInputName;
            PartDocument oPartDocument;

            oPartDocument = (PartDocument)m_inventorApplication.ActiveDocument;
            PartComponentDefinition oPartCompDef;

            oPartCompDef = oPartDocument.ComponentDefinition;
            Face oSelectFace;

            oSelectFace = selectFace;

            PartFeatures oFeatures;

            oFeatures = oPartCompDef.Features;
            iFeatureDefinition oiFeatureDef;

            oiFeatureDef = oFeatures.iFeatures.CreateiFeatureDefinition(filepath + "\\" + indexnumber + "Footprint.ide");
            ucsNumber    = JudgeFaceUcs(oSelectFace);
            Inventor.Vector oVector = oPartCompDef.UserCoordinateSystems[ucsNumber].XAxis.Line.Direction.AsVector();
            foreach (iFeatureInput oInput in oiFeatureDef.iFeatureInputs)
            {
                if (oInput.Name == "放置平面" || oInput.Name == "x轴" || oInput.Name == "y轴" || oInput.Name == "y" || oInput.Name == "x")
                {
                    switch (oInput.Name)
                    {
                    case "放置平面":
                        iFeatureSketchPlaneInput oPlaneInput;
                        oPlaneInput            = (iFeatureSketchPlaneInput)oInput;
                        oPlaneInput.PlaneInput = oSelectFace;
                        oPlaneInput.SetPosition(m_Point, oVector, rotateAngle);
                        break;

                    case "x轴":
                        iFeatureEntityInput oInputXAxis;
                        oInputXAxis        = (iFeatureEntityInput)oInput;
                        oInputXAxis.Entity = oPartCompDef.UserCoordinateSystems[ucsNumber].XAxis;
                        break;

                    case "y轴":
                        iFeatureEntityInput oInputYAxis;
                        oInputYAxis        = (iFeatureEntityInput)oInput;
                        oInputYAxis.Entity = oPartCompDef.UserCoordinateSystems[ucsNumber].YAxis;
                        break;

                    case "y":
                        iFeatureParameterInput oInputx;
                        oInputx       = (iFeatureParameterInput)oInput;
                        oInputx.Value = Yposition;
                        break;

                    case "x":
                        iFeatureParameterInput oInputy;
                        oInputy       = (iFeatureParameterInput)oInput;
                        oInputy.Value = Xposition;
                        break;
                    }
                }
                else
                {
                    oInputName = oInput.Name;
                    iFeatureParameterInput oParameXInput;
                    oParameXInput            = (iFeatureParameterInput)oInput;
                    oParameXInput.Expression = m_connectToaccess.SelectConnectToAccess(oInputName);
                }
            }
            iFeature oiFeature;

            oiFeature  = oFeatures.iFeatures.Add(oiFeatureDef);
            m_iFeature = oiFeature;


            double disminX = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("LminX")) / 2.0 + Xposition;
            double disminY = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("LminY")) / 2.0 + Yposition;
            double dismaxX = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("LmaxX")) / 2.0 + Xposition;
            double dismaxY = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("LmaxY")) / 2.0 + Yposition;


            DrawSketch(selectFace, Yposition, Xposition, disminY, disminX, dismaxY, dismaxX, m_iFeatureName);

            //------------------------------------------------------------------------------编写保存iFeature名称的属性集
            RotateSketch(oPartCompDef, m_iFeatureName, Yposition, Xposition, rotateAngle);
            WriteAttribute(oiFeature, m_Point, "Yes", rotateAngle);
            oiFeature.Name = m_iFeatureName;

            //------------------------------------------------------------------------------拉伸曲面以区分网络
            string sql        = @"select * from ComponentsDb where ComponentsDb.IndexName='" + indexname + "'";
            string cavityType = m_connectToaccess.GetSingleInformation(sql, "CavityType");

            if (cavityType == "二通插装孔")
            {
                ColorAllCavPort(oiFeature, oSelectFace);
            }

            ColorAllFootpPort(oiFeature, oSelectFace);
            ShowPortColor();
            oPartDocument.Update2();
        }