Texture inconsistent on the same component in different locations


Sorry for the code issues. My .rb file can be found here: Component test.rb (2.2 KB)

I changed the number segments for the curves and switched the material to SketchUp’s “Concrete Block 8x8 Gray” for simplicity.

I also tried to select only the vertical edges but failed to do that… (commented out code) I struggle with calling out of components that are not initially named or created by myself.


I see what you see when I test your code.
No amount of selecting or setting the edges soft, smooth or hidden helps.


To grab the faces that make the ‘curved face’ you navigate through an edge.curve reference to find all attached faces. And then, in this example, throw away the face that is the bottom of the wall. For example

# add this after your line 42 which was
#selection = model.selection.add(entities1.to_a)

curve = edges1[0].curve
faces = []
curve.each_edge {|e| 
  e.faces.each {|f| 
    faces << f
faces.flatten! #edit, this is not needed, duh

# remove the one face whose normal has a negative z value
faces.reject! {|f| f.normal.z <0}

selection = model.selection.add(faces.to_a)

Component test just select front face.rb (2.5 KB)


Wasn’t mine posted above a bit simpler ? :stuck_out_tongue_winking_eye:


Thank you for the instructions! The code you provided does in fact select the front (curved) face, but I still can’t get the texture placed on it evenly and I’m sure it’s because of what Eneroth posted above. I’m hoping I can find a relatively easy way to apply the texture without having to project it.


So do you think that applying a smooth texture to this curved face is not possible without maybe projecting the texture?


Well, I noted that Thomas said this isn’t yet possible with the API (in post 3 above) …

I looked at TT’s QuadFaceTools but didn’t get too much into the UV settings.
He did set hidden, soften and smooth on all break edges for surfaces. Thought we’d try this.
We, did, and it wasn’t enough.





Shoot. Do you have any other suggestions for how to apply a texture to this face with only code? The only way I’ve read about for my situation is projected textures since the texture positioning is not functioning properly.


This does not eliminate the bottom face (which has more than 4 vertices.)
Perhaps ?

curve.edges.flat_map(&:faces).uniq.reject {|f| f.vertices.size>4 }


Look at the TT code suggested above.

Which is not working in the present versions of the API according to Thomas.
Well, it does work… but it may corrupt the model file or cause SketchUp to believe there is something needing fixing which may or may not be true. (The result was kind of vague. See the other thread you started on texture projection.)

I know it’s a bummer, but like I’ve had to shelve many half finished extensions because of lacking features or bugs in the API. I can’t see this one lasting much longer though. Especially since ImageRep was implemented.


Well thank you for all the help Dan, you’ve been very helpful and I’ve learned a lot!


… we try our best.


Actually another idea just came.
I wonder if the “fix errors” bug could be worked around by creating a component writing it to disk, undoing and purging the in model component, then loading the one from disk ?

Or maybe close the current model, do this in a new model, and then reopen the original and load the component ?

Ie, the main idea is to avoid the model “needs fix” corruption.


Oh Duh! We overlooked the other method … Sketchup::Face#position_material()

This is the method Thomas is using in QuadFaceTools "entities.rb":line 686


Great find Dan! Although, I’m not really sure how to use this command…

From looking at the code it seems like the variables are my material, a an array of points that links my face and reference point, and a boolean of if I am using the front face of my surface…?


Yup that’s it.



Yes Dan, I’m making progress with this find! I feel as though I’m one step away from finally finding my answer. Using the position#material code I can map the texture on my bottom face correctly. Now my only issue is that when I pushpull the face up, the texture on the curve is not affected by the position#material code and is the same as always…

Any ideas on how to use this code on the faces of the curve?


You’ll have to map the texture across the curve’s faces so that the texture aligns across each break.


So I’ll map each of the faces on the curve separately?