Switch between scripts

I can not switch between two python scripts in two sensors. when I use output signals of robot arm as flags it does not work.
I am using while app.simulation.IsRunning == true statement.
unless i use a delay statement after it, the program breaks down
Any Help?

delay(0) might help
delay(0) might help

Just tried it but still does not work @titu

Ok how about you use a boolean signal instead of while app.simulation.IsRunning == true statement.

Are the two scripts within the same component or is it separate components?

They are in two different components. I tried using output signals of the robot as flags and using if condition to run each script but the if condition is never true.
For example: if robot.signalout.output(111, True):
and i set it to true before the if condition but still the condition is never true

I have No experience with this. What Happens if you try to realize with two boolean Signals?

Regards
Feature

i tried two flags but got the same result, the condition is never true

Try something like:

If (robot.signalout.output(111) == True):

Isn’t the syntax you use for setting the signal?

Have a look at this thread: Hiding components with Python scripting in VC - #5 by WilliamSmith

Regards
Feature

Still doesn’t work. I am really thankful for your help anyways.
The robot signals i’m using 111 and 112 are not connected to anything in the robot’s signal maping. I am just setting them to true before the if condition and then check the condition.

robot_comp = app.findComponent("IRB 4600-45/2.05")
 robot = getRobot(robot_comp)
 robot.SignalMapOut.output(111, True)
 while app.Simulation.IsRunning== True:
  delay(0.1)
  if(robot.SignalMapOut.output(111, True)):
   #start by getting the part

Could this be the problem?

Is your while-loop in the OnRun Method of the Script?

Regards
Feature

yes all of my code is in the OnRun() method.

Have you tried this?

Regards
Feature

Actually I am using the vcHelpersRobot2 library so i used
if(robot.signalMapOut.output(111,True)):
but still didnot work

As I mentioned I don’t use this, maybe an Error or faulty Code…

Try it with normal boolean Signals in combination with triggerCondition or Post your layout!?

Regards
Feature

it worked thank you!
Also do you know if it is possible to pick multiple objects at the same time using python API?

I’m happy to hear that! :grin:

There are different ways to do that, depending on the circumstances…

Regards
Feature

1 Like

@captain_feature For instance, i want my sensor to stop when it counts two boxes. And then the robot picks the two boxes and places them on another conveyor.

Implement a counterVariable, when this is <2 reset it and grad the desired parts?

Regards
Feature

yes, my problem is h ow to grab multiple parts using python

Did you search in the forum? Did you check academy or sample layouts?

By the way this is another topic?

Regards
Feature