sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Developing a specific if statement ?

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 234 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](http://thingsvirtual.blogspot.ca/)
      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
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement