Re-applying materials after scaling?
-
Let's say I have a component with a vertical wood grain material. If I make the component larger in the vertical dimension, the material stretches. This makes the wood grain distort (eg, look "blurry").
Using the UI, I can repair this damage, by sampling the material on a face in an unstretched component, then doing a "Paste all" into a vertical grain face in the stretched component. However, I can't figure out what part of the API would allow me to do this.
Using the UI, I set up "before" and "after" files. I then compared a number of values, including the material's color, display_name, and name. None of these appear to change.
The object ID for the material's texture changes, but I see no change in the texture's height, width, image_height, image_width, average_color, or filename.
What am I missing?
-r
-
http://code.google.com/apis/sketchup/docs/ourdoc/
uvhelper
.html and http://code.google.com/apis/sketchup/docs/ourdoc/face.html#get_UVHelper
look like they might help, BUT these really only apply to faces not instances... there is no equivalentinstance.get_UVHelper
method.You are applying the texture to faces in the component-instance itself NOT a face ?
So such textures will inevitably scale [as also when they're applied directly to a face inside a definition].If it were a group then grouping that group itself [to keep geometry separated] then exploding the group inside it will revert the scaling of the texture as the container group is not itself scaled - you could remember the original group's name/desc/attributes beforehand and then apply them to the new group...
The somewhat simpler fix with components is to have 'sets' of similar components, partially sized initially with size ranges - say c0-12, c12-24, c24-36, c36-48 etc... [where it's 0"-12" say]: then you'd swap the initial instance's definition for one that is nearest the scaled size, and then the textures will adjust slightly, but to a limited extent which will have little visible variation. So for example you initially place c0-12 and it's to be scaled to 30" long - a simple lookup method says "
if dim>24 and dim<=36 then defn='c24-36'
", so you set yourinstance.definition=definitions[defn]
and then the subsequent scaling of that instance's textures is now acceptable because the definition was already made near to that size -
.
Advertisement