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!
    πŸ”Œ Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    [CityGen] Trying to use City_Gen.module_path

    Scheduled Pinned Locked Moved City Generator
    6 Posts 3 Posters 11.5k Views 3 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      I'm sure this is fundamental ruby 101 question and I'm being dense....so nothing new!

      I want to make a variable with the path to the "building" folder (not in the program yet, its something I'm playing with). So I figured I could do this:
      path = City_Gen.module_path path.concat "/buildings"

      But everytime I run that, it keeps adding another /buildings onto the end. So I get:

      C:/Program Files/Google/Google SketchUp 7/Plugins/citygen/modules/buildings/buildings/buildings/buildings/buildings/buildings/buildings

      I figure that each time I ran it, it would return the path, and so the concat would just add /buildings onto the end of the path. I wasn't expecting it to actually modify the @module_path variable.

      So what would be the correct way to use City_Gen.module_path so I could append my buildings folder onto it, and not change the @module_path and mess up everything else that depends on that variable remaining constant.

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        hm... taht's odd.

        I thought ruby made a copy when you used the =

        What happens if you do: path = City_Gen.module_path + "/buildings" ?

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Ahh, yes that works. I so rarely work with strings, its like my mind turns to mush when I try. Thanks Thom!

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • tbdT Offline
            tbd
            last edited by

            
            path = File.join(City_Gen.module_path,"buildings")
            
            

            SketchUp Ruby Consultant | Podium 1.x developer
            http://plugins.ro

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              FYI; if you do a lot of string processing then you might want to use single quotes strings instead of double quoted string. Double quoted strings allows variables inside it and require more processing than single quoted. I'm not that familiar with the performance difference in Ruby, but it's the same in PHP. I've done quite a bit of PHP programming for making websites and then it's always string manipulations so I got into the habit for always using single quoted unless I need variables in my string.
              The Su plugins there's usually not that much string processing going on, so I don't think it'll matter that much.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @unknownuser said:

                
                > path = File.join(City_Gen.module_path,"buildings")
                > 
                

                Ah. πŸ˜„

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                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