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

Some Ruby Help

Scheduled Pinned Locked Moved Plugins
3 Posts 2 Posters 346 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.
  • K Offline
    ktkoh
    last edited by 23 Apr 2010, 16:59

    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
    • T Offline
      TIG Moderator
      last edited by 23 Apr 2010, 17:15

      @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 23 Apr 2010, 23:17

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

        Advertisement