Texture inconsistent on the same component in different locations

Hi Dan,

What code do you use to hold the array of curve faces? And if done this way, everything will be able to be done through script with no manual input needed?

fs = sel.grep(Sketchup::Face)

Well I manually selected the curve faces. So see the other thread on getting an array of the faces.

All I can say is it worked for me.


Would it matter that the part I am trying to texture is in a group? The following code is what I am using and it isn’t working for me. Still breaks up the texture on each face of the curve.

group = entities.add_group
entities1 = group.entities
edges1 = entities1.add_arc base_centerpoint, vector2, vector1, 33.107, 0.degrees, 90.degrees, numsegs = 23
edges2 = entities1.add_arc base_centerpoint, vector2, vector1, 40.107, 0.degrees, 90.degrees, numsegs = 29
edges3 = entities1.add_edges [@x-3.50,@y-36.607,@z+0.001], [@x+3.50,@y-36.607,@z+0.001]
edges4 = entities1.add_edges [@x-36.607,@y-3.50,@z+0.001], [@x-36.607,@y+3.50,@z+0.001]

base_face = entities1.add_face *edges1,*edges3,*edges2,*edges4
entities1.grep(Sketchup::Edge).each{|e| e.hidden=true }
base_solid = base_face.pushpull -height

selection = model.selection.add(entities1.to_a)
sel = Sketchup.active_model.selection.grep(Sketchup::Face).each{|e|e.material=wallmat}

Face#material doesn’t set any texture mapping, it merely sets the material property of the face. Setting the UV mapping is not trivial but can be done. TT’s QuadFace tools does it


Thank you for the feedback. I guess I didn’t realize that the paint bucket tool was so complex, and it looks like what I’m trying to do is a lot harder than I initially thought…

I noticed that when I select all of the faces of my group through ruby script each face on the curve is selected separately, but when I use the select tool manually it highlights the whole curved surface like it is one face. Is it possible to do this with code? Or is the select tool much more complicated than I thought too?

The gif below shows what is selected when I run my code verses what gets selected when I use the select tool. Sorry for all of the visuals, but that is how I learn best, and it helps me realize what I am trying to say since I am pretty new to coding especially with SketchUp.


I was testing inside a component instance context. So no I do not think it matters.

Re, your code,
(1) please quote it correctly for the forum
(2) I cannot test as it has variables I do not know the value of. (When you post code, please post code that others can test.)
(3) Do not use weird odd numbers of segments for curves and circles. (This causes problems where cardinal points do not fall on vertices. Should use an even number that divides into 360 well, ie, 6, 8, 12, 16, 18, 36, etc.)

EDIT: Oh, and post the material if it’s not one of the distro SketchUp materials.

The main difference is that in my test, I did not make the bottom curve’s edges hidden before pushpull.
Instead, I only made the vertical inner edges of the inner curve surface hidden, after pushpull.

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)

1 Like

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 }
1 Like

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.

1 Like

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

1 Like

… 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.