Material by Layer in Ruby
-
We are trying to access Material by Layer information, using Ruby, for rendering and RPS 3D PDF.
We are able to extract the texture image for the material using Texture Writer.
However, we could not access the material size, and other information.
We can do this using the SDK exporter, but we would prefer to do it directly in Ruby.
Has anyone been able to access the material assigned to a layer from Ruby?
-
Materials don't have layers. Faces and edges have layers and materials.
Todd
-
@unknownuser said:
Materials don't have layers. Faces and edges have layers and materials.
Todd
That is true. However they have a thing that acts a lot like a material in the Color by Layer dialog:
We are able to extract the texture image from this, but not the size.
We are able get both using Skp_Reader (C++ code), but cannot access them from Ruby.
-
Materials don't have layers, but layers can have materials.
Unfortunately, Google has not provided ruby access to the layer material.
-
I wrote this work around a while ago... It does it by making an obj export of the model set 'material by layer' temporarily, and then using its mtl file to get the layers and colours... that's as good as it gets... You could use the data from the temp file rather than write a csv ? You could even export it all to a temp folder and delete that at the end if required ?
-
Al, since you can get to the data you need via the SDK, write a C/C++ extension that returns the data to Ruby.
Todd
-
We are going to write an Exporter, but that has the disadvantage of only working with the Professional version of SketchUp.
We can write an external program using SKP_Reader, but that will require that the user save the current model before rendering it.
We would like to get this information from the current model, in the free version, without saving the model. (If possible)
@unknownuser said:
Al, since you can get to the data you need via the SDK, write a C/C++ extension that returns the data to Ruby.
Todd
-
What's wrong with this agonizing approach:
- create an "array entry" for every layer
- For every group/component/entity...
- determine if it has any material associated with it
- if so, for it's layer "array entry", add the material to it as a subarray
When done, you have an array of layers, and each layer records the materials in it.
From the first post, I thought I was missing the obvious. This is the obvious approach.
Since materials don't have layers, but objects have both materials and layers, you just have to run the objects and make your own list. From my perspective, no big deal - it's just not a quick call to any singe method to get it done.
Todd
-
pitty that Sketchup.active_model.sapidoc is not available in SU6 anymore
-
Shoot!
This was a good idea TIG, but the .mtl file does not contain the texture size information.
@unknownuser said:
Alias OBJ Material File
Exported from SketchUp, (c) 2000-2006 Google, Inc.
newmtl Layer0
Ka 0.000000 0.000000 0.000000
Kd 1.000000 0.000000 0.000000
Ks 0.330000 0.330000 0.330000
map_Kd test4/Layer0.jpgKd is the color, but when I change the texture size and export it again, nothing in the file changes to match it.
I guess we'll have to write our own exporter...
@tig said:
I wrote this work around a while ago... It does it by making an obj export of the model set 'material by layer' temporarily, and then using its mtl file to get the layers and colours... that's as good as it gets... You could use the data from the temp file rather than write a csv ? You could even export it all to a temp folder and delete that at the end if required ?
-
We will look at this again, but I believe the group/component/entity will report its own material and not the "Color by Layer" material.
But we will try it. It would be a shame to miss the obvious answer.
TextureHelper lets us save copies of the texture file for the layer, but neither Texture Helper of UVQHelper seem to let us access the texture size.
@unknownuser said:
What's wrong with this agonizing approach:
- create an "array entry" for every layer
- For every group/component/entity...
- determine if it has any material associated with it
- if so, for it's layer "array entry", add the material to it as a subarray
When done, you have an array of layers, and each layer records the materials in it.
From the first post, I thought I was missing the obvious. This is the obvious approach.
Since materials don't have layers, but objects have both materials and layers, you just have to run the objects and make your own list. From my perspective, no big deal - it's just not a quick call to any singe method to get it done.
Todd
Advertisement