Converting model to Ruby script


#1

Continuing the discussion from [Code] Sorting an array of class identifiers by ancestry:

I suppose we could. But why? A skp file is probably the most condensed and best format for a SketchUp model file.


#2

I agree. This begs the question, “why? what is the use case?”


#3

Well you got me think there. Do you teach ruby?


#4

Dan does a tremendous amount of helping people with Ruby on this and other forums, but the questions remain: what are you hoping to accomplish? what is the point of representing a model as a collection of code that draws it rather than directly as the result? Is your objective simply to learn Ruby programming to the SketchUp Ruby API?


#5

Well I am looking to learn. I just assumed that the file size would be smaller in ruby format.


#6

Well, Ruby is a programming language, not a format.

But, that aside, a program to create your model would need to contain all the fundamental data (locations of all vertices and logical relations among them such as where edges and faces should join) plus the code to invoke SketchUp API methods to construct SketchUp entities from it. For that to be smaller than a SketchUp model, the SketchUp model file format would have to be less efficient than the Ruby code. That could happen, for example, if the model contains a lot of entities that are identical except for their data parameters, in which case a small amount of code could possibly draw them all. But it could not be assumed in general.