Yes, I got that.
Thx!
Ok, I see. That also explains why find_faces
didn´t work on neither of the edges.
So add_face(edgearray) doesn´t work on API created egdes? Or is there a command that forces edges to merge to loops if possible?
But I can´t see the face on your screen, only four edges?
Here ist what it looks like when I execute the code on my machine. Maybe it´s a difference, because I use Ruby Code Editor?
[xxl-img:xg9qtt3f]http://www.steffenblome.de/add_face.jpg[/xxl-img:xg9qtt3f]
as you can see I used
ent = mod.entities
but I just tried
ent = mod.active_entities
with the same results.
And thanks for that advice on how to create a face with a hole, I´m going to use that.
In the Ruby API it says that youn can create a face by passing an array of edges as an argument:
@unknownuser said:
Entities.add_faceSketchUp 6.0+
The add_face method is used to create a face. You can call this method a number of ways:entities.add_face(edge1, edge2, edge3, ...)
entities.add_face(edgearray)
entities.add_face(pt1, pt2, pt3, ...)
entities.add_face([pt1, pt2, pt3,...])
entities.add_face(curve)
I tried it like this
punkteArray = []
edgeArray =[]
punkteArray.push(Geom;;Point3d.new(0,0,0))
punkteArray.push(Geom;;Point3d.new(100,0,0))
punkteArray.push(Geom;;Point3d.new(100,0,100))
punkteArray.push(Geom;;Point3d.new(0,0,100))
punkteArray.push(Geom;;Point3d.new(0,0,0))
edgeArray = ents.add_edges punkteArray
face = ents.add_face(edgeArray)
but that returned nil and no edges were drawn at all. I know that I could have used
face = ent.add_face(punkteArray)
but I was hoping to be able to create a face with a hole in it by passing an array with the outer and inner loop edegs to the add_face method, but not even passing a single loops seems to work.
Since I now have working code I better not change it, but I´ll keep your advices in mind for further projects. I´m afraid I won´t be able to explain all my goals, since my English isn´t that good and it´s hard to explain just by text. (And actually I just wanted to know how to reverse edges, but of course any further information is welcome!)
Thanks for your support!
I already deleted the old code, but it was something like this:
edgeUses = loop.edgeuses
firstEdge=edgeUses[0]
currentEdgeUse = firstEdgeUse
nextEdgeUse = currentEdgeUse.next
while (currentEdgeUse.edge.end != firstEdgeUse.edge.start)
endPoint = currentEdgeUse.edge.end
if ((endPoint != nextEdgeUse.edge.start) && (endPoint != nextEdgeUse.edge.end))
puts "current Edge and next Edge not connected!"
end
...
wrap nextEdgeUse.edge and swap start and end if necessary
...
currentEdgeUse = nextEdgeUse
nextEdgeUse = currentEdgeUse.next
end #of loop
This code does not reflect using the wrapper class. just assume that edge.start and edge.end are in correct (continous) order. My point is, that using that code on the six faces of a cube the if-statement was true several times which to me means, that you can´t be sure "next" returns an adjacent edge(use). (Of course I could be wrong!)
My goal is (simplified) to let the user redefine the coordinates of vertices. Therefore I pick one vertex (point 1) which can not be modified as a reference point and then the user can edit the coordinates of the next point (point 2) relatively to point 1, so point 2 also has fixed coordinates. Then the user can edit point 3 relatively to point 2 and so on.
This works fine, now I´m trying to deal with faces with holes in them, respectively faces with more than one loop.
I used EdgeUses, but they are useless...
At least for my purpose. The reason is, that the "next"-method doesn´t necessarily seem to return an edge which is adjacent to the edge on which the method is called.
I solved my problem like this:
first I wrote a method to traverse through the edges of a loop in one direction until returning to the first edge.
While doing so, I saved all edges in an Array, but before I wrapped the edges in a class "EdgeWrapper". This class has three attributes: the edge-object and two vertices called "start" and "end". EgdeWrapper.start is initialized with EdgeWrapper.edge.start an EdgeWrapper.end with EdegWrapper.edge.end. If I want to change the edge orientation i can assign EdgeWrapper.edge.start to EdgeWrapper.end and EgdeWrapper.egde.end to EdgeWrapper.start.
Of course creating a class inherited from "Edge" with additional start and end vertices would also have been possible (and maybe better), but for my needs the above works fine.
Hi there!
I need to swap start and end points of edges, for I need the orientation of edges on a face to be a contnious loop. (I´m aware of the outer_loop method of faces, but for certain reasons it doesn´t fit my needs.)
In a single face the edges are continous (which in my definition means every start point of an edge is the end point of exactly one other edge), but if you look at the side faces of a cube, both vertical edges seem to be oriented in positive z-direction.
Therefore I´m trying to implement same sort of "reverse"-method for edges.
my attempts so far:
new_edge = ents.add_edges edge_to_reverse.end.position, edge_to_reverse.start.position
edge_to_reverse.erase!
that didn´t work, for when erasing the original edge, the newly created edge will also be erased.
My second approach was to save the original edge´s vertices, delete the edge and then draw a new one using the saved Points:
new_start = edge_to_reverse.end
new_end = edge_to_reverse.start
edge_to_reverse.erase!
new_edge = ents.add_edges new_start.position, new_end.position
this work quite well, but the face is beeing erased when deleting the old edge. Not a big deal, I just added the face again using the find_faces-method:
new_edge.find_faces
So that is nearly what I wanted to achieve, but there is (at least) one problem: if there is a face with a hole in it, the find_faces method might eventually fill this hole with a face.
any suggestions?
I didn´t know about that possibility and it really seems to be just what I´m looking for. I will definitely give it try.
Thanks!
Thanks for your advices. I have tested the post_url method before, but I guess you can only submit the values of <input> elements like text areas or buttons in the url, no images. I decided to drop that feature for now, may I will implement it later. There seem´s to be another approach using the flash file upload abbility, may be I´ll give it a try then.