Average color pasted instead of texture. Why?
-
Hi,
I try to paste some images as textures on SketchUp Face objects.
I calculate coordinates for material positioning and create new material with texture and past on the face. And this procedure works very well on numerous test models I've experimented with.But I've created new model yesterday, and got strange material pasting results.
Instead of image texture, I got pasted image average color.
This is not a problem with material positioning, because when average color is pasted I don't have in context menu 'Texture' submenu.Note, I haven't changed my code for pasting, I tried this same model in Sketchup 8, 2013 and 2014 and always the same result.
If I copy complete geometry and paste it in some other model or even "Paste in place" in the same model, textures are positioned correctly.Code snippet to give idea what I'm doing. All variables on right side of statements are already calculated:
material = Sketchup.active_model.materials.add("new_material") material.texture = filename material.texture.size = [width,height] on_front = true position = [coords[0],image_pt_array[2],coords[1],image_pt_array[1]] face.position_material(material,position,on_front)
I also tried to inspect face when texture is pasted as average color and when it is pasted as image and in both cases I get the same output
Vertices (3.65m, 0m, 0.71m) (3.65m, 1.3m, 0.71m) (2.53m, 1.3m, 0.71m) (2.53m, 0m, 0.71m) Material color Color(150, 208, 32, 255) Material type 1 material name fc_sunexp_2966303 Texture average color Color(150, 208, 32, 255) Texture filename C:/Users/Marija/MyPrograms/Daylighting_plugin/test_model/sunexposure_output/fc_images/Layer0_f_2966303_0_simple_exposure_standard_summarized_year_total_sunexposure_final.jpg Texture image width, height 100, 116 Texture width, height 51.1811023622047, 59.3700787401575 Texture valid true Front UV u=~ 0.03m v=~ 0.03m u=~ 0.03m v=0.00m u=0.05m v=-0.00m u=0.05m v=~ 0.03m Back UV u=3.65m v=0.00m u=3.65m v=1.30m u=2.53m v=1.30m u=2.53m v=0.00m
My question is:
- Why is material pasted as its average color instead of original image?
- Have I accidentally set some faces' property/flag while I was creating Sketchup model, so materials are pasted wrong?
Since I've tried this same code numerous times, and never had problem like this, so I suspect I've done something 'wrong' while creating a model.
I'm sending image with example in attachment.
Thanks in advance,
Marija
-
I've found the problem 2 minutes after I've sent the question
In "Styles" toolbar "Shaded" option was toggled on instead of "Shaded with textures" when I created and saved Sketchup model for the first time.
When I switched to correct style, everything shows as it should be!
I'll check if there is a way to set this "Style" automatically when user works inside plugin, so correct textures are shown.
-
You might use a send action string.
See: Re: [Code] Sketchup.send_action() : Arguments to...the strings for rendering:
%(green)["renderHiddenLine:" "renderMonochrome:" "renderShaded:" "renderTextures:" "renderWireframe:"]
Example:
Sketchup::send_action("renderTextures:")
-
Thanks Dan,
That is exactly what I needed!
Advertisement