Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

[.NET C#] Difference between CreateCommand and CreateCompositeCommand?

Hello,

 

what is the difference between CreateCommand and CreateCompositeCommand?

When do I have to use CreateCompositeCommand?

7 REPLIES
Solution
Solution
Accepted by topic author MarkusH
‎09-12-2015 01:59 PM

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

CreateCommand creates a simple command using TxRoboticCommandCreationData - this creation data can only recieve some text as input.

CreateCompositeCommand creates a command with additional parameters given by an array of elemets of (abstract) type TxRoboticCompositeCommandElement.

For instance you could create composite command as follows:

 

ArrayList elements = new ArrayList();
var myCmd = new TxRoboticCompositeCommandStringElement("MyObjCommand"); 
var objElt = new TxRoboticCompositeCommandTxObjectElement(obj); //obj is some ITxObject

TxRoboticCompositeCommandCreationData creationData =
           new TxRoboticCompositeCommandCreationData(elements);

operation.CreateCompositeCommand(creationData); //operation is some ITxRoboticOperation

 

 

 

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

Thank you for the explanation!

 

An example for create command would be:

# Blank <componentname>

 

What about the commands # Drive Device and # Wait Device?

Must these commands be created with compositeCommand?

Solution
Solution
Accepted by topic author MarkusH
‎09-12-2015 02:00 PM

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

It is better to create them as composite, so it supports renaming of object as well as several object with same names. However the simulation does support such commands (# Blank, # Attach, # DriveDevice, etc...) as pure string commands via a research of relevant object with the given string name.

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

Hello!

 

To make it clear.

I can all spot attributes (# Blank, # Display, # Drive Device, # Wait Device, # WaitTime, ...) either create with CreateCommand or CreateCompositeCommand?

 

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

Yes, both will be simulated. The advantage of creating a composite command is explained in my previous answer.

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

[ Edited ]

Hello,

unfortunately I am still having big problems to create a composite command.

Let's say we have the following command:

# Blank part_x

 

part_x is of type TxCompoundPart in the study.

How can I determine the right object in the study if the command is only a string because it comes from a file (e.g. no_robot from Robcad)?

In theory more than one object in the study could have the name part_x.

 

Update:

Now, I found the methods GetObjectsByName and GetObjectsByID. I think these methods will solve one part of my problem.

Re: [.NET C#] Difference between CreateCommand and CreateCompositeCommand?

Useful post, but one small point - I think you omitted the step of adding myCmd and objElt to the elements arraylist:

elements.Add(myCmd);
elements.Add(objElt);