Hiding a path from PCell code

I have a PCell that can use a Path as part of its shape control. Now, in some cases I do not want to use the path and then I like to hide it. I created the path in my PCell __init__ as:

self.param("path", self.TypeShape, "TLine", default = pya.DPath([pya.DPoint(0, 0), pya.DPoint(100, 0)], 0), hidden=True)

This hides the Path, however doing

self.path.hidden = False

does not make it visible again.

Anyone knows if it is possible to toggle visibility of a Path in a PCell?



  • Hi @ravn,

    currently (with 0.27), the hidden feature is not dynamic - you can set it at the beginning, but not change it.

    In 0.28 you will be able to dynamically change the visibility of a parameter in a new PCell method called "callback". This method is called whenever a parameter is changed or once initially. So you can implement logic there which controls aspects of the parameters, like in this sample:

        # "name" is the name of the parameter which was changed or an empty string for "initialize"
        def callback_impl(name)
          if name == "" || name == "p2"
            p3.enabled = p2.value > 10.0
            p4.readonly = p2.value > 10.0
            p5.visible = p2.value > 20.0
            p6.icon = p2.value > 30.0 ? RBA::PCellParameterState::ErrorIcon : RBA::PCellParameterState::NoIcon


Sign In or Register to comment.