How to read .skp files in ruby?
-
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?
-
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 -
Thank you
-
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 ....
-
@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 frommodel.entities. Everything inmodel.definitionsbelongs to groups, components or images. -
When you import a model, the entities (edges, faces, groups,... ) don't go directly in model.entities. They are encapsulated in a new component....
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement