Exemplo n.º 1
0
        private void deleteBrowerNodes()
        {
            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;
            int delete = 17;
            ClientBrowserNodeDefinition deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);

            while (deleteoDef != null)
            {
                deleteoDef.Delete();
                delete++;
                deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);
            }
            foreach (Inventor.BrowserNode node in oPanes["油路"].TopNode.BrowserNodes)
            {
                if (node.Visible == false)
                {
                    node.Visible = true;
                }
            }
            oPanes["油路"].Update();
            oPanes["油路"].Activate();
        }
        /// <summary>
        /// delete custom nodes
        /// </summary>
        /// <param name="BrowserNodeDefinition"></param>
        /// <param name="BeforeOrAfter"></param>
        /// <param name="Context"></param>
        /// <param name="HandlingCode"></param>
        /// <remarks></remarks>
        private void m_BrowserEvents_OnBrowserNodeDeleteEntry(object BrowserNodeDefinition, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
        {
            MessageBox.Show("OnBrowserNodeDeleteEntry");
            //do deletion by the client

            if (BeforeOrAfter == EventTimingEnum.kAfter)
            {
                ClientBrowserNodeDefinition oBND = (ClientBrowserNodeDefinition)BrowserNodeDefinition;
                oBND.Delete();
            }
        }
Exemplo n.º 3
0
        private void btnAddNetInformation_Click(object sender, EventArgs e)//加载油路网络信息
        {
            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;
            int delete = 17;
            ClientBrowserNodeDefinition deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);

            while (deleteoDef != null)
            {
                deleteoDef.Delete();
                delete++;
                deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);
            }

            ClientNodeResources oRscs = oPanes.ClientNodeResources;
            ClientNodeResource  oRsc  = oRscs.ItemById(m_ClientId, 14);
            int number = 0;
            int maxId  = 17;

            //加载油孔网络信息
            while (number < 14)
            {
                int j = 0;
                number++;
                BrowserNode node = oPanes["油路"].TopNode.BrowserNodes[number];
                number--;
                while (j < trViewNet.Nodes[number].Nodes.Count)
                {
                    BrowserNodeDefinition oDef = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(trViewNet.Nodes[number].Nodes[j].Text, maxId, oRsc);
                    node.AddChild(oDef);
                    maxId++;
                    j++;
                }
                number++;
            }

            foreach (Inventor.BrowserNode node in oPanes["油路"].TopNode.BrowserNodes)
            {
                if (node.BrowserNodes.Count == 0)
                {
                    node.Visible = false;
                }
            }
            oPanes["油路"].Update();
            oPanes["油路"].Activate();
        }
        private void m_BrowserEvents_OnBrowserNodeGetDisplayObjects(object BrowserNodeDefinition, ref Inventor.ObjectCollection Objects, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
        {
            PartDocument            oPartDocument = m_inventorApplication.ActiveDocument as PartDocument;
            PartComponentDefinition oPartDef      = oPartDocument.ComponentDefinition;

            if (oHighlight == null)
            {
                oHighlight = oPartDocument.CreateHighlightSet();
            }
            else
            {
                oHighlight.Clear();
            }

            Inventor.Color oColor = default(Inventor.Color);
            oColor = m_inventorApplication.TransientObjects.CreateColor(128, 22, 22);

            // Set the opacity
            oColor.Opacity   = 0.8;
            oHighlight.Color = oColor;

            if (BrowserNodeDefinition is ClientBrowserNodeDefinition)
            {
                ClientBrowserNodeDefinition oClientB = (ClientBrowserNodeDefinition)BrowserNodeDefinition;
                //highlight all ExtrudeFeature
                if (oClientB.Label == "Node2")
                {
                    foreach (ExtrudeFeature oExtrudeF in oPartDef.Features.ExtrudeFeatures)
                    {
                        oHighlight.AddItem(oExtrudeF);
                    }
                    //highlight all RevolveFeature
                }
                else if (oClientB.Label == "Node3")
                {
                    foreach (RevolveFeature oRevolveF in oPartDef.Features.RevolveFeatures)
                    {
                        oHighlight.AddItem(oRevolveF);
                    }
                }
            }
        }
Exemplo n.º 5
0
        //-----------------------------------------------------------------------------------
        //从项目数据库加载油路信息
        private void AddNetInformationFrommdb()
        {
            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;
            int delete = 15;
            ClientBrowserNodeDefinition deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);

            while (deleteoDef != null)
            {
                deleteoDef.Delete();
                delete++;
                deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);
            }

            ClientNodeResources oRscs = oPanes.ClientNodeResources;
            ClientNodeResource  oRsc  = oRscs.ItemById(m_ClientId, 14);

            string[] getresult = new string[25];
            m_connectToaccess = new ConnectToAccess(deFaultpath + "\\CavityLibrary", "项目数据库");
            string sql    = @"select * from NETList";
            int    number = 15;

            #region
            m_connectToaccess.GetInformation(sql, "NET1", out getresult);
            int i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[1];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET2", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[2];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET3", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[3];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET4", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[4];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET5", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[5];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET6", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[6];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET7", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[7];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET8", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[8];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET9", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[9];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET10", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[10];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET11", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[11];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET12", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[12];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NULLNET", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[13];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }
            #endregion//加载油孔网络信息
            foreach (Inventor.BrowserNode node in oPanes["油路"].TopNode.BrowserNodes)
            {
                if (node.BrowserNodes.Count == 0)
                {
                    node.Visible = false;
                }
            }
            oPanes["油路"].Update();
            oPanes["油路"].Activate();
        }