Hello People I got this face with it’s own 10 edges.
I need to make a Ruby Extension to change the Starting Edge of a Face like this.
Hello People I got this face with it’s own 10 edges.
I need to make a Ruby Extension to change the Starting Edge of a Face like this.
Why do you need to change it?
If it’s only one face, you could do it manually.
What difference does it make to your modelling?
I understand the question (but not how to solve it). But I don’t understand at all the reason why you want to do it in the first place. If you could clarify that, there might be a different kind of solution to a higher order question.
Well I find a ruby script for CNC machine and based on it I build my own one ; and it works properly; what it mainly does is to search on my sketchup document for faces and then export all coordinates to a file as Gcode; it does it pretty good; but sometimes depending of the model I need reorder the start edge.
Anyway I confesses I don’t know how to get it manually.
Any help are welcome
Thanx in advanced
What I know SketchUp offers no way to change the edge order. In a more technical application like Rhino I can imagine it’s a standard procedure, but in the friendly SketchUp world where technical phrases like vertex are never used, users aren’t even expected to know there is an order to the edges.
If you need a different order for an exported file I’d change the order at the export level, not change the model itself. You could have an attribute that identifies the starting edge, and then use Ruby’s Array#rotate method to get an array of the edges starting where you want it to start.
you don’t need to actually change them in the .skp file to export in a different order…
this is a demo of rotating the points array, which you could then export, as @eneroth3 suggests…
the centre points are added in the corrected order…
model = Sketchup.active_model
ents = model.entities
view = model.active_view
face = ents.grep(Sketchup::Face)[0]
loop = face.outer_loop
edgeuses = loop.edgeuses
pts = []
edgeuses.each{|use| pts << use.edge.start.position.to_a}
until pts[0][1] == face.bounds.min[1]
pts.rotate!
end
pts.each{|pt| ents.add_cpoint(pt)
sleep 0.5
view.refresh}
john
Thanx you all; it’s much more than I needed it
I’m so crazy to arrive home to test yours ideas; I keep you posted.
Thanx you again
Hi again, I’ve trying to understand how array rotation works and I’ve been making some test. I got so many funny results.
1 – I wrote this:
mmm = ["Me", "You", "She", "world"]
mmm.rotate
I ran it and I god [“You”, “She”, “world”, “Me”] Fantastic this is too easy!!!
Then I added some simple single line of code;
mmm = [“Me”, “You”, “She”, “world”]
mmm.rotate
Print “mmm = ”, mmm
And I got [“Me”, “You”, “She”, “world”]; no rotation!!!
What’s a happening my friends?
Rotate returns a new Array. If you want to rotate the existing object you need to use rotate!.
Thank you Eneroth; I realized that when assign the result of rotate to its own array:
mmm = mmm.rotate;
Thank you so much for your help;
Is it possible to guide me for including an attribute on a point; or should I start a new post?