top of page
Search
Writer's pictureIvaylo Fiziev

IS_PICKED/IS_SELECTED SCL functions


I create some of my posts based on real customer questions. This one is a perfect example. The question was: Why is the IS_PICKED function not working?

At first I could not understand what they mean but then I realized that they are trying to monitor the pick using a signal in simulation panel. And since the function generates a pulse the UI can hardly show it.

Despite the documentation it seems like they don't understand how this works. In this post I'll bring some light on these.

First the use case: User interacting with the objects in the graphics viewer. Similarly to an HMI the code should react to user clicks.

SCL scripts execute periodically. We rely on this fact to detect clicks. On each execution the script simply checks the picked/selected state of the object it is assigned to.


Now the functions:

IS_PICKED - returns the picked state of the object. e.g. whether the user has clicked on the object in the graphics viewer. The function returns true when called after the click. Subsequent calls return false. In other words it generates a very short pulse. You can use this pulse as a trigger of some other logic inside the script. The SCL debugger can help you detect the pulse by putting a breakpoint in a related 'if' statement:


IS_SELECTED - returns the selected state of the object. e.g. whether the user has selected the object in the graphics viewer or the object tree. This is again triggered by a click but the object stays selected until another object is selected or the selection is cleared. In other words the selection generates a very wide pulse. This is more likely to be used for monitoring. Again you can use the debugger to detect the change in state. Usually you'll need to combine this function with a rising edge trigger (R_TRIG) in order to react once on selection gain.


If you need to react on selection loss you simply switch to using a falling edge trigger (F_TRIG). Simple but elegant, isn't it?


I hope this clears the mystery a bit.

Have a wonderful day!

8 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page