RoboDK Forum
Show/Hide Simulation Event可打印版本

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Show/Hide Simulation Event (/Thread-Show-Hide-Simulation-Event)



Show/Hide Simulation Event-SamuelEStreamline-05-29-2023

Is there a way to add a simulation event to a program via Python API that will hide/show an object?

I'm thinking about using something like the following but I don't know how to call the object and the action (show/hide):

Code:
ins_event_show = {'Type': INS_TYPE_EVENT, 'Behavior': EVENT_SHOW, 'Item': robot}

program = RDK.Item('My_Program', ITEM_TYPE_PROGRAM)
program.setParam("Add", ins_event_show)

Any thoughts?


RE: Show/Hide Simulation Event-Albert-05-30-2023

This is possible by using the ObjectList entry in the dictionary and a list of pointers as a string.

Example:
Code:
EVENT_SHOW=2
EVENT_HIDE=3

ObjectList = ""
因为我tem in items:
ObjectList += str(item.item) + ","

ins_event_show = {'Type': INS_TYPE_EVENT, 'Behavior': EVENT_SHOW, 'ObjectList': ObjectList}

program = RDK.Item('My_Program', ITEM_TYPE_PROGRAM)
program.setParam("Add", ins_event_show)



RE: Show/Hide Simulation Event-SamuelEStreamline-05-30-2023

Thank you Albert!

Is the ObjectList entry just a list of strings that represent the name of the object I want to hide/show?

I'm able to create a hide/show event in the simulation via the API but it unfortunately remains undefined and does not actually have the item I want selected.

I assume I'm doing something wrong with the ObjectList entry. Here's what the dictionary looks like that I pass into the setParam method:

show_instruction: {'Type': 7, 'Behavior': 2, 'ObjectList': ['Fanuc-M-20iD-35-Leg-1']}

There is a robot with that name in the station at the time of program creation.


RE: Show/Hide Simulation Event-Albert-05-31-2023

The item list should be a list of pointers as a string, separated by comma. The code I shared should give you the item pointer (item.item) and convert to a string.

You can read what a show or hide event instruction looks like to get an idea.