Controlling Visibility of subelements of a component out of a KRL program in KUKA-SIM

Hi,

I want to switch the visibility inside a component by handing over an integer to a python script.
out of a KUKA-Robot program. The integer is given by 16 Output-Bits.

For example I hand over 26482 to the routine and the feature 35400_26482 gets displayed.

I have already collected some snippets. But it does not work in KUKA-SIM 4.3.

Can someone please help me?

Kind regards, Markus

Hi,

I hope this helps if you have any questions regarding this solution please ask.

You should be able to just replace your showElement method with the two I have provided. Basically it’s just iterating over the Feature Tree of your Component and whenever it finds a Geometry Feature it will set it’s visibilty based on the provided element id.

Here’s the code in text form so you can copy and paste it:

def showElement(element_id_int):
  comp = getComponent()
  text = str(element_id_int).strip()
  
  showElementRecursive(comp.RootFeature, text)
  
  comp.rebuild()

def showElementRecursive(element, element_id):
  for sub_element in element.Children:
    if sub_element.Type == VC_GEOMETRY:
      sub_element.Visible = (element_id in sub_element.Name)
    else:
      showElementRecursive(sub_element, element_id)

Kind regards, Fynn