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

My ruby read write file error when loading them

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 957 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.
  • D Offline
    dukejazz
    last edited by 20 Aug 2014, 23:48

    So would you want me to init open my r/w file each time you start-up skeckup so that my ruby can be loaded with-out r/w error?
    (or can I make some subloop process when you only inial or postial run the ruby function.to open or close r/w file)

    The problem is the comfirm init open r/w file menu process, I wish I could init open my file with out open file menu and select process.

    Dose anyone use read/write funtion?

    Dose the r/w section of ruby init load only to seketchup untill some one call it thou the open file process.

    It must be something simple?

    or I missing some info to sheckup process to init open r/w function.

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 21 Aug 2014, 11:28

      You issue is not expressed clearly. 😞
      Can you simply explain what is is you want to do...

      Any RB files in Plugins auto-load as SketchUp starts.
      You can manually use load('somefile.txt') after it is done - the TXT file won't have auto-loaded before that.

      You can certainly use fi=File.open(fullfilepath, 'r') or fi=File.open(fullfilepath, 'w').
      To get the file's contents you could also use contents=IO.read(fullfilepath)
      To get an array of 'lines' use lines=IO.readlines(fullfilepath)
      To write to a file there are several ways...
      fi.write(stuff) fi.print(string) fi.puts(line)
      etc...
      Don't forget to tidy up with fi.close afterwards, if using 'open' and completing the 'writing' etc, otherwise it is stuck open and can't be accessed by another process until SketchUp is closed.
      Note how you need to pass the FULL path to the file your are opening to read/write...
      If it does not exist it is made.
      Unless you use the second argument of 'a' to 'append' [instead of 'w' for 'write'] the file's contents will be overwritten.

      TIG

      1 Reply Last reply Reply Quote 0
      • D Offline
        dukejazz
        last edited by 21 Aug 2014, 20:42

        Thanks Tig

        load('somefile.txt')

        it's was something simple

        now

        errors and fix menu's begone

        I fixing my massive inputbox and Var array (to a eazier to use floting WebDialog for inputing and smaller number of data arays need to control my processing )

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

        Advertisement