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)
            {
            }
        }
 /// <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)
        {
            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();
        }
Exemple #4
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);
        }
        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());
            //}
        }