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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Some Ruby Help

    Scheduled Pinned Locked Moved Plugins
    3 Posts 2 Posters 362 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.
    • K Offline
      ktkoh
      last edited by

      I am trying to set a layer to be visible on one page using the code:
      page = page.set_visibility layer visibility

      I have put this code in the ruby console and it runs without error but the layer is not visible on the page as I expected.

      model = Sketchup.active_model
      entities = model.entities
      selection = model.selection
      layers = model.layers
      pages = model.pages
      page = pages["Blank Page"]
      if (page)
      UI.messagebox page
      layername = "A01-Test"
      page = page.set_visibility ["A01-Test"], [true]
      else
      UI.messagebox "Failure"
      end
      

      Would someone help point out the error in my code?

      Keith

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        @ktkoh said:

        I am trying to set a layer to be visible on one page using the code:
        page = page.set_visibility layer visibility
        I have put this code in the ruby console and it runs without error but the layer is not visible on the page as I expected.
        ...

        I have taken the liberty of putting your post's code inside [Code]-braces...
        Assuming you have a page called "Blank Page" and a layer called "A01-Test" then the page set_visibility method takes a 'layer' (NOT a layer name) and a 'boolean' i.e. true or false (NOT an array), so just recast it as follows...
        page.set_visibility(layers["A01-Test"],true)

        I see no need to set the result to anything unless you want to test if it's done it - the method returns the page if successful and nil if failed...

        It should now work... ❓

        TIG

        1 Reply Last reply Reply Quote 0
        • K Offline
          ktkoh
          last edited by

          TIG thanks that worked like I needed it to. Next time I'll remember to add the code brackets. I am in the process of adding features to my makepart ruby and as someone wrote the monkey see monkey do coding only goes so far.

          Keith

          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