Exemple #1
0
        public void CopyTaskToNewRobot(Form FM, DataType.Dsystem DSystem, RobotTask robotTask, RobotTask TargetrobotTask, Product SrcRobot, Product TargetRobot)
        {
            //string TarName = SrcRobot.get_PartNumber();
            //ProductDocument SrcRobotDoc = (ProductDocument)DSystem.DSDocument.Item(TarName + ".CATProduct");
            //TarName = TargetRobot.get_PartNumber();
            //ProductDocument TargetRobotDoc = (ProductDocument)DSystem.DSDocument.Item(TargetRobot.get_PartNumber() + ".CATProduct");
            Selection selection = DSystem.CDSActiveDocument.Selection;

            selection.Clear();
            //foreach (Operation soperation in robotTask.ChildrenActivities)
            //{
            //    selection.Add(soperation);
            //}
            selection.Add(robotTask);
            try
            {
                selection.Copy();
                selection.Clear();
                //selection = TargetRobotDoc.Selection;
                selection.Add(TargetrobotTask);
                selection.Paste();
            }
            catch (Exception e)
            {
                MessageBox.Show("应发了未知错误,请核实是否完全克隆后再删除原机器人! " + e.Message);
            }
        }
Exemple #2
0
        public Selection GetIRobotMotion(Form FM, DataType.Dsystem DSystem, int SelectType = 9, string Mess = "请选择一个机器人")
        {
            FM.WindowState = FormWindowState.Minimized;
            INFITF.Application CatApplication = DSystem.DSApplication;
            Selection          USelect        = null;

            try
            {
                ProcessDocument PPRP = DSystem.DSActiveDocument;
                if (PPRP == null)
                {
                    USelect = DSystem.CDSActiveDocument.Selection;
                }
                else
                {
                    USelect = PPRP.Selection;
                }
            }
            catch (Exception)
            {
            }
            USelect.Clear();
            var Result = USelect.SelectElement2(DataType.InputObjectType(SelectType), Mess, true);

            if (Result == "Cancel")
            {
                return(null);
            }
            if (USelect.Count < 1)
            {
                MessageBox.Show("请先选择对象后再点此命令!");
                return(null);
            }
            return(USelect);
        }
Exemple #3
0
        /// <summary>
        /// Delmia 在仿真示教模式下使用
        /// </summary>
        /// <param name="FM"></param>
        /// <param name="DSystem"></param>
        /// <returns></returns>
        public Selection GetInitTargetProduct(Form FM, DataType.Dsystem DSystem, int dType = 9, string Msg = "请选择初始化对象")
        {
            FM.WindowState = FormWindowState.Minimized;
            ProcessDocument PPRP    = DSystem.DSActiveDocument;
            Selection       USelect = null;

            if (PPRP == null)
            {
                return(null);
            }
            USelect = PPRP.Selection;
            USelect.Clear();
            var Result = USelect.SelectElement2(DataType.InputObjectType(dType), Msg, true);

            if (Result == "Cancel")
            {
                return(null);
            }
            if (USelect.Count < 1)
            {
                MessageBox.Show("请先选择对象后再点此命令!");
                return(null);
            }
            return(USelect);
        }
Exemple #4
0
        private void OutTargetListAix_Click(object sender, EventArgs e)
        {
            GloalForDelmia GFD = new GloalForDelmia();

            DStype = GFD.InitCatEnv(this);
            if (DStype.Revalue == -1)
            {
                return;
            }
            Selection Uselect     = GFD.GetIRobotMotion(this, DStype, 9, "请选择正确的产品数模作为坐标基准");
            Product   BaseProduct = null;

            if (Uselect == null && Uselect.Count < 1)
            {
                return;
            }
            BaseProduct = (Product)Uselect.Item2(1).Value;
            SPAWorkbench TheSPAWorkbench = (SPAWorkbench)DStype.CDSActiveDocument.GetWorkbench("SPAWorkbench"); // Default Get Coordxyz From Word

            try
            {
                Reference  basereference = Uselect.Item2(1).Reference;
                Measurable measurable    = TheSPAWorkbench.GetMeasurable(basereference);
                object[]   PointCoord    = new object[3];//{-99, -99, -99, -99, -99, -99, -99, -99, -99 };
                Uselect.Item2(1).GetCoordinates(PointCoord);
                measurable.GetCenter(PointCoord);
            }
            catch (Exception e1)
            {
                MessageBox.Show("发生未知错误:" + e1.Message);
            }
        }
Exemple #5
0
        /// <summary>
        /// 清空机器人Home预制坐标信息_Yecc
        /// </summary>
        /// <param name="FM"></param>
        /// <param name="DSystem"></param>
        /// <param name="product"></param>
        /// <param name="RobotName"></param>
        /// <param name="progressBar"></param>
        /// <param name="CreateCable"></param>
        public void ClearRobotHomeList(Form FM, DataType.Dsystem DSystem, Product product, String RobotName, ProgressBar progressBar, bool CreateCable = false)
        {
            //Workbench TheKinWorkbench = DSystem.CDSActiveDocument.GetWorkbench("KinematicsWorkbench");
            Mechanisms      cTheMechanisms = null;
            ProductDocument partDocument   = GetProductPath(product, DSystem, false);
            Selection       selection      = partDocument.Selection;

            selection.Clear();
            try
            {
                BasicDevice  basicDevice   = (BasicDevice)product.GetTechnologicalObject("BasicDevice");
                System.Array homePositions = null;
                //for (int i = 0; i < 100; i++) // add New Robot Home Position
                //{
                //    object[] HomePos = { 0, 0, 0, 0, 0, 0 };
                //    basicDevice.SetHomePosition("RobotHome_" + i, HomePos);
                //}
                basicDevice.GetHomePositions(out homePositions);
                int HomePosNum = homePositions.Length;
                if (HomePosNum > 1) //当对象运动机构数量>1时 清除全部机构对象
                {
                    foreach (HomePosition homePosition in homePositions)
                    {
                        selection.Add(homePosition);
                        //Array AtoolTip = null;
                        //homePosition.GetAssociatedToolTip(out AtoolTip);
                        //selection.Add(homePosition);
                    }
                    selection.Delete();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + ";请在帮助-》问题反馈与建议中反馈该问题,谢谢!");
                //选定的对象不存在任何运动机构
            }
            //Mechanisms TheMechanismsList = TheKinWorkbench.Mechanisms;
            RobGenericController Rgcr          = (RobGenericController)product.GetTechnologicalObject("RobGenericController");
            RobControllerFactory CRM           = (RobControllerFactory)product.GetTechnologicalObject("RobControllerFactory");
            GenericMotionProfile genericMotion = null;
            int ProfileCount = 0;

            Rgcr.GetMotionProfileCount(out ProfileCount);
            if (ProfileCount > 0)
            {
                string ProfileName = "DNBRobController";
                Rgcr.GetMotionProfile(ProfileName, out genericMotion);
            }
            InitController(Rgcr, CRM, 10, progressBar);
            Mechanism mechanism = cTheMechanisms.Add();
            //mechanism.FixedPart=
            ///RefDocument//mk:@MSITStore:F:\02%20我的知识库\05%20学习&总结资料\01%20CAA开发资料\V5Automation.chm::/online/CAAScdDmuUseCases/CAAKiiMechanismCreationSource.htm
            //string GetName = CRM.get_Name();
        }
Exemple #6
0
        public ProductDocument GetProductPath(Product Tproduct, DataType.Dsystem DStype, bool Value = false)
        {
            Documents CatDocuments = DStype.DSDocument;
            String    Path         = string.Empty;
            String    SPath        = string.Empty;
            String    Name         = Tproduct.get_PartNumber();

            //String NwProductName = Name + "_Fixture";
            try
            {
                ProductDocument DSPD = (ProductDocument)CatDocuments.Item(Name + ".CATProduct");
                return(DSPD);
            }
            catch (Exception)
            {
                //
            }
            return(null);
        }
Exemple #7
0
        private void reSelectRobotTask_Click(object sender, EventArgs e)
        {
            tagList.Clear();
            viatagList.Clear();
            processtagList.Clear();
            ProcessTaskAddress.Items.Clear();
            Pbar.Value = 0;
            Pbar.Step  = 10;
            GloalForDelmia GFD = new GloalForDelmia();

            DStype = GFD.InitCatEnv(this);
            if (DStype.Revalue == -1)
            {
                return;
            }
            this.TopMost     = false;
            this.WindowState = FormWindowState.Minimized;
            Selection Uselect   = GFD.GetIRobotMotion(this, DStype, 12, "请选择即将操作的Taglist对象");
            RobotTask robotTask = null;

            if (Uselect != null && Uselect.Count > 0)
            {
                try
                {
                    String GetName = string.Empty;
                    robotTask = (RobotTask)Uselect.Item2(1).Value;
                    GetName   = robotTask.get_Name();
                    selectedrobotTaskName.Text = GetName;
                    //GFD.ClearRobotHomeList(this, DStype, Usp, "Test", Pbar);
                    GFD.ReadTaskTagList(this, robotTask, TaskListA, TaskListB, Pbar, ref tagList, ref viatagList, ref processtagList);
                }
                catch
                {
                    MessageBox.Show("操作目标过程中发生未知错误,编号:0029874,在入口的帮助选项卡中反馈该问题!");
                }
            }
            //this.TopMost = true;
            //this.WindowState = FormWindowState.Maximized;
            this.WindowState   = FormWindowState.Normal;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.TopMost       = false;
        }
Exemple #8
0
        private void ProcessTaskAddress_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (robotTasks.Count < 1)
            {
                return;
            }
            String    GetName     = string.Empty;
            int       SelectIndex = ProcessTaskAddress.SelectedIndex;
            RobotTask srobotTask  = robotTasks[SelectIndex];

            GetName = srobotTask.get_Name();
            //selectedrobotTaskName.Text = GetName;
            //GFD.ClearRobotHomeList(this, DStype, Usp, "Test", Pbar);
            GloalForDelmia GFD = new GloalForDelmia();

            DStype = GFD.InitCatEnv(this);
            GFD.ReadTaskTagList(this, srobotTask, TaskListA, TaskListB, Pbar, ref tagList, ref viatagList, ref processtagList);
            this.WindowState   = FormWindowState.Normal;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.TopMost       = true;
        }
Exemple #9
0
        public void CreateRobotMoto(Form FM, DataType.Dsystem DSystem, Product product, String RobotName, ProgressBar progressBar, bool CreateCable = false)
        {
            Workbench  TheKinWorkbench = DSystem.CDSActiveDocument.GetWorkbench("KinematicsWorkbench");
            Mechanisms cTheMechanisms  = null;

            try
            {
                cTheMechanisms = (Mechanisms)product.GetTechnologicalObject("Mechanisms");
                if (cTheMechanisms.Count > 1) //当对象运动机构数量>1时 清除全部机构对象
                {
                    foreach (Mechanism item in cTheMechanisms)
                    {
                        cTheMechanisms.Remove(item); //Clear All Mechanisms
                    }
                }
            }
            catch (Exception)
            {
                //选定的对象不存在任何运动机构
            }
            //BasicDevice basicDevice = (BasicDevice)product.GetTechnologicalObject("BasicDevice");
            //Mechanisms TheMechanismsList = TheKinWorkbench.Mechanisms;
            RobGenericController Rgcr          = (RobGenericController)product.GetTechnologicalObject("RobGenericController");
            RobControllerFactory CRM           = (RobControllerFactory)product.GetTechnologicalObject("RobControllerFactory");
            GenericMotionProfile genericMotion = null;
            int ProfileCount = 0;

            Rgcr.GetMotionProfileCount(out ProfileCount);
            if (ProfileCount > 0)
            {
                string ProfileName = "DNBRobController";
                Rgcr.GetMotionProfile(ProfileName, out genericMotion);
            }
            InitController(Rgcr, CRM, 10, progressBar);
            Mechanism mechanism = cTheMechanisms.Add();
            //mechanism.FixedPart=
            ///RefDocument//mk:@MSITStore:F:\02%20我的知识库\05%20学习&总结资料\01%20CAA开发资料\V5Automation.chm::/online/CAAScdDmuUseCases/CAAKiiMechanismCreationSource.htm
            //string GetName = CRM.get_Name();
        }
Exemple #10
0
        /// <summary>
        /// 初始化软件环境及全局变量
        /// </summary>
        /// <param name="FM">当前From</param>
        /// <param name="SoftTarget">Catia/Delmia</param>
        /// <returns></returns>
        public DataType.Dsystem InitCatEnv(Form FM)
        {
            DataType.Dsystem   Dsvalue = new DataType.Dsystem();
            INFITF.Application DSApplication;
            Documents          DSDocument;

            INFITF.Document CDSActiveDocument;
            ProcessDocument DSActiveDocument;

            Process[] AllProcess = Process.GetProcessesByName("DELMIA");
            #region Vision Selection Model
            //if (AllProcess.Length > 1)
            //{
            //    try
            //    {
            //        // MessageBox.Show("当前打开超过1个Delmia,可能操控的Delmia非您需要的对象,请核实!");
            //        // IntPtr Ptr = AllProcess[2].MainWindowHandle;
            //        // string Pname = AllProcess[2].MainWindowTitle;
            //        //  int progid=  AllProcess[2].;
            //        // object Pobj = Marshal.GetActiveObject("Delmia.Application");
            //        //// object Tobj = Marshal.GetObjectForIUnknown(ptr2);
            //        // object Pobj0 = Marshal.GetActiveObject(progid.ToString());
            //        // DSApplication = (INFITF.Application)Pobj;
            //        // String tn = DSApplication.get_Caption();
            //    }
            //    catch (Exception)
            //    {
            //        throw;
            //    }
            //}
            #endregion
            try
            {
                DSApplication = (INFITF.Application)Marshal.GetActiveObject("Delmia.Application");
            }
            catch (Exception)
            {
                FM.WindowState   = FormWindowState.Normal;
                FM.StartPosition = FormStartPosition.CenterScreen;
                MessageBox.Show("未检测到打开的Delmia!,请重新运行Delmia!_" + AllProcess.Length);
                Dsvalue.Revalue = -1;
                return(Dsvalue);
                //throw;
            }
            try
            {
                DSApplication.set_Caption("正在运行锐锋快速建模工具!");
            }
            catch (Exception)
            {
                //  throw;
            }
            // 获取当前活动ProductDocument
            try
            {
                DSDocument        = (Documents)DSApplication.Documents;
                CDSActiveDocument = DSApplication.ActiveDocument;
                try
                {
                    DSActiveDocument = (ProcessDocument)CDSActiveDocument;
                }
                catch (Exception)
                {
                    DSActiveDocument = null;
                    //throw;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("未检测到活动Product,正在为您创建,请手动辅助完成!");
                Dsvalue.Revalue = -1;
                return(Dsvalue);
                //MessageBox.Show("未检测到活动Product,已自动为您创建对象!");
            }
            // 添加一个新零件
            Dsvalue.DSApplication     = DSApplication;
            Dsvalue.DSDocument        = DSDocument;
            Dsvalue.DSActiveDocument  = DSActiveDocument;
            Dsvalue.CDSActiveDocument = CDSActiveDocument;
            Dsvalue.Revalue           = 0;
            return(Dsvalue);
        }