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

    Ruby plugin - Export from skp to Quake .map file

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 921 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.
    • P Offline
      pyrvs
      last edited by

      Hi! I'm a noob at ruby scripts and I'd like to make a ruby plugin for converting sketchup models to GTK Radiant editor (Quake III Arena) .map files.
      The .map file is basically a .txt file structured as follows:

      **```
      //entity 0
      {
      "classname" "worldspawn"
      // brush 0
      {
      ( 126 -344 92 ) ( 130 -344 92 ) ( 130 -352 96 ) common/caulk 0 0 90 0.25 0.25 0 0 0
      ( 126 -336 128 ) ( 126 -352 128 ) ( 126 -336 0 ) gothic_ceiling/woodceiling1a 0 0 90 0.25 0.25 0 0 0
      ( 130 -344 92 ) ( 126 -344 92 ) ( 130 -344 0 ) gothic_ceiling/woodceiling1a 0 0 90 0.25 0.25 0 0 0
      ( 130 -352 0 ) ( 130 -336 0 ) ( 122 -352 0 ) common/caulk 0 0 90 0.25 0.25 0 0 0
      ( 130 -352 0 ) ( 130 -352 128 ) ( 130 -336 0 ) gothic_ceiling/woodceiling1a 0 0 90 0.25 0.25 0 0 0
      ( 130 -352 0 ) ( 122 -352 0 ) ( 130 -352 128 ) gothic_ceiling/woodceiling1a 0 0 90 0.25 0.25 0 0 0
      }
      }

      
      where, in a brush (a block), each line represents a plane whith its texture. Each plane is represented by 3 coordinates (a triangle). Planes can only define convex brushes (blocks); no concavities allowed
      
      **```
      //entity 0
      {
      "classname" "worldspawn"
      // brush 0
      {
      ( x y z ) ( x y z ) ( x y z ) texturefolder/texture sShift tShift rotation sScale tScale |detail|structural| 0 0
      ( x y z ) ( x y z ) ( x y z ) texturefolder/texture sShift tShift rotation sScale tScale |detail|structural| 0 0
      ( x y z ) ( x y z ) ( x y z ) texturefolder/texture sShift tShift rotation sScale tScale |detail|structural| 0 0
      ( x y z ) ( x y z ) ( x y z ) texturefolder/texture sShift tShift rotation sScale tScale |detail|structural| 0 0
      ( x y z ) ( x y z ) ( x y z ) texturefolder/texture sShift tShift rotation sScale tScale |detail|structural| 0 0
      ( x y z ) ( x y z ) ( x y z ) texturefolder/texture sShift tShift rotation sScale tScale |detail|structural| 0 0
      }
      }
      
      ```**
      I think what I'm trying to script is at least conceptually quite easy, but I don't know how to start..
      The main question I ask is how to make sketchup creat a txt or map file to input converted data into?
      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        The SketchUp API does not have IO methods... That is standard to Ruby.

        So you need to 1st learn standard Ruby.
        Ruby Newbie's Guide to Getting Started

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • P Offline
          pyrvs
          last edited by

          Ok, i've been playing around with the ruby console in sketchup and some of those tutorials (Thanks for the links!) and at least I wrote some commands I liked:

          
          Dir.chdir("/Temp")
          File.new("newfile.map",  "w+")
          
          

          And that creates a new .map file in the Temp folder for me to write into. Does anyone know how to make a "select folder" popup, or save the file in the same folder as the .skp?

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

            Sketchup's UI API UI.open_panel(), and save_panel() etc
            Then folder=File.dirname(model.path) etc
            Read both the API, AND the general Ruby File/Dir stuff together...

            You don't need to use Dir.chdir() if you give File.new(fpath, 'w') the full-path to the file... which you can of course pre-assemble from the model's directory path and the new file's name, thus
            fpath=File.join(File.dirname(model.path), 'my.map')

            Of course you can check that the model has been saved and therefore not model.path.empty? before proceeding etc...

            TIG

            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