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

    How to read .skp files in ruby?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 702 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.
    • R Offline
      rahulnejanawar
      last edited by

      Hi,

      I have written some plugins and I have some .skp files containing some models.

      I want to be able to read these files programmatically and run my plugins on those models. Is it possible?.

      I read about Sketchup C API. This is C. My plugins in ruby. So I was not sure how to use them together. Is the ability to read .skp files and get models available in ruby? Any pointers to examples?

      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        You can only read the open model in Ruby. To read SketchUp models on disk you need to use the C API. We have made a Ruby C++ extension example that can be used as a boilerplate for using C_libs - like the C API:
        https://github.com/SketchUp/ruby-c-extension-examples

        1 Reply Last reply Reply Quote 0
        • R Offline
          rahulnejanawar
          last edited by

          Thank you

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

            A workaround is to import the model.
            The first added definition contains the loaded model, the other definitions are those of the nested components and groups.
            Your plugin can retrieve information, or modify those definitions, write them back to disk and delete the instance and definition of the loaded model.

            But there can be name-conflicts (materials, components...) beween the loaded and the main model. EG: Sketchup will rename the materials of your model if ....

            1 Reply Last reply Reply Quote 0
            • tt_suT Offline
              tt_su
              last edited by

              @pgarmyn said:

              The first added definition contains the loaded model, the other definitions are those of the nested components and groups.

              ❓ What do you mean by that?
              The root model entities are only available from model.entities. Everything in model.definitions belongs to groups, components or images.

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

                When you import a model, the entities (edges, faces, groups,... ) don't go directly in model.entities. They are encapsulated in a new component....

                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