示例#1
0
        private void ZoneModlueM(string Rob1, TxObjectList Rob1Sigs, string Rob2, TxObjectList Rob2Sigs, string[] Zone, ITxPlcModule p1)
        {
            TxPlcExpressionBuilder eb1 = new TxPlcExpressionBuilder();

            try
            {
                foreach (string z in Zone)
                {
                    string str1 = textBox1.Text.Replace("Rob", Rob1).Replace("X", z);
                    string str2 = textBox3.Text.Replace("Rob", Rob2).Replace("X", z);
                    string str3 = textBox2.Text.Replace("Rob", Rob2).Replace("X", z);
                    string str4 = textBox2.Text.Replace("Rob", Rob1).Replace("X", z);

                    eb1.Add(FindSig(Rob1Sigs, str1, true));
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(FindSig(Rob2Sigs, str2, true));
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(FindSig(Rob2Sigs, str3, false));
                    p1.AddEntry(FindSig(Rob1Sigs, str4, false), eb1.Expression);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
示例#2
0
        private void ZoneLBS(string Rob1, TxObjectList Rob1Sigs, string Rob2, TxObjectList Rob2Sigs, string[] Zone, TxPlcLogicBehavior LB)
        {
            TxPlcExpressionBuilder eb1 = new TxPlcExpressionBuilder();

            try
            {
                foreach (string z in Zone)
                {
                    string str1 = textBox12.Text.Replace("X", z);
                    string str2 = textBox11.Text.Replace("X", z);

                    ITxPlcLogicBehaviorEntry en1 = SegEn(LB, FindSig(Rob1Sigs, str1, true));
                    ITxPlcLogicBehaviorEntry en2 = SegEn(LB, FindSig(Rob2Sigs, str2, true));
                    ITxPlcLogicBehaviorEntry en3 = SegEn(LB, FindSig(Rob2Sigs, str1, true));

                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(en1);
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(TxPlcExpressionOperator.LeftParenthesis);
                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(en2);
                    eb1.Add(TxPlcExpressionOperator.Or);
                    eb1.Add(en3);
                    eb1.Add(TxPlcExpressionOperator.RightParenthesis);

                    ITxPlcLogicBehaviorExit ex1 = SegEx(LB, FindSig(Rob1Sigs, str2, false), eb1.Expression);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
示例#3
0
        private void ZoneLBM(string Rob1, TxObjectList Rob1Sigs, string Rob2, TxObjectList Rob2Sigs, string[] Zone, TxPlcLogicBehavior LB)
        {
            TxPlcExpressionBuilder eb1 = new TxPlcExpressionBuilder();

            try
            {
                foreach (string z in Zone)
                {
                    string str1 = tb_ZoneReq.Text.Replace("Rob", Rob1).Replace("X", z);
                    string str2 = tb_Zonefree.Text.Replace("Rob", Rob2).Replace("X", z);
                    string str3 = tb_ZoneEnable.Text.Replace("Rob", Rob2).Replace("X", z);
                    string str4 = tb_ZoneEnable.Text.Replace("Rob", Rob1).Replace("X", z);


                    ITxPlcLogicBehaviorEntry en1 = SegEn(LB, FindSig(Rob1Sigs, str1, true));
                    ITxPlcLogicBehaviorEntry en2 = SegEn(LB, FindSig(Rob2Sigs, str2, true));
                    ITxPlcLogicBehaviorEntry en3 = SegEn(LB, FindSig(Rob2Sigs, str3, false));

                    eb1.Add(en1);
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(en2);
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(en3);

                    ITxPlcLogicBehaviorExit ex1 = SegEx(LB, FindSig(Rob1Sigs, str4, false), eb1.Expression);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
示例#4
0
        private void AddToEditor_bt_Click(object sender, EventArgs e)
        {
            Dictionary <ITxRoboticOperation, string> operationdic = new Dictionary <ITxRoboticOperation, string>();

            //遍历获取所有operation
            TxObjectList oplist = TxApplication.ActiveDocument.OperationRoot.GetAllDescendants(new TxTypeFilter(typeof(ITxRoboticOperation)));

            if (!(opname_tb.Text == ""))
            {
                foreach (ITxRoboticOperation op in oplist)
                {
                    //if (op.Name== opname_tb.Text)
                    //{
                    //    TxApplication.ViewersManager.PathEditorViewer.AddOperation(op);
                    //}
                    if (op.Name == opname_tb.Text)
                    {
                        operationdic.Add(op, op.Name);
                    }
                }
                foreach (ITxRoboticOperation item in operationdic.Keys)
                {
                    TxApplication.ViewersManager.PathEditorViewer.AddOperation(item);
                }
            }
            else
            {
                MessageBox.Show("Please define the searching text by picking up operation or entering its name!");
            }
        }
示例#5
0
        /// <summary>
        /// Load the manufacturing features by their name to the study
        /// </summary>
        private void LoadMfgByName()
        {
            TxObjectList mfgsToLoad = new TxObjectList();

            TxEmsCacheManager emsCacheManager = new TxEmsCacheManager();

            QueryEmsCache(emsCacheManager, "wpMfgLibrary", "children", planningObject, null);

            TxObjectList mfgsInLibrary = planningObject.GetField("children") as TxObjectList;

            QueryEmsCache(emsCacheManager, "wpMfgLibrary", "name", null, mfgsInLibrary);

            foreach (ITxPlanningObject mfg in mfgsInLibrary)
            {
                string name = mfg.GetField("name") as string;
                if (MfgCollection.Contains(name))
                {
                    mfgsToLoad.Add(mfg);
                }
            }

            if (mfgsToLoad.Count > 0)
            {
                TxDocumentEx document = new TxDocumentEx();
                document.LoadComplete(mfgsToLoad, true);
                TxMessageBox.Show($"{mfgsToLoad.Count} Mfgs loaded!", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
            }
            else
            {
                TxMessageBox.Show("No wanted Mfgs found in library", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
示例#6
0
        private void button7_Click(object sender, EventArgs e)
        {
            ITxRoboticLocationOperation ro = txObjEditBoxCtrl1.Object as ITxRoboticLocationOperation;
            ITxTypeFilter objFilter        = new TxTypeFilter(typeof(ITxRoboticLocationOperation));
            TxObjectList  obj = ro.ParentRoboticOperation.GetAllDescendants(objFilter);

            try
            {
                for (int i = 0; i < obj.Count; i++)
                {
                    if (obj[i + 1] is TxWeldLocationOperation)
                    {
                        string str = ";-- " + obj[i + 1].Name + " --";
                        ITxRoboticOperation rop = obj[i] as ITxRoboticOperation;
                        if (rop.Commands.Count == 0)
                        {
                            rop.CreateCommand(new TxRoboticCommandCreationData(str));
                        }
                        else
                        {
                            TxRoboticCommand rc = rop.Commands[rop.Commands.Count - 1] as TxRoboticCommand;
                            if (!rc.Text.Contains("_ps_"))
                            {
                                rop.CreateCommand(new TxRoboticCommandCreationData(str));
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
示例#7
0
        private TxPlcSignalBase FindSig(TxObjectList RobSigs, string Signame, bool input)
        {
            if (input) //无论INPUT值,无论SIG是FROMROBOT还是TOROBOT,返回都是SIG???,那么IF、内嵌IF意义何在
            {          //根据INPUT的BOOL值来确定要返回的是FROMROBOT还是TOROBOT。
                foreach (ITxPlcSignal sig in RobSigs)
                {
                    if (sig.Name.Contains(Signame) && sig is TxPlcFromRobotSignal)
                    {
                        return((TxPlcSignalBase)sig);
                    }
                }
            }
            else
            {
                foreach (ITxPlcSignal sig in RobSigs)
                {
                    if (sig.Name.Contains(Signame) && sig is TxPlcToRobotSignal)
                    {
                        return((TxPlcSignalBase)sig);
                    }
                }
            }
            //=========|=========|=========|=========|=========|=========|=========|===

            //=========|=========|=========|=========|=========|=========|=========|===
            string str = "";

            if (RobSigs.Count > 0)
            {
                str = RobSigs[0].Name.Split('_')[0];
            }
            MessageBox.Show(str + " 机器人信号表中没有找到信号-" + str + Signame);
            return(null);
        }
示例#8
0
        private void ZoneModlueS(string Rob1, TxObjectList Rob1Sigs, string Rob2, TxObjectList Rob2Sigs, string[] Zone, ITxPlcModule p1)
        {
            TxPlcExpressionBuilder eb1 = new TxPlcExpressionBuilder();

            try
            {
                foreach (string z in Zone)
                {
                    string str1 = textBox12.Text.Replace("X", z);
                    string str2 = textBox11.Text.Replace("X", z);

                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(FindSig(Rob1Sigs, str1, true));
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(TxPlcExpressionOperator.LeftParenthesis);
                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(FindSig(Rob2Sigs, str2, false));
                    eb1.Add(TxPlcExpressionOperator.Or);
                    eb1.Add(FindSig(Rob2Sigs, str1, true));
                    eb1.Add(TxPlcExpressionOperator.RightParenthesis);
                    p1.AddEntry(FindSig(Rob1Sigs, str2, false), eb1.Expression);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
示例#9
0
        /// <summary>
        /// Check the selection if it is a robot with more than three joints.
        /// Only the first object in the list will be checked.
        /// It is assumed that a device with more than three joints represents a robot.
        /// </summary>
        /// <param name="objects">The list of objects</param>
        private void CheckSelection(TxObjectList objects)
        {
            bool flag = false;

            if (objects.Count == 1)
            {
                if (objects[0] is ITxRobot robot)
                {
                    if ((robot as ITxDevice).DrivingJoints.Count > 3)
                    {
                        flag = true;
                    }
                }
            }
            _enable = flag;
        }
示例#10
0
        public override void OnInitTxForm()
        {
            base.OnInitTxForm();
            TxObjectList selectedObjects = TxApplication.ActiveSelection.GetItems();

            if (selectedObjects.Count > 0)
            {
                ITxObject firstObject = selectedObjects[0];
                if (firstObject is TxRobot)
                {
                    m_robotPicker.Object = firstObject;
                    UpdateUI();
                }
            }
            m_robotPicker.Focus();
        }
        private void OnAddSelectedPathsToViewerExecuted(object obj)
        {
            TxObjectList selectedOperations = TxApplication.ActiveSelection.GetFilteredItems(new TxTypeFilter(typeof(ITxRoboticOperation)));

            if (selectedOperations == null || selectedOperations.Count == 0)
            {
                return;
            }
            foreach (ITxCompoundOperation operation in selectedOperations)
            {
                TxObjectList locations = operation.GetAllDescendants(new TxTypeFilter(typeof(ITxRoboticLocationOperation)));
                foreach (TxObjectBase location in locations)
                {
                    locationOperations.Add(new RoboticLocationViewModel(location, operation.Name, operation.Id));
                }
            }
        }
        /// <summary>
        /// Opens the machine data directory of the selected robot
        /// </summary>
        internal static void OpenMachineDataDirectory()
        {
            TxObjectList selectedObjects = TxApplication.ActiveSelection.GetItems();

            if (selectedObjects.Count == 1)
            {
                if (selectedObjects[0] is ITxRobot robot)
                {
                    string path = robot.GetMachineDataDirectory();

                    if (RwFileAndDirectoryUtilities.DoesDirectoryExist(path))
                    {
                        Process.Start("explorer.exe", path);
                    }
                    else
                    {
                        throw new TxArgumentException($"The directory {path} does not exist!");
                    }
                }
            }
        }
示例#13
0
        /// <summary>
        /// Add the selected items to the export collection
        /// </summary>
        private void AddMfgsToCollection()
        {
            if (TxApplication.ActiveDocument.Selection == null || TxApplication.ActiveDocument.Selection.Count == 0)
            {
                return;
            }

            TxObjectList selectedMfgs = TxApplication.ActiveDocument.Selection.GetFilteredItems(new TxTypeFilter(typeof(TxMfgFeature)));

            if (selectedMfgs == null || selectedMfgs.Count == 0)
            {
                return;
            }

            foreach (TxMfgFeature selectedMfg in selectedMfgs)
            {
                if (!Mfgs.Contains(selectedMfg))
                {
                    Mfgs.Add(selectedMfg);
                }
            }
        }
示例#14
0
 /// <summary>
 /// 添加目标operation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button4_Click(object sender, EventArgs e)
 {
     foreach (ITxObject obj in TxApplication.ActiveSelection.GetAllItems())
     {
         try
         {
             if (obj is ITxCompoundOperation)
             {
                 ITxCompoundOperation cop     = obj as ITxCompoundOperation;
                 TxTypeFilter         tp      = new TxTypeFilter(typeof(ITxRoboticOperation));
                 TxObjectList         objlist = cop.GetAllDescendants(tp);
                 foreach (ITxObject obj1 in objlist)
                 {
                     txObjGridCtrl_targetLocation.AppendObject(obj1);
                 }
             }
         }
         catch
         {
         }
     }
 }
        public override void Execute(object cmdParams)
        {
            ////遍历获取所有机器人列表
            //TxObjectList rolist = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(TxRobot)));

            //拾取机器人
            TxObjectList rolist = TxApplication.ActiveSelection.GetFilteredItems(new TxTypeFilter(typeof(TxRobot)));

            foreach (TxRobot robot in rolist)
            {
                //创建机器人program
                ITxRoboticProgram RobotProgram = TxApplication.ActiveDocument.RoboticProgramRoot.CreateProgram(new TxRoboticProgramCreationData(robot));
                RobotProgram.Name = robot.Name + "_Program";

                //将机器人program加载到path editor中
                TxApplication.ViewersManager.PathEditorViewer.SetRoboticProgram(RobotProgram);

                //将机器人的所有op添加到robot program中
                //TxObjectList rplist = robot.GetAllDescendants(new TxTypeFilter(typeof(ITxRoboticOperation)));
                TxObjectList rplist = robot.SimulatingOperations;
                foreach (ITxRoboticOperation item in rplist)
                {
                    ITxRoboticProgramElement txRoboticProgramElement = item as ITxRoboticProgramElement;
                    RobotProgram.AddElement(txRoboticProgramElement);
                    if (txRoboticProgramElement.Name.ToUpper() == "MAIN" | txRoboticProgramElement.Name.ToUpper() == "CELL")
                    {
                        RobotProgram.SetElementNumber(txRoboticProgramElement, 125);
                    }
                }

                //将当前robot program设置为default program,即下载当前program到PS robot中
                ITxRobot         txRobot          = robot as ITxRobot;
                TxRoboticProgram txRoboticProgram = RobotProgram as TxRoboticProgram;

                txRobot.DefaultProgram = txRoboticProgram;
            }
        }
示例#16
0
        /// <summary>
        /// Load the manufacturing features by their name to the study
        /// </summary>
        private void LoadMfgByName()
        {
            /*
             * Thanks to Siemens API Team for the support
             * https://community.plm.automation.siemens.com/t5/Tecnomatix-Developer-Forum/Tx13-0-Import-Mfg/m-p/519783#M1240
             */
            TxObjectList mfgsToLoad = new TxObjectList();

            TxEmsCacheManager emsCacheManager = new TxEmsCacheManager();

            QueryEmsCache(emsCacheManager, "wpMfgLibrary", "children", planningObject, null);

            TxObjectList mfgsInLibrary = planningObject.GetField("children") as TxObjectList;

            QueryEmsCache(emsCacheManager, "wpMfgLibrary", "name", null, mfgsInLibrary);

            foreach (ITxPlanningObject mfg in mfgsInLibrary)
            {
                string name = mfg.GetField("name") as string;
                if (MfgCollection.Contains(name))
                {
                    mfgsToLoad.Add(mfg);
                }
            }

            if (mfgsToLoad.Count > 0)
            {
                TxDocumentEx document = new TxDocumentEx();
                document.LoadComplete(mfgsToLoad, true);
                TxMessageBox.Show($"{mfgsToLoad.Count} Mfgs loaded!", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
            }
            else
            {
                TxMessageBox.Show("No wanted Mfgs found in library", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
示例#17
0
 /// <summary>
 /// Check the remaining selection if it contains only one item and if it is a robot with more than three axis
 /// </summary>
 protected override void OnSelectionItemsRemoved(TxObjectList objects)
 {
     CheckSelection(TxApplication.ActiveSelection.GetAllItems());
 }
示例#18
0
 /// <summary>
 /// Disable the command if items are added to the selection
 /// </summary>
 protected override void OnSelectionItemsAdded(TxObjectList objects)
 {
     _enable = false;
 }
示例#19
0
 /// <summary>
 /// Query the eMServer fields
 /// </summary>
 /// <param name="emsCacheManager">Cache manager for emServer fields</param>
 /// <param name="index">The string indexer, normally "wpMfgLibrary"</param>
 /// <param name="attribute">The attribue for setting on eMServer cached field</param>
 /// <param name="planningObject">The planning object, here it is the MfgLibrary</param>
 /// <param name="collection">The collection with required objects, in this case the mfg names</param>
 private static void QueryEmsCache(TxEmsCacheManager emsCacheManager, string index, string attribute, ITxPlanningObject planningObject, TxObjectList collection)
 {
     emsCacheManager.Clear();
     emsCacheManager[index].SetAttributes(attribute);
     if (planningObject != null && collection == null)
     {
         emsCacheManager[index].SetRootObject(planningObject);
     }
     else if (planningObject == null && collection != null)
     {
         emsCacheManager[index].SetRootObjects(collection);
     }
     emsCacheManager.CacheData();
 }
示例#20
0
        public override void Execute(object cmdParams)
        {
            if (!MinoApi.LicenseCheck.LicenceCheck())// 20180427
            {
                return;
            }

            //get the root of physical//all physical
            TxPhysicalRoot physRoot = TxApplication.ActiveDocument.PhysicalRoot;
            //need filter.robot
            ITxTypeFilter objFilter = new TxTypeFilter(typeof(TxRobot));
            //return all descendants by filter
            TxObjectList objst = physRoot.GetAllDescendants(objFilter);

            //
            TxApplication.ActiveUndoManager.StartTransaction();

            MinoApi.MinoCEEForm rz = new MinoApi.MinoCEEForm();
            //
            rz.Robots = new TxRobot[objst.Count];

            if (objst.Count > 0)
            {
                TxRobot tr = objst[0] as TxRobot;
                if (tr.Controller.Name == "Fanuc-Rj")
                {
                    rz.radioButton2.Checked = true;
                }
                else
                {
                    rz.radioButton1.Checked = true;
                }
            }

            List <TxRobot> Roblist = new List <TxRobot>();

            foreach (TxRobot robot in objst)
            {
                Roblist.Add(robot);
            }
            Roblist = Roblist.OrderBy(s => s.Name).ToList();

            int c = objst.Count, i = 0;

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            dataGridViewCellStyle1.Alignment             = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle1.Font                  = new System.Drawing.Font("宋体", 11F);
            rz.dataGridView3.Columns[0].HeaderCell.Style = dataGridViewCellStyle1;

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Menu;
            DataGridViewComboBoxColumn col = rz.dataGridView2.Columns[0] as DataGridViewComboBoxColumn;

            foreach (TxRobot robot in Roblist)
            {
                rz.Robots[i] = robot;
                DataGridViewTextBoxColumn dc = new System.Windows.Forms.DataGridViewTextBoxColumn();
                dc.HeaderText       = robot.Name;
                dc.Name             = "Column" + i + 1;
                dc.HeaderCell.Style = dataGridViewCellStyle1;
                dc.DefaultCellStyle = dataGridViewCellStyle1;
                dc.SortMode         = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;

                rz.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                    dc
                });

                rz.dataGridView3.Rows.Add();
                rz.dataGridView3.Rows[i].Cells[0].Value = robot.Name;
                rz.dataGridView1.Rows.Add();
                rz.dataGridView1.Rows[i].Cells[i].Style = dataGridViewCellStyle2;

                DataGridViewTextBoxColumn dc1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
                dc1.HeaderText       = robot.Name;
                dc1.Name             = "Column" + i + 1;
                dc1.HeaderCell.Style = dataGridViewCellStyle1;
                dc1.DefaultCellStyle = dataGridViewCellStyle1;
                dc1.SortMode         = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
                rz.dataGridView8.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                    dc1
                });
                col.Items.Add(robot.Name);
                i = i + 1;
            }

            TxApplication.ActiveUndoManager.EndTransaction();
            rz.dataGridView8.Rows.Add();
            rz.Show();
        }
示例#21
0
 /// <summary>
 /// Create a new instance of the logical group cration data
 /// </summary>
 public RwLogicalGroupCreationData()
 {
     Items = new TxObjectList();
 }
        private void cUiContinuousButton1_Click(object sender, EventArgs e)
        {
            //Snapshots can be retrieved from under the physical root using a type filter that will filter out only snapshots.
            TxTypeFilter filter    = new TxTypeFilter(typeof(TxSnapshot));
            TxObjectList snapshots = TxApplication.ActiveDocument.PhysicalRoot.GetDirectDescendants(filter);

            foreach (TxSnapshot s in snapshots)
            {
                string st = s.Name;
            }
            //Retrieve a selected snapshot (existing functionality)
            TxSnapshot   snapshot = null;
            TxObjectList selList  = TxApplication.ActiveSelection.GetItems();

            if (selList.Count == 1)
            {
                snapshot = selList[0] as TxSnapshot;
            }
            //The snapshots creation data class should be created with the new snapshot name, and then sent to the CreateSnapshot function that will create it under the root.
            //The current state of the Graphic Viewer will be captured in the snapshot.
            TxSnapshotCreationData creationData = new TxSnapshotCreationData("snapshotName");

            TxApplication.ActiveDocument.PhysicalRoot.CreateSnapshot(creationData);

            //The Update() function of the TxSnapshot class should be used.
            //The current state of the Graphic Viewer will be captured in the snapshot.

            snapshot = null;
            selList  = TxApplication.ActiveSelection.GetItems();
            if (selList.Count == 1)
            {
                snapshot = selList[0] as TxSnapshot;
            }
            if (snapshot != null)
            {
                snapshot.Update();
            }

            //Apply an existing snapshot(new functionality)
            //The Apply() function of the TxSnapshot class should be used, with a parameters class that describes what aspect of the snapshot to apply.
            //The TxApplySnapshotParams class is a new data class to hold the apply preferences.
            //The user should configure the following parameters (the default for all parameters is false):
            //DevicePoses - Specifies whether applying the snapshot should affect the poses of the devices(should it jump the devices to the poses that they are in, in the snapshot).
            //ObjectsAttachments - Specifies whether applying the snapshot should affect the attachments of the objects(should it attach the attachments to the objects that they are attached to in the snapshot).
            //ObjectsColor - Specifies whether applying the snapshot should affect the color of the objects(should it change objects' colors that they are in, in the snapshot).
            //ObjectsLocation - Specifies whether applying the snapshot should affect the location of the objects (should it move the objects to the locations that they are in, in the snapshot).
            //ObjectsViewingMode - Specifies whether applying the snapshot should affect the viewing mode of the objects(should it change the viewing mode of the objects, according to the state that they are in, in the snapshot).
            //ObjectsVisibility - Specifies whether applying the snapshot should affect the visibility of the objects(should it blank/display the objects, according to the state that they are in, in the snapshot).
            //PMIsScale - Specifies whether applying the snapshot should affect the scaling of PMIs(should it change the scaling of PMIs, according to the state that they are in, in the snapshot).
            //PointOfView - Specifies whether applying the snapshot should affect the point of view.
            //Following is code for configuring the parameters and applying the snapshot:
            TxApplySnapshotParams parameters = new TxApplySnapshotParams();

            parameters.DevicePoses        = true;
            parameters.ObjectsAttachments = true;
            parameters.ObjectsColor       = true;
            parameters.ObjectsLocation    = true;
            parameters.ObjectsViewingMode = true;
            parameters.ObjectsVisibility  = true;
            parameters.PMIsScale          = true;
            parameters.PointOfView        = true;
            snapshot.Apply(parameters);

            TxObjectList objects;

            // the user fills the objectList
            objects = null;
            TxClipboardData clipboardData = new TxClipboardData();

            clipboardData.Objects = objects;
            // convert the data to IDataObject that will be set in the DoDragDrop:
            TxDragAndDropClipboardServices services = new TxDragAndDropClipboardServices();
            IDataObject dataObject;

            services.CopyToDataObject(clipboardData, out dataObject);
            // start a drag and drop operation:
            DoDragDrop(dataObject, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);


            // Prepare the cylinder creation data
            TxCylinderCreationData cd = new TxCylinderCreationData();

            cd.Name   = "myCylinder";
            cd.Base   = new TxVector(0, 0, 0);
            cd.Top    = new TxVector(0, 0, 300);
            cd.Radius = 100;
            // Get the first item from the selection
            TxObjectList        selectedItems = TxApplication.ActiveSelection.GetItems();
            ITxGeometryCreation geoParent     = selectedItems[0] as ITxGeometryCreation;

            // If the selected item is of a type under which a geometry can be created
            // (that is, if it implements ITxGeometryCreation), create the cylinder
            // under it.
            if (geoParent != null)
            {
                geoParent.CreateSolidCylinder(cd);
            }

            // Get the first item from the selection.

            TxObjectList       selectedList = TxApplication.ActiveSelection.GetItems();
            ITxLocatableObject obj          = selectedList[0] as ITxLocatableObject;
            // If the item is locatable, write its location to the output window.
            //if (loc != null)
            //{
            //    TxTransformation loc = obj.AbsoluteLocation;

            //    Debug.Write("\n\nThe location of " + ((ITxObject)obj).Name + " as a matrix:");
            //    Debug.Write("\n" + loc.ToString());
            //    Debug.Write("\n\nThe translation of " + ((ITxObject)obj).Name + ":");
            //    Debug.Write("\n" + loc.Translation.ToString());
            //    Debug.Write("\n\nThe RPY rotation of " + ((ITxObject)obj).Name + ":");
            //    Debug.Write("\n" + loc.RotationRPY_XYZ.ToString());
            //}
        }
示例#23
0
 /// <summary>
 /// Check the new selection if it contains only one item and if it is a robot with more than three axis
 /// </summary>
 protected override void OnSelectionItemsSet(TxObjectList objects)
 {
     CheckSelection(objects);
 }
 /// <summary>
 /// Create a new instance of the logical group view model
 /// </summary>
 public RwLogicalGroupViewModel()
 {
     Items = new TxObjectList();
 }
示例#25
0
        public TxPlcLogicBehavior CreatNewLB(string name)
        {
            TxTypeFilter objF1 = new TxTypeFilter(typeof(TxCompoundResource));
            TxObjectList objs  = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(objF1);
            TxObjectList objs1 = new TxObjectList();
            bool         b     = false;

            foreach (TxCompoundResource c in objs)
            {
                if (c.Name == "LB_Main")
                {
                    b = true;
                    objs1.Add(c);
                    TxTypeFilter objF2 = new TxTypeFilter(typeof(TxComponent));
                    foreach (ITxObject obj in c.GetAllDescendants(objF2))
                    {
                        if (obj.Name == "LB_" + name)
                        {
                            obj.Delete();
                        }
                    }
                    break;
                }
            }

            if (!b)
            {
                objs1.Add(TxApplication.ActiveDocument.PhysicalRoot.CreateCompoundResource(new TxCompoundResourceCreationData("LB_Main")));
            }

            TxApplication.ActiveSelection.Clear();
            TxApplication.ActiveSelection.AddItems(objs1);

            ITxObject                     m_logicResource;
            TxPlcLogicBehavior            txPlcLogicBehavior;
            TxNewPartResourceParametersEx txNewPartResourceParametersEx = new TxNewPartResourceParametersEx();

            txNewPartResourceParametersEx.Type         = "PmToolPrototype";
            txNewPartResourceParametersEx.TypeNiceName = "LB_" + name;
            TxApplication.CommandsManager.ExecuteCommand("ComponentOperations.NewResource", txNewPartResourceParametersEx);
            m_logicResource = txNewPartResourceParametersEx.CreatedObject;

            TxComponentEx.ConnectComponentToDatabase(m_logicResource);
            TxLogicResourceEx.ConnectLogicResource(m_logicResource);
            TxPlcLogicBehaviorCreationData creationData2 = new TxPlcLogicBehaviorCreationData();
            TxComponent txComponent = m_logicResource as TxComponent;

            txPlcLogicBehavior = txComponent.CreateLogicBehavior(creationData2);
            TxLinearUnitEnumEx  linearUnits  = TxLinearUnitEnumEx.Milimeter;
            TxAngularUnitEnumEx angularUnits = TxAngularUnitEnumEx.Radian;

            TxUnitsOptions.TxLinearUnit  linearUnit  = TxApplication.Options.Units.LinearUnit;
            TxUnitsOptions.TxAngularUnit angularUnit = TxApplication.Options.Units.AngularUnit;
            switch (linearUnit)
            {
            case TxUnitsOptions.TxLinearUnit.Millimeter:
                linearUnits = TxLinearUnitEnumEx.Milimeter;
                break;

            case TxUnitsOptions.TxLinearUnit.Centimeter:
                linearUnits = TxLinearUnitEnumEx.Centimeter;
                break;

            case TxUnitsOptions.TxLinearUnit.Meter:
                linearUnits = TxLinearUnitEnumEx.Meter;
                break;

            case TxUnitsOptions.TxLinearUnit.Inch:
                linearUnits = TxLinearUnitEnumEx.Inch;
                break;

            case TxUnitsOptions.TxLinearUnit.Foot:
                linearUnits = TxLinearUnitEnumEx.Foot;
                break;
            }
            switch (angularUnit)
            {
            case TxUnitsOptions.TxAngularUnit.Degree:
                angularUnits = TxAngularUnitEnumEx.Degree;
                break;

            case TxUnitsOptions.TxAngularUnit.Radian:
                angularUnits = TxAngularUnitEnumEx.Radian;
                break;
            }
            TxLogicBehaviorEx.SetLogicBehaviorUnits(txPlcLogicBehavior, linearUnits, angularUnits);
            return(txPlcLogicBehavior);
        }
 public override void Execute(object cmdParams)
 {
     TxObjectList objlist = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(TxPlcSignalBase)));
 }