美文网首页狮猿社Tecnomatix_PDPS
Tecnomatix PDPS 机器人自动避障

Tecnomatix PDPS 机器人自动避障

作者: 锦囊喵 | 来源:发表于2020-03-02 15:01 被阅读0次

PDF下载链接

A. Source Code: Main program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Planning;
using Tecnomatix.Engineering.DataTypes;
using Tecnomatix.Engineering.Olp;
using Tecnomatix.Engineering.Olp.OLP_Utilities;
using System.Collections;
namespace TecnomatixTesting1
{
    public class TxHelloWorld : TxButtonCommand
    {
         
        // Creation of constants
        static TxDocument TxStudy = TxApplication.ActiveDocument;
        static TxOperationRoot TxOpRoot = TxApplication.ActiveDocument.OperationRoot;
        static TxNoTypeFilter TxNoFilter = new TxNoTypeFilter();
        static TxTypeFilter OperationFilter = new TxTypeFilter(typeof(TxCompoundOperation));
        static TxTypeFilter LocationFilter = new TxTypeFilter(typeof(ITxRoboticLocationOperation));
        static TxTypeFilter IV_Filter = new TxTypeFilter(typeof(TxInterferenceVolume));
        //Path where the .CSV is placed (output)
        static string savePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        string OutputDirectory = savePath + @"\Distance.csv";
        public override string Category
        {
            get
            {
                return StringTable.CATEGORY;
            }
        }
        public override void Execute(object cmdParams)
        {
            
            #region MinimalDistance
            TxObjectList InterferenceVolumes =
TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(IV_Filter);
            TxObjectList ViaLocations =
TxApplication.ActiveDocument.OperationRoot.GetAllDescendants(LocationFilter);
            TxObjectList ClosestViaLocation = new TxObjectList();
            TxObjectList Robots = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new
TxTypeFilter(typeof(TxRobot)));
            var csv = new StringBuilder(); //Declare before loop
            csv.AppendLine("\"sep=;\""); //Specifies the separating sign in the .CSV‐file
            TxObjectList Command = TxApplication.ActiveDocument.OperationRoot.GetAllDescendants(new
TxTypeFilter(typeof(ITxRoboticLocationOperation)));
            if (InterferenceVolumes != null)
            {
                int j = 0; //Counter for Interference Volumes
                int r = 1; //counter for Zones
                int a = 0; //Counter for ViaLocations
                int t = 0; //counter for writing ViaLocations on Process Simulate and .CSV
                string[,] Info = new string[Command.Count, 6]; //Array to save all generated data
(i,j), all VL "i" will have "j" properties assigned
                TxObjectList VLocation = new TxObjectList();
                foreach (TxInterferenceVolume Intervol in InterferenceVolumes)
                {
                    ITxDisplayableObject DisplayableInterferenceVolume =
(ITxDisplayableObject)InterferenceVolumes[j]; //Prevents error when calculating minimal distance by
making sure the interference volume is being displayed
                    DisplayableInterferenceVolume.Display();
                    // variables for generating the Minimal Distance measure
                    double ActualDistance = 0; //Unit: [mm]. Will be the return value from
GetMinimalDistance
                    TxVector PointOnIV = new TxVector();
                    TxVector PointOnViaPoint = new TxVector();
                    ITxLocatableObject IV_Location = Intervol as ITxLocatableObject;
                    TxObjectList InterferenceHoldingObjects = Intervol.HoldingObjects; //Gets the two
robots that generated the segment
                    // TODO: create a for loop to avoid having repetitive lines
                    ITxRoboticOrderedCompoundOperation Segment1 = InterferenceHoldingObjects[0] as
ITxRoboticOrderedCompoundOperation;
                    ITxRoboticOrderedCompoundOperation Segment2 = InterferenceHoldingObjects[1] as
ITxRoboticOrderedCompoundOperation;
                    ITxRobot Robot1 = Segment1.Robot;
                    ITxRobot Robot2 = Segment2.Robot;
                    TxObjectList TxORobot = new TxObjectList();
                    TxORobot.Add(Robot1);
TxORobot.Add(Robot2);
                    int q = 0; // counter for holding robots on a segment
                    foreach (ITxObjectCollection Segment in InterferenceHoldingObjects)
                    {
                        TxObjectList ViaLocation = Segment.GetAllDescendants(LocationFilter);
                        TxRobot Robot = TxORobot[q] as TxRobot;
                        q++;
                        TxObjectList RobotTx = new TxObjectList();
                        TxObjectList IV = new TxObjectList();
                        double[] Distance = new double[ViaLocation.Count];
                        string[] Text = new string[ViaLocation.Count];
                        TxRoboticCompositeCommandStringElement StringElement = new
TxRoboticCompositeCommandStringElement();
                        TxRoboticCompositeCommandCreationData CommandCreationData = new
TxRoboticCompositeCommandCreationData();
                        ITxRoboticLocationOperation VLocCommand;
string[] Separator = { "@" };
                        int i = 0;
                        var InIV = 0;
                        foreach (ITxLocationOperation ViaLoc in ViaLocation)
                        {
                            TxOlpControllerUtilities utility = new TxOlpControllerUtilities();
                            ITxRoboticControllerServices services =
utility.GetInterfaceImplementationFromController(Robot.Controller.Name,
typeof(ITxRoboticControllerServices), typeof(TxControllerAttribute), "ControllerName") as
ITxRoboticControllerServices;
                            TxJumpToLocationData data = new TxJumpToLocationData();
                            services.Init(Robot);
services.JumpToLocation(ViaLoc as ITxLocationOperation, data);
                            TxApplication.RefreshDisplay();
                            ITxLocatableObject ViaPointLocation = Robot.Collection as
ITxLocatableObject;
                            ITxLocatableObject ViaPointLocation1 = ViaPointLocation.Collection as
ITxLocatableObject;
                            IV_Location.GetMinimalDistance(ViaPointLocation1, out ActualDistance, out
PointOnIV, out PointOnViaPoint);
                            //checks for pairs of robots same as the current selection, if not find
anything then new zone is created
                            for (int x = 0; x < a; x += 1)
                            {
                                if (Info[x, 1] == Robot1.Name && Info[x, 2] == Robot2.Name)
                                {
                                    Info[a, 5] = Info[x, 5];
                                    break;
                                }
else if (Info[x, 1] == Robot2.Name && Info[x, 2] == Robot1.Name)
                                {
                                    Info[a, 5] = Info[x, 5];
                                    break;
                                }
                            }
if (Info[a, 5] == null)
                            {
                                if (a == 0)
                                {
                                    Info[a, 5] = r.ToString();
                                     
                                }
else  
{
                                    r++;
Info[a, 5] = r.ToString();
                                }
//break;
                            }
                            Info[a, 0] = Intervol.Name.ToString();//Interference Volume
                            Info[a, 1] = Robot1.Name.ToString();//ROBOT1
                            Info[a, 2] = Robot2.Name.ToString();//ROBOT2
                            Info[a, 3] = ViaLoc.Name.ToString();//Via Location evaluated
                            VLocation.Add(ViaLoc);
                             
                            TxObjectList Delt = new TxObjectList();
                            if (ActualDistance <= 0)
                            {
                                if (InIV == 0)
                                {
                                    InIV = 1;
                                    if (i == 0)
                                    {
                                        Info[a, 4] = "WaitSignal AllocateZone" + Info[a, 5] +
";";//first location in IV
                                    }
else
{
                                        Info[a ‐ 1, 4] = Info[a ‐ 1, 4] + " @ " + "WaitSignal
AllocateZone" + Info[a, 5] + "; ";
                                        if (i == ViaLocation.Count ‐ 1)
                                            Info[a, 4] = "WaitSignal ReleaseZone" + Info[a, 5] +
";";//last location in IV
                                        else
                                            Info[a, 4] = "!Inside IV;";
                                    }
//TODO: Evaluate if this if worth to do.
                                    VLocCommand = ViaLoc as ITxRoboticLocationOperation;
                                    Delt = VLocCommand.Commands;
                                    if (Delt.Count > 0)
                                    {
                                        foreach (TxRoboticCommand Cmmnd in Delt)
                                        {
                                            TxRoboticCommand Del = Cmmnd as TxRoboticCommand;
                                            //Del.Delete();
                                        }
                                    }
                                }
else
{
                                    if (i == ViaLocation.Count ‐ 1)
                                    {
                                        Info[a, 4] = "WaitSignal ReleaseZone" + Info[a, 5] +
";";//last location in IV
                                    }
else
                                        Info[a, 4] = "!Inside IV;";
                                }
                            }
else
{
                                if (InIV == 1)
                                {
                                    InIV = 0;
                                    Info[a, 4] = "WaitSignal ReleaseZone" + Info[a, 5] + ";";
                                    VLocCommand = ViaLoc as ITxRoboticLocationOperation;
                                    Delt = VLocCommand.Commands;
                                    if (Delt.Count > 0)
                                    {
                                        foreach (TxRoboticCommand Cmmnd in Delt)
                                        {
                                            TxRoboticCommand Del = Cmmnd as TxRoboticCommand;
                                            //Del.Delete();
                                        }
                                    }
                                }
else
{
                                    Info[a, 4] = "!Outside IV;";
                                }
                            }
                            i++;//DEL
a++;
                        }
//Loop for writing to file (.csv) and OLPcommands
                        for (int y = t; y < a; y += 1)//Needs to be aout of the main loop x=b from x
until a
                        {
                            //FILE
                             
                            var newLine =
string.Format("\"{0}\";\"{1}\";\"{2}\";\"{3}\";\"{4}\";\"{5}\"", Info[y, 0], Info[y, 1], Info[y, 2],
Info[y, 3], Info[y, 4], Info[y, 5]);
                            csv.AppendLine(newLine);
                            VLocCommand = VLocation[y] as ITxRoboticLocationOperation;
                            //OLP
string[] Word = Info[y,4].Split(Separator,
StringSplitOptions.RemoveEmptyEntries); //separates wait wignals that are written in the same line
for same ViaLocation
                            for (int s = 0; s < Word.Length; s++) // writes OLP commands included in
text[t], usually only 1
                            {
                                ArrayList ArrList = new ArrayList();
                                StringElement.Value = Word[s];
                                ArrList.Add(StringElement);
CommandCreationData.Elements = ArrList;
                                VLocCommand.CreateCompositeCommand(CommandCreationData);
                            }
t++;
                        }
var newLine1 = string.Format("\" \";");
                        csv.AppendLine(newLine1);
t=a;
                    }
j++;
                }
                //copy here the writing file
            }
            //Declare after loop ‐ Actual writing of output to file
            System.IO.File.WriteAllText(OutputDirectory, csv.ToString());
            //Information window telling that process has ended and the path in which the file has
been saved.
            MessageBox.Show("Script finished. Output written to " + savePath, "MinimalDistance",
MessageBoxButtons.OK, MessageBoxIcon.Information);  
        }
        public override string Name
        {
            get
            {
                return StringTable.MODEL_OBJECTS_COMMAND_NAME;
            }
        }
    }
}
            #endregion 

B.Source Code: ConsoleChangePriority.exe

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.ComponentModel;
namespace ConsoleChangePriority
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("How many swept volumes will be calculated? ");
            string strPriorityCommand = "/C wmic process where name=\"SweptVolumeEngine.exe\" CALL
setpriority \"high priority\""; //"SweptVolumeEngine.exe" could be replaced with another process
which priority you want to change
            string consoleCalcInfo = "Raised priority of swept volume calculation {0} out of {1}";
            string strUserInput = Console.ReadLine();
            int intUserInput;
            int intEndofRun = 0;
            int intMaxNumberOfRuns = 100;
            if (Int32.TryParse(strUserInput, out intUserInput))
            {
                intUserInput = Int32.Parse(strUserInput);
            }
            else
            {
                Console.WriteLine("String could not be parsed, restart the application and enter an
integer when prompted");
                Console.ReadKey();
            }
            for (int i = 1; i <= intUserInput; i++)
            {
                try
                {
                    Console.WriteLine("Looking for SweptVolumeEngine.exe");
                    Process[] SWE = Process.GetProcessesByName("SweptVolumeEngine");
                    if (SWE[0] != null)
                    {
                        var observation = System.Diagnostics.Process.Start("CMD.exe",
strPriorityCommand);
                        Console.WriteLine("Raised priority of ");
                        SWE[0].WaitForExit();
intEndofRun = 0;
                        Process[] CMD = Process.GetProcessesByName("CMD");
                        CMD[0].Kill();
Console.WriteLine(consoleCalcInfo, i, intUserInput);
                        System.Threading.Thread.Sleep(1000 * 4); //Input in milliseconds. Waits 4
seconds before making a new attempt
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    i‐‐;
intEndofRun++;
Console.WriteLine("SweptVolumeEngine.exe is currently not running");
                    if (intEndofRun > intMaxNumberOfRuns)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000 * 3); //Input in milliseconds. Waits 3 seconds
before making a new attempt
                }
                catch
                {
                    Console.WriteLine("Program encountered unexpected error and will now close");
                    i = intUserInput;
                    break;
                    // System.Threading.Thread.Sleep(1000 * 3); //Input in milliseconds. Waits 3
seconds before making a new attempt
                }
            }
                Console.WriteLine("Search ended, did not find any SweptVolumeEngine.exe with {0}
attempts", intMaxNumberOfRuns);
                Console.WriteLine("Therefore approximately " + intMaxNumberOfRuns * 3 / 60 + "
minutes since last SweptVolumeEngine.exe finished");
                Console.WriteLine("Press any button to exit application");
                Console.ReadKey();
        }
    }
}
 

C.Source Code: Copy-Paste via-locations

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tecnomatix.Engineering;
namespace TecnomatixTesting
{
   
#region ButtonCommand
public class TxHelloWorld : TxButtonCommand
{
         
    public override string Category
    {
    get  
    {  
     return TecnomatixTesting1.StringTable.CATEGORY;
    }
    }
    public override void Execute(object cmdParams)
    {
            //TxRoboticViaLocationOperation SavedOp = new TxRoboticViaLocationOperation();
             
            // TODO DECLARE i for each of the "foreachs" loops
            //typeof(TxCompoundOperation)
            TxObjectList Level1 = TxApplication.ActiveDocument.OperationRoot.GetDirectDescendants(new
TxNoTypeFilter());
            int i1 = 0;
            foreach (TxCompoundOperation Level1Op in Level1)
            {
                TxObjectList Level2 = Level1Op.GetDirectDescendants(new TxNoTypeFilter());
                foreach (TxCompoundOperation Level2Op in Level2)
                {
                    TxObjectList Level3 = Level2Op.GetDirectDescendants(new TxNoTypeFilter());
                    int i3 = 0;
                    foreach (ITxOperation if3 in Level3)
                    {
                        TxCompoundOperation Level3Op = Level3[i3] as TxCompoundOperation;
                        TxObjectList Level4 = new TxObjectList();
                         
                        Level4 = Level3Op.GetDirectDescendants(new TxNoTypeFilter());
                         
                        i3++;
int i4 = 0;
                        ITxOperation SavedOp = null as ITxOperation;
                        ITxOperation SavedOp1;
foreach (ITxOperation Op4 in Level4)
                        {
                            TxCompoundOperation If4 = Level4[i4] as TxCompoundOperation;
                            if (If4 != null)//enter here when we have cases
                            {
                                #region Compound Operations
                                TxCompoundOperation Level4Op = Level4[i4] as TxCompoundOperation;
                                TxObjectList Level51 = Level4Op.GetDirectDescendants(new
TxTypeFilter(typeof(TxCompoundOperation)));//TODO fix this to be able to work with Directin cases
ROB22
                                int i5 = 0;
                                foreach (ITxOperation Op5 in Level51)
                                {
                                     
                                    TxCompoundOperation Level51Op = Op5 as TxCompoundOperation;
                                    if (Level51Op != null)
                                    {
                                        TxObjectList Level6 = Level51Op.GetDirectDescendants(new
TxNoTypeFilter());
                                        int i6 = 0;
                                        foreach (ITxOperation compOp5 in Level6)
                                        {
                                            TxGenericRoboticOperation GenRobOp = Level6[i6] as
TxGenericRoboticOperation;
                                            TxWeldOperation WeldOp = Level6[i6] as TxWeldOperation;
                                            TxObjectList Level7;
ITxOperation Level6Op;
                                            //if (GenRobOp != null)
                                            //{ TxObjectList Level7 =
GenRobOp.GetDirectDescendants(new TxNoTypeFilter()); }
                                            if (WeldOp != null)
                                            {   Level6Op = WeldOp;
                                                Level7 = WeldOp.GetDirectDescendants(new
TxNoTypeFilter());
                                            }
else
{   Level6Op = GenRobOp;
                                                Level7 = GenRobOp.GetDirectDescendants(new
TxNoTypeFilter());
                                            }
SavedOp1 = SavedOp;
                                            if (Level7.Count != 0)
                                            {
                                                if (i5 == Level51.Count)
                                                { SavedOp = Level7[Level7.Count ‐ 1] as
TxRoboticViaLocationOperation; }
                                            }
else { SavedOp = null; }
                                            if (i4 != 0 && SavedOp1 != null) //i3 means the index
below level 3, to see when the frist operation of the segment hapens. might move this to the copy
method
                                            {   PasteMethod(Level6Op, SavedOp1);
                                            }
i5++;
i6++;
                                        }
                                    }
else
{
                                        TxGenericRoboticOperation GenRobOp = Op5 as
TxGenericRoboticOperation;
                                        TxWeldOperation WeldOp = Op5 as TxWeldOperation;
                                        TxObjectList Level7;
ITxOperation Level6Op;
                                        //if (GenRobOp != null)
                                        //{ TxObjectList Level7 = GenRobOp.GetDirectDescendants(new
TxNoTypeFilter()); }
                                        if (WeldOp != null)
                                        {   Level6Op = WeldOp;
                                            Level7 = WeldOp.GetDirectDescendants(new
TxNoTypeFilter());
                                        }
else
{   Level6Op = GenRobOp;
                                            Level7 = GenRobOp.GetDirectDescendants(new
TxNoTypeFilter());
                                        }
SavedOp1 = SavedOp;
                                        if (Level7.Count != 0)
                                        {
                                            if (i5 == Level51.Count)
                                            { SavedOp = Level7[Level7.Count ‐ 1] as
TxRoboticViaLocationOperation; }
                                        }
else { SavedOp = null; }
                                        if (i4 != 0 && SavedOp1 != null) //i3 means the index below
level 3, to see when the frist operation of the segment hapens. might move this to the copy method
                                        { PasteMethod(Level6Op, SavedOp1);
                                        }
i5++;
                                    }
                                     
                                }
                            }
#endregion  
                            else // Enter here when the having a generic robotic operation at level 4
                            {
                                 
                                TxObjectList Level52;
ITxOperation Level4Op;
TxGenericRoboticOperation GenRobOp = Level4[i4] as
TxGenericRoboticOperation;
                                TxContinuousRoboticOperation ContOp = Level4[i4] as
TxContinuousRoboticOperation;
                                TxWeldOperation WeldOp = Level4[i4] as TxWeldOperation;
                                //TODO revise this as the same statement is repited start and end
                                if (GenRobOp != null)
                                {   Level4Op = GenRobOp;
                                    Level52 = GenRobOp.GetDirectDescendants(new TxNoTypeFilter());
                                }
                                else if (ContOp != null)
                                {   Level4Op = ContOp;
                                    Level52 = ContOp.GetDirectDescendants(new TxNoTypeFilter()); }
                                else if (WeldOp != null)
                                {   Level4Op = WeldOp;
                                    Level52 = WeldOp.GetDirectDescendants(new TxNoTypeFilter()); }
                                else
{   Level4Op = GenRobOp;
                                    Level52 = GenRobOp.GetDirectDescendants(new TxNoTypeFilter()); }
                                SavedOp1 = SavedOp;
                                if (Level52.Count != 0)
                                { SavedOp = Level52[Level52.Count ‐ 1] as
TxRoboticViaLocationOperation; }
                                else { SavedOp = null; }
                                if (i4 != 0 && SavedOp1 != null)  
                                {
                                    PasteMethod(Level4Op, SavedOp1);
                                }
                            }
i4++;  
                        }
                    }
                }
            }
            #region Old code
            //TxTypeFilter IV_Filter = new TxNoTypeFilter();
            /*TxObjectList InterferenceVolumes1 =
TxApplication.ActiveDocument.OperationRoot.GetDirectDescendants(new TxNoTypeFilter());
            TxCompoundOperation show = InterferenceVolumes1[1] as TxCompoundOperation;
            TxObjectList InterferenceVolumes2 = show.GetDirectDescendants(new TxNoTypeFilter());
            TxCompoundOperation show1 = InterferenceVolumes2[5] as TxCompoundOperation;
            TxObjectList InterferenceVolumes3 = show1.GetDirectDescendants(new TxNoTypeFilter());
            TxCompoundOperation show2 = InterferenceVolumes3[0] as TxCompoundOperation;
            TxObjectList InterferenceVolumes4 = show2.GetDirectDescendants(new TxNoTypeFilter());
            TxCompoundOperation show3 = InterferenceVolumes4[1] as TxCompoundOperation;
            TxObjectList InterferenceVolumes5 = show3.GetDirectDescendants(new TxNoTypeFilter());
            ITxOperation show4 = InterferenceVolumes5[0] as ITxOperation;
            TxTypeFilter Sel_Filter = new TxTypeFilter(typeof(TxCompoundOperation));
            TxObjectList Selection_1 =
TxApplication.ActiveDocument.OperationRoot.GetAllDescendants(Sel_Filter);
            TxRoboticViaLocationOperation[] lastViaList = null ;
            TxObjectList Preview = new TxObjectList();
            TxObjectList Preview1 = new TxObjectList();
            int i = 0;
            
            foreach (TxCompoundOperation compOp in Selection_1)
            {
                TxCompoundOperation CompOp = Selection_1[i] as TxCompoundOperation;
                TxObjectList weldList = CompOp.GetDirectDescendants(new
TxTypeFilter(typeof(TxWeldOperation)));
                int i2 = 0;
                foreach (TxWeldOperation compOp1 in weldList)
                {
                    TxWeldOperation CompOp1 = weldList[i2] as TxWeldOperation;
                    TxObjectList weldList1 = CompOp1.GetDirectDescendants(new
TxNoTypeFilter());//think about putting and exclude for compounds
                
                    if (weldList.Count > 0)
                    {
                        //TxRoboticViaLocationOperation lastViaLoc = weldList1[weldList1.Count ‐ 1]
as TxRoboticViaLocationOperation;
                        Preview1.Add(weldList1[weldList1.Count ‐ 1]);
                    }
                }
                //lastViaList.SetValue(lastViaLoc, i);
                i++;
            }
           /* foreach (TxCompoundOperation compOp in InterferenceVolumes)
            {
                TxObjectList weldList = compOp.GetAllDescendants(new
TxTypeFilter(typeof(TxCompoundOperation)))  ;
            }
            TxOperationRoot operartionRoot = TxApplication.ActiveDocument.OperationRoot;
            TxRoboticViaLocationOperation op = InterferenceVolumes[0] as
TxRoboticViaLocationOperation;
            TxObjectList operationsToCopy = new TxObjectList();
            operationsToCopy.Add(op);
            TxObjectList operationsCopies = null;
            if (operartionRoot.CanPasteList(operationsToCopy))
                operationsCopies = operartionRoot.Paste(operationsToCopy);
            */
             
            /* int index = 0;
            foreach (ITxObject InterfVol in InterferenceVolumes)
            {
                string InterferenceVolName = string.Format("Interference volume: {0}", index + 1);
                // Console.WriteLine(InterferenceVolName + "\n");
                ++index;
            }
            
            var sb = new StringBuilder();
            /*if (InterferenceVolumes.Count < 1)
            {
                MessageBox.Show(string.Format("Number of Interference Volumes: {0}",
InterferenceVolumes.Count), Name, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                int index = 0;
                foreach (ITxObject InterfVol in InterferenceVolumes)
                {
                    MessageBox.Show(string.Format(MessageFormat, InterferenceVolumes[index].Name),
Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ++index;
                }
            }
            MessageBox.Show(string.Format(MessageFormat, show.Name), Name, MessageBoxButtons.OK,
MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show1.GetType()), Name,
MessageBoxButtons.OK, MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show1.Name), Name, MessageBoxButtons.OK,
MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show2.GetType()), Name,
MessageBoxButtons.OK, MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show2.Name), Name, MessageBoxButtons.OK,
MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show3.GetType()), Name,
MessageBoxButtons.OK, MessageBoxIcon.Information);
XIII
            MessageBox.Show(string.Format(MessageFormat, show3.Name), Name, MessageBoxButtons.OK,
MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show4.GetType()), Name,
MessageBoxButtons.OK, MessageBoxIcon.Information);
            MessageBox.Show(string.Format(MessageFormat, show4.Name), Name, MessageBoxButtons.OK,
MessageBoxIcon.Information);
            */
#endregion  
    }
        //this method gets info about the parent and SavedOp to make a copy of the vialocation in the
next segment.
        public void PasteMethod(ITxOperation ParentOp, ITxOperation SavedOp1)  
        {
            TxGenericRoboticOperation GenericParent = ParentOp as TxGenericRoboticOperation;
            ITxWeldOperation WeldParent = ParentOp as ITxWeldOperation;
            ITxContinuousOperation ContParent = ParentOp as ITxContinuousOperation;
             
            TxRoboticViaLocationOperation SavedViaLoc = SavedOp1 as TxRoboticViaLocationOperation;
            TxWeldLocationOperation SavedWeldLoc = SavedOp1 as TxWeldLocationOperation;
            if (SavedViaLoc != null)
            {
                if (GenericParent != null)
                {
                    TxObjectList operationsToCopy = new TxObjectList();
                    operationsToCopy.Add(SavedViaLoc);
TxObjectList CopyOperation = null;
                    if (GenericParent.CanPasteList(operationsToCopy))
{
                        CopyOperation = GenericParent.Paste(operationsToCopy);
                        ITxObject CopyOperationOP = CopyOperation[0] as ITxObject;
                        // this list is used for when there is no location on the operation and the
copied operation cant be moved anywhere
                        TxObjectList ListParent = GenericParent.GetDirectDescendants(new
TxNoTypeFilter());
                        if (ListParent.Count > 1)
                        { GenericParent.MoveChildAfter(CopyOperationOP, null); }
                         
                    }
                }
                else if (ContParent != null)
                {
                    TxObjectList operationsToCopy = new TxObjectList();
                    operationsToCopy.Add(SavedViaLoc);
TxObjectList CopyOperation = null;
                    if (ContParent.CanPasteList(operationsToCopy))
{
                        CopyOperation = ContParent.Paste(operationsToCopy);
                        ITxObject CopyOperationOP = CopyOperation[0] as ITxObject;
                        ContParent.MoveChildAfter(CopyOperationOP, null);
                    }
                }
                else  
                {
                    TxObjectList operationsToCopy = new TxObjectList();
                    operationsToCopy.Add(SavedViaLoc);
TxObjectList CopyOperation = null;
                    if (WeldParent.CanPasteList(operationsToCopy))
{
                        CopyOperation = WeldParent.Paste(operationsToCopy);
                        ITxObject CopyOperationOP = CopyOperation[0] as ITxObject;
                        WeldParent.MoveChildAfter(CopyOperationOP, null);
                    }
                }
            }
            else
            {
                if (GenericParent != null)
                {
                    TxObjectList operationsToCopy = new TxObjectList();
                    operationsToCopy.Add(SavedWeldLoc);
TxObjectList CopyOperation = null;
                    if (GenericParent.CanPasteList(operationsToCopy))
{
                        CopyOperation = GenericParent.Paste(operationsToCopy);
                        ITxObject CopyOperationOP = CopyOperation[0] as ITxObject;
                        GenericParent.MoveChildAfter(CopyOperationOP, null);
                    }
                }
                else if (ContParent != null)
                {
                    TxObjectList operationsToCopy = new TxObjectList();
                    operationsToCopy.Add(SavedWeldLoc);
TxObjectList CopyOperation = null;
                    if (ContParent.CanPasteList(operationsToCopy))
{
                        CopyOperation = ContParent.Paste(operationsToCopy);
                        ITxObject CopyOperationOP = CopyOperation[0] as ITxObject;
                        ContParent.MoveChildAfter(CopyOperationOP, null);
                    }
                }
                else
                {
                    TxObjectList operationsToCopy = new TxObjectList();
                    operationsToCopy.Add(SavedWeldLoc);
TxObjectList CopyOperation = null;
                    if (WeldParent.CanPasteList(operationsToCopy))
{
                        CopyOperation = WeldParent.Paste(operationsToCopy);
                        ITxObject CopyOperationOP = CopyOperation[0] as ITxObject;
                        WeldParent.MoveChildAfter(CopyOperationOP, null);
                    }
                }
            }               
        }
    public override string Name
    {
    get
    {
     return TecnomatixTesting1.StringTable.MODEL_OBJECTS_COMMAND_NAME;
    }
    }
    }  
#endregion
    #region VolumeRetrieve
    /*public class TxVolumeRetrieve : TxDocument
    {
        //Class members:
        //Interference object. Include as list?
        TxObjectList List_of_objects = TxApplication.ActiveDocument.GetObjectsByName("Volume");
       
        public void
        string objectType2 = List_of_objects[0].ToString();
        
    } */
    #endregion
}

相关文章

网友评论

    本文标题:Tecnomatix PDPS 机器人自动避障

    本文链接:https://www.haomeiwen.com/subject/sixvkhtx.html