• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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 19 May 2014, 13:38

    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
    • T Offline
      tt_su
      last edited by 19 May 2014, 14:00

      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 20 May 2014, 12:10

        Thank you

        1 Reply Last reply Reply Quote 0
        • P Offline
          pgarmyn
          last edited by 20 May 2014, 17:55

          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
          • T Offline
            tt_su
            last edited by 20 May 2014, 22:26

            @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 21 May 2014, 19:45

              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
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement