+ Reply to Thread
Results 1 to 8 of 8

Thread: Conditions on When to Hide and Object

  1. #1

    Conditions on When to Hide and Object

    Is it possible to place conditions on when to hide an object? I want a line segent to be hidden after it gets larger than another line segment in the file. So I want to hide a when a>b. Can this be done?

    Thanks!

  2. #2
    Sketchpad Developer
    Join Date
    Oct 2010
    Location
    Philadelphia
    Posts
    71

    Conditions on When to Hide an Object

    Hi, you can certainly create the effect of showing or hiding an object depending on a calculation in the sketch. (I use the word "effect" because the technique actually involves controlling the existence of the object rather than just its visibility. This is more powerful, because existence also affects child objects.)

    Here's one method, based on dilation, that I use most commonly. Begin by creating the conditional value using the Boolean Logic tools, which you'll find here: Help | Sample Sketches & Tools | Custom Tools. Use these tools to calculate a Boolean value (a value of 1 for True and 0 for False). In your example, you could use the x <= y tool to compare the two lengths in question. Then use the reciprocal of the Boolean result, which is 1 in the True case and undefined (or infinity) in the False case, to dilate the object you want to hide. Finally, hide the original object, so the only one visible is the dilated image.

    When the value is True, the dilated image is exactly where the original was, and when the value is False, the dilated image doesn't exist. The enclosed sketch shows an example of this technique, and also shows a similar method for displaying conditional text -- a caption that appears only when a particular condition is true.

    I hope this is useful.
    --Scott
    Attached Files

  3. #3
    Scott,

    This definitely sounds like it will work. I'd love to take a look at your sample file but I only have GSP v. 3. We have a site license and haven't been able to afford to upgrade. Can you re-save the file in compatibility mode and re-post?

    Thanks so much!
    Lara

  4. #4
    Sketchpad Developer
    Join Date
    Oct 2010
    Location
    Philadelphia
    Posts
    71
    Lara, I'm sorry to say that it's not possible to save these tools in GSP3 format. GSP3, which was replaced by GSP4 in 2001 and then by GSP5 in 2009, did not have custom tools. That said, in GSP3 you can create calculations (or even GSP3 scripts) with a similar effect, by using the signum function (abbreviated sgn). This function returns -1 if its argument is negative, 0 if the argument is 0, and +1 if the argument is positive. For instance, to calculate a Boolean value for the condition x=0, you could calculate 1-abs(sgn(x)). The result will be 1 if x is 0, and 0 if x is either greater than zero or less than zero. Thus it returns True (1) when x=0, and False (0) when x is not 0.

    You can use similar calculations for just about any condition from which you want to calculate a Boolean value.

  5. #5
    Scott, I'm wrong about versions. I need the file in GSP4. I use custom tools all the time!

    Thanks!

  6. #6
    Scott, I saved the GSP 5 file and sent it to a friend who converted it to compability mode for me and sent it back. When I open it in GSP 4 it doens't do what it says it wil do...

  7. #7
    Sketchpad Developer
    Join Date
    Oct 2010
    Location
    Philadelphia
    Posts
    71
    Lara, when I save in GSP4 mode, I find that all the tools except for the switches save correctly. That includes all the comparison tools (like x > y) and all the Boolean operators (like AND and NOT). If there's anything else, besides the switches, that doesn't save properly for GSP4, please send me an email (directly to stek@kcptech.com), include your copy of the document, and tell me exactly what doesn't work as it is supposed to. (Without more information about the problem you encountered, I can't give you any kind of useful response.)

  8. #8
    Sketchpad Developer
    Join Date
    Oct 2010
    Location
    Philadelphia
    Posts
    71
    I've just uploaded some useful tools for making geometric objects and text appear and disappear based on calculated or measured values. I also started a new thread in case there are questions about these new tools, or the techniques involved in using them. The new thread is here: http://sketchexchange.keypress.com/f...-and-Disappear

    And the tools themselves are here: http://sketchexchange.keypress.com/s...and-text-tools

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts