• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Developing a specific if statement ?

Scheduled Pinned Locked Moved Developers' Forum
2 Posts 2 Posters 234 Views
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 15 Sept 2008, 02:36

    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
    • T Offline
      tbd
      last edited by 15 Sept 2008, 06:56

      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
      1 / 1
      • First post
        1/2
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement