• Login
sketchucation logo sketchucation
  • Login
ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

Convert Array into Integer

Scheduled Pinned Locked Moved Plugins
3 Posts 2 Posters 147 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 Offline
    rossthompson
    last edited by 5 Jun 2014, 08:27

    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
    • T Offline
      tt_su
      last edited by 5 Jun 2014, 09:26

      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 Offline
        rossthompson
        last edited by 5 Jun 2014, 11:22

        Hi, that has sorted it.

        Thank you

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          3/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement