cancel
Showing results for 
Search instead for 
Did you mean: 

Check if selection contains a robot and not a rail

Legend
Legend

Hello,

I want to program a command enabler that enables a command if there is only one object selected and it is a robot (TxRobot).

Now my problem is that also rails are of type TxRobot but selections on rails should not enable the command.

Currently I cast the TxRobot object to a TxDevice and decide on the DrivingJoints property. My class derives from TxCommandSelectionEnabler.

        private void CheckSelection(TxObjectList objects)
        {
            bool flag = false;
            if (objects.Count == 1)
            {
                ITxRobot robot = objects[0] as ITxRobot;
                if (robot != null)
                {
                    if ((robot as ITxDevice).DrivingJoints.Count > 3)
                    {
                        flag = true;
                    }
                }
            }
            _enable = flag;
        }

Are there better ways to "filter off" rails?

7 REPLIES

Re: Check if selection contains a robot and not a rail

Creator
Creator

you should use the commandtypefilter.

 

This enables the Button when ever you select a txrobot.

 

public class App : TxButtonCommand
    {
        private TxCommandTypeFilterSingleObjEnabler _enabler;
        public App()
        {
            TxTypeFilter filter = new TxTypeFilter(typeof(ITxRobot));
            _enabler = new TxCommandTypeFilterSingleObjEnabler(filter);
        }

        public override string Name
        {
            get
            {
                return "AppName";
            }
        }

        public override string Category
        {
            get
            {
                return "Company";
            }
        }

        public override ITxCommandEnabler CommandEnabler
        {
            get
            {
                return _enabler;
            }
        }
		
        public override void Execute(object cmdParams)
        {
            TxObjectList selectedList = TxApplication.ActiveSelection.GetItems();
            if (selectedList.Count == 1)
            {
                TxRobot robot = selectedList[0] as TxRobot;
            }
        }
    }

Re: Check if selection contains a robot and not a rail

Legend
Legend

Hi,

I forgot to write that I already tried TxCommandTypeFilterSingleObjEnabler.

My solution works but I wonder if there are better ways to difference between robots and rails.

In your solution the command would even enable if the selection contains a rail. That is not what I want.

Re: Check if selection contains a robot and not a rail

Creator
Creator

Hello Markus,

 

check if your rail is an txrobot. In this case the filter does not work, of course.

The Filter works definitly on our environement, where the robot is a txrobot and the rail is a txdevice.

 

 

Re: Check if selection contains a robot and not a rail

Legend
Legend

Hello Titaniser!

 

Sure it would be the best if robots and rails are of different types.

But in may case rails are always of type TxRobot and that makes ist difficult to differ.

 

I found only the solution with counting the joints. But for me this is not correct because there are also robots with only three joints existing. I am looking for other properties/solutions that makes it possible to clearly differ between robots and rails.

Re: Check if selection contains a robot and not a rail

Siemens Genius Siemens Genius
Siemens Genius

Hi Markus,

 

It is  still not clear for me what is the reason that you must define Rail as a robot (do you need some OLP controller to control the rail???).

 

If both are TxRobot, then they both have a base frame, toolframe and TCP, they are both also ITxDevice and have joints. So you cannot differentiate without MANUALLY creating the difference. 

 

You can differentiate by the PM type, if you make sure the Robot and the Rail have different PM type.

Otherwise you can try other methods to differentiate - naming conventions,  value of some server properties etc.

 

Kind regards,

Zachi

Re: Check if selection contains a robot and not a rail

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Zachi,

 

This is standard workflow for some OEMs or other PS user. They define also the Rail as robot. 

Yes it is correct the rail will have a TOOLFRAME and a BASEFRAME.

As far as I remember the reason why they did this, in the past "attach" was only a study information. So they "mounted" the robot on the rail. As a result, they have the connection between robot and rail as database information.

 

Best regards

Patrick

Re: Check if selection contains a robot and not a rail

Creator
Creator

Thats a good example of fixing software problems with workarounds.

 

*thumbs up