sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🚨 Skimp | 25% Off until March 30 Buy Now

    Developing a specific if statement ?

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 281 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tomot
      last edited by

      I need to develop some If statements to correct the pushpull direction of several entities
      related to a Door Ruby, I'm currently developing.

      Currently this Ruby has no problems if the user installs only left swinging door
      in either the yz or xz planes.

      However if the user installs right swinging doors the pushpulls need to be reversed.

      I have observed the following conditions:

      #Pushpull OK
      #left hand door in yz plane:
      $Vec1 = $pt0 - $pt1

      $Vec1 = Vector3d (0, 48, 0)

      #Pushpull OK
      #left hand door in xz plane:
      $Vec1 = $pt0 - $pt1

      $Vec1 = Vector3d(-48, 0, 0)

      #pushpull needs to be reversed
      #right hand door in yz plane:
      $Vec1 = $pt0 - $pt1

      $Vec1 = Vector3d(0, -48, 0)

      #pushpull needs to be reversed
      #right hand door in xz plane:
      $Vec1 = $pt0 - $pt1

      $Vec1 = Vector3d(48, 0, 0)

      I can see that -y value from one expression and the x>0 value from the other are the conditions
      needed to reverse the pushpull.

      Question: how do I extract the -y value and the x>0 value into a working if statement?

      TIA

      my plugins
      tomot

      1 Reply Last reply Reply Quote 0
      • tbdT Offline
        tbd
        last edited by

        x,y,z = $Vec1.to_a
        if (-y && x>0)
          ... do your code
        end
        
        

        also try not to use global variables (see this discussion)

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better πŸ’—

        Register Login
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement