How do you move vertices?
-
@unknownuser said:
I would like to see .pushpull return an array of newly created edges and faces, with the opposite face listed first.
That would be great.
That makes sense to compare and subtract, then find the leftover entity with the normal that matches the original face. That did not cross my mind to search that way. Thanks guys! I'll post it when I get it written (probably after work or during lunch).
@unknownuser said:
@Chris - a terminology thing: we're not dealing with "names" of faces. We're dealing with Object References.
Oops, I'll work on my terminologyChris
-
ok, here is the code I put together based on your guys comments. It gets all geometry before pushpulling, then all geometry after pushpulling and does a subtraction, leavin just the new stuff. Then searches through that for a face with a normal == to the original face's normal. Thanks for the help on this. Now I can do a uniform scale on the new face. So I'll incorporate it all into my greeble script later today I hope. Thanks!
model = Sketchup.active_model entities = model.selection # Initialize my Arrays existing_ents = [] current_ents = [] new_ents = [] # Define existing entities and then push.pull my face existing_ents = entities[0].all_connected entities[0].pushpull( 100, true) # Define all entities after the push.pull current_ents = entities[0].all_connected # Define new entities through subtraction new_ents = current_ents - existing_ents # Loop through each new entity to find the faces, # then find just the face with its normal matching the original face # Send a quick text to the Ruby console and paint the face to show it worked new_ents.each do |ent| if ent.typename == ( "Face" ) if ent.normal == entities[0].normal puts "Found it! The Object Reference is " + ent.to_s ent.material = [0,0,0] end end end
This script requires having a single face selected when the script is run.
Chris
-
For your playing around with stuff like this, (and I encourage it), here's a tip. Instead of this:
entities = model.selection . . existing_ents = entities[0].all_connected
Do this, and it's less typing:
entity = model.selection[0] . . existing_ents = entity.all_connected
That way, you get rid of the array reference early and no more qualifying every use with [0].
For short stuff (shorter than this), I just use the console.
-
Ahh, very helpful, thanks again Todd,
Chris
Advertisement