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!
    Mac User? | Join the Rayscaper Beta for Mac Learn More

    Convert Array into Integer

    Scheduled Pinned Locked Moved Plugins
    3 Posts 2 Posters 328 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.
    • R
      rossthompson
      last edited by

      Hi,

      I am trying to use a simple bit of code that allows me to set the color alpha value in SketchUp 7.

      I use this version as its the last one with a free DWG importer.

      Anyway the problem is I can only get an array from 'UI.inputbox' and I need an integer to set the color.alpha value.

      Can anyone correct the code?

      Thanks

      Ross

      ` def translucent
      model = Sketchup.active_model
      materials = model.materials
      m=materials.add("translucent") unless m=materials["translucent"] # Adds a material to the "in-use" material pallet.

      title = 'Opacity'
      prompt = 'Opacity'
      default = 0.5
      result = UI.inputbox([prompt], [default], "text") # need to use array

      UI.messagebox(result)

      m.color = Sketchup::Color.new(100, 100, 100, result) # Specify the colour.opacity
      color = m.color
      alpha = m.alpha=0.5 # Set material transparency
      materials.current = materials["translucent"] # Set to the current material
      Sketchup.send_action "selectPaintTool:" # Start the paint tool
      end`

      1 Reply Last reply
      Reply Quote 0
      • tt_suT
        tt_su
        last edited by

        You need to access the items inside the array. In your case you only have one item so it would be: result[0].

        m.color = Sketchup::Color.new(100, 100, 100, result[0])

        http://rubylearning.com/satishtalim/ruby_arrays.html

        You should also check result to see if the user hit Cancel in the inputbox.

        1 Reply Last reply
        Reply Quote 0
        • R
          rossthompson
          last edited by

          Hi, that has sorted it.

          Thank you

          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