sketchucation logo sketchucation
    • Login
    1. Home
    2. whodah
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    W
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: File Path with backslashes

      Hi,

      I realize that I forgot to mention that I am defining mymodel as:

      
      mymodel = Sketchup.active_model
      
      

      TIG: thanks! I hear ya on the \ vs. / thing for windows. But / is what the SVG script shows on the screen when one chooses a path, even on this windows environment. I tried both:

      
      File.join(File.dirname(mymodel.path), mymodel.title+".svg").tr("\"","/")
      
      

      and:

      
      (File.dirname(mymodel.path)+"/"+mymodel.title+".svg").tr("\"","/")
      
      

      which both resulted in:
      C:usersuserdesktop/Untitled.svg

      Aerilius: that did the trick, thank you very much!
      😄

      Your code results in:
      C:/users/user/desktop/Untitled.svg

      (and it works with the SVG plugin!)

      Final code that works for those googling down the road:

      
      mymodel = Sketchup.active_model
      mymodelpath = File.expand_path(mymodel.path)
      @svgFilename = Sketchup.active_model.get_attribute "foi_svg_export", "svgFilename", File.join(File.dirname(mymodelpath), mymodel.title+".svg")
      
      
      posted in Developers' Forum
      W
      whodah
    • File Path with backslashes

      Hello,

      I'm new to this. I'm using a Windows system and am tweaking the nifty SVG plugin:
      http://flightsofideas.net/?p=572

      It has a line in the code of:

      
      @svgFilename = Sketchup.active_model.get_attribute "foi_svg_export", "svgFilename", "flightofideas.svg"
      
      

      When one invokes the plugin, a pop-up box comes up with that path for the "Output File":
      http://www.flickr.com/photos/27621953@N02/3768086037/

      When first invoked, that path is simply "flightofideas.svg" until you specify (or navigate) a path. Subsequent changes remember that path. I'd like to automate that a bit and default that field to the drawing's working path to get you started. So far, from this post, I am at:

      
      @svgFilename = Sketchup.active_model.get_attribute "foi_svg_export", "svgFilename", File.dirname(mymodel.path)+mymodel.title+".svg"
      
      

      But instead of "C:/users/user/desktop/Untitled.svg" I get "C:usersuserdesktopUntitled.svg" (note the lack of slashes)

      Also, I have a feeling that I'll need to add a slash on my own after the path and before the model. But I can't seem to get that working either.

      Any ideas/help?

      Thanks!

      posted in Developers' Forum
      W
      whodah
    • 1 / 1