Esempio n. 1
0
        public SldBsp GetSldPrdInfoFromFile(IEdmVault5 poVault, string filePath)
        {
            SldBsp      bspPrt = null;
            IEdmFolder5 opParentFolder;
            //bspPrt = new SldBuy();
            IEdmFile5 poFile = poVault.GetFileFromPath(filePath, out opParentFolder);

            if (poFile == null)
            {
                bspPrt      = new SldPrt();
                bspPrt.type = 1;
                return(bspPrt);
            }
            IEdmEnumeratorVariable5 enumVar = poFile.GetEnumeratorVariable();

            if (enumVar == null)
            {
                return(null);
            }

            object tmpVar;
            string partType = "";

            if (enumVar.GetVar("Part Type", "@", out tmpVar))
            {
                partType = tmpVar.ToString();
            }
            if (partType == "自制件")
            {
                bspPrt      = new SldPrt();
                bspPrt.type = 1;
                SldPrt prt = (SldPrt)bspPrt;
                if (enumVar.GetVar("工艺路线", "@", out tmpVar))
                {
                    prt.route = tmpVar.ToString();
                }
            }
            else if (partType == "标准件")
            {
                bspPrt      = new SldStd();
                bspPrt.type = 2;
            }
            else
            {
                bspPrt      = new SldBuy();
                bspPrt.type = 3;
            }
            bspPrt.path = filePath;
            return(bspPrt);
        }
Esempio n. 2
0
        public void ProcessTableAnn(BomTableAnnotation swBOMTableAnn, string ConfigName, SldAsm asmPrd)
        {
            int             nNumRow    = 0;
            string          ItemNumber = null;
            string          PartNumber = null;
            TableAnnotation swTableAnn = (TableAnnotation)swBOMTableAnn;

            Console.WriteLine("   Table Title        " + swTableAnn.Title);
            IEdmVault5 vault = new EdmVault5();

            vault.LoginAuto("科德研发部", 0);
            if (!vault.IsLoggedIn)
            {
                Console.WriteLine("登录PDM失败");
                return;
            }
            nNumRow       = swTableAnn.RowCount;
            swBOMTableAnn = (BomTableAnnotation)swTableAnn;
            for (int j = 0; j < swTableAnn.RowCount; j++)
            {
                //
                //for (int i = 0; i < swTableAnn.ColumnCount;i++ )
                //    Console.WriteLine(swTableAnn.get_Text(j, i));
                //获取类别和特有信息
                //if (j == swTableAnn.RowCount - 1)//最后一行为标题栏,跳过
                //     continue;
                string filePath   = "";
                string compName   = "";
                string compConfig = "";
                int    compCount  = swBOMTableAnn.GetComponentsCount2(j, ConfigName, out ItemNumber, out PartNumber);
                for (int i = 0; i < compCount; i++)
                {
                    Component2 comp2 = swBOMTableAnn.IGetComponents2(j, ConfigName, i);
                    if (comp2 != null)
                    {
                        filePath   = comp2.GetPathName();
                        compName   = comp2.Name2;
                        compConfig = comp2.ReferencedConfiguration;
                        Console.WriteLine("           Component Name :" + comp2.Name2 + "      Configuration Name : " + comp2.ReferencedConfiguration);
                        Console.WriteLine("           Component Path :" + comp2.GetPathName());
                    }
                }
                if (filePath == "")
                {
                    continue;
                }
                SldBsp bsp = GetSldPrdInfoFromFile(vault, filePath);
                if (bsp == null)
                {
                    continue;
                }
                bsp.path = filePath;
                //SldBsp bsp = new SldBsp();
                swTableAnn.get_Text(j, 0);                              //序号
                bsp.number = swTableAnn.get_Text(j, 1);                 //代号
                bsp.name   = swTableAnn.get_Text(j, 2);                 //名称
                string amout = swTableAnn.get_Text(j, 3);
                bsp.amout    = amout == ""?0:int.Parse(amout);          //数量
                bsp.material = swTableAnn.get_Text(j, 4);               //材料
                string weight = swTableAnn.get_Text(j, 5);
                bsp.weight      = weight == "" ? 0 : int.Parse(weight); //单重
                bsp.totalWeight = bsp.weight * bsp.amout;               // swTableAnn.get_Text(j, 6);//总重
                bsp.remark      = swTableAnn.get_Text(j, 7);            //备注
                string number = swTableAnn.get_Text(j, 8);              //测试
                if (bsp.number == "")
                {
                    bsp.number = number;
                }
                if (bsp is SldPrt)
                {
                    asmPrd.sldPrtList.Add((SldPrt)bsp);
                }
                else if (bsp is SldStd)
                {
                    asmPrd.sldStdList.Add((SldStd)bsp);
                }
                else if (bsp is SldBuy)
                {
                    asmPrd.sldBuyList.Add((SldBuy)bsp);
                }
            }
            return;
        }