Pushpull coding problem
-
I have a 1/4 circle, and the face defined
how do I code the pushpull?e = entities.add_arc([x+$dist, y+$dist, z], vecx, vecz, $d/2, 0, pi/2, $s)
e = entities.add_line([x+$dist, y+$dist, z],[x+$dist, y+$dist+$d/2, z])
e = entities.add_line([x+$dist, y+$dist, z],[x+$dist+$d/2, y+$dist, z])
e.find_faces # the face is now defined
e.pushpull $thick #thick is definedtia
-
Before the .find_faces, do an inventory of all the faces in your current entities set.
After the .find_faces, do a second inventory of all the faces in your current entites set.
Subtract the first inventory from the second.
With the remaining elements, find the face with the same normal as the one you pushpulled.Todd
-
The code you have won't work.
"e" is an edge. e.find_faces works for edges, so it's good.
e.pushpull will never work, 'cuz .pushpull only works on faces.
Remove the e.pushpull, do what I said in the first post to come up the new face, and then do the pushpull on that face.
Todd
-
Sorry but I don't understand your coding lingo
But I did find an example piece of code from a previous Ruby that works
model.entities.add_arc([x+@dist, y+@dist, z], vecx, vecz, @d/2, 0, pi/2, @s)
model.entities.add_line([x+@dist, y+@dist, z],[x+@dist, y+@dist+@d/2, z])
e=model.entities.add_line([x+@dist, y+@dist, z],[x+@dist+@d/2, y+@dist, z])
e.find_faces
e.faces.first.pushpull @thickdo I understand the following correctly?
"e",collects the 3 entities (arc, line & line)
"e.find_faces" ,then makes the face out of the entities
now what does "first" do because without it pushpull still wont work?
tia
-
That won't work. I don't have time now to respond, but will later tonight.
I've posted the code to do this somewhere before. Perhaps in the old pro Ruby forum. Maybe you can search on "find_faces" and "pushpull" to locate it.
Todd
-
Todd, I think you misread my last post.
I found that code in a another Ruby, and applied it to my example. and viola it WORKS!
what followed was my understanding of what I thought the code was doing.
I would like you to comment if my understanding is correct.and I don't understand why adding ".first" make the pushpull work?
-
@tomot said:
model.entities.add_arc([x+@dist, y+@dist, z], vecx, vecz, @d/2, 0, pi/2, @s)
model.entities.add_line([x+@dist, y+@dist, z],[x+@dist, y+@dist+@d/2, z])
e=model.entities.add_line([x+@dist, y+@dist, z],[x+@dist+@d/2, y+@dist, z])
e.find_faces
e.faces.first.pushpull @thickdo I understand the following correctly?
"e",collects the 3 entities (arc, line & line)
"e.find_faces" ,then makes the face out of the entities
now what does "first" do because without it pushpull still wont work?
tia
You are right - I misread. No, you don't understand correctly. But you will soon enough.
@unknownuser said:
"e",collects the 3 entities (arc, line & line)
No. This assignment to "e" only assigns that last line (edge). You only need to .find_faces on a single edge for a closed loop of lines in order to get a face. So, your assignment is correct. You could have performed the .find_faces on the other line, or, any segment of the arc, and you would get the face like you want.
@unknownuser said:
"e.find_faces" ,then makes the face out of the entities
Basically, yes. The method looks at the edge you pass, then goes through all edges connected to the edge you passed, and for every closed and coplanar loop of edges that can be found, faces get made.
@unknownuser said:
now what does "first" do because without it pushpull still wont work?
The .first method will pass the first array element to pushpull. Your code is:
@unknownuser said:
e.faces.first.pushpull @thick
e is an edge.
e.faces is an array of all the faces that use this edge.
e.faces.first is the first element (the first face) in the faces array.
e.faces.first.pushpull calls the pushpull method for the passed face. (e.faces.first).See the doc here: http://www.ruby-doc.org/docs/ProgrammingRuby/ for the Array class and its methods.
The .pushpull method is defined to be called for a face, not for an array. When you use the .first method on the faces array, you are picking a random face (the first one in the array at position face[0]), and it will pushpull just fine. Note that you are doing nothing in your code to identify the exact face you want to pushpull - you're just picking, essentially, a random face. So, yes, the pushpull works, but no, it's probably not acting on the face you want. If it is acting on the face you want, they you are a lucky person, because of all the newly created faces, the one you wanted jut happened to be the first one in the array.
Todd
-
Hi,
The simplest way:arc= model.entities.add_arc([x+@dist, y+@dist, z], vecx, vecz, @d/2, 0, pi/2, @s) line1 = model.entities.add_line([x+@dist, y+@dist, z],[x+@dist, y+@dist+@d/2, z]) line2 = =model.entities.add_line([x+@dist, y+@dist, z],[x+@dist+@d/2, y+@dist, z]) face = model.entities.add_face[arc,line1,line2] face.pushpull @thick
Regards,
Advertisement