Entities#add_face doesn’t have a variant that allows a mixture of individual edges with an Array of edges. You might unshift edge3, edge2, edge1 onto the front of the Array and then pass the Array as a single argument to add_face.
If the face coincides with the edge of the sheathing (at the bottom), I can actually do this instead:
new_face41 = (line1.faces)[0]
This will get the face which I can then push/pull to create the door opening. The only problem is that I’m not guaranteed that the first face in the array is the correct face. However, after testing this about 20 times it still has not selected the larger face of the solid.
Which brings me to my next question, why do I need to go through all of these steps to get the edges that make up the arc when the variable edgearray already contains this array of edges? … ??
The whole curve and arcCurve thing confuses the heck out of me.
That is actually my 1st question. Just because some obscure example does this kind of thing doesn’t mean you cannot use your own best judgement to write better code.
Of course not, because neither the Sketchup::Face class nor the NilClass have a #flatten method. (You’re trying to call Array#flatten method upon the result of the add_face method, which is not an array.)
It is more usual to use the “splat” operator to convert arrays to parameter lists (and visa versa.)
new_face41 = entities40.add_face(line3, line2, line1, *edgearray)
if new_face41
# add face was successful
end
… but you can also do …
new_face41 = entities40.add_face( [line3, line2, line1, edgearray].flatten )
if new_face41
# add face was successful
end
… or even …
new_face41 = entities40.add_face( [line3, line2, line1] + edgearray )
if new_face41
# add face was successful
end
You must be sure to check the result of the add_face call or check the the line arguments and the arc are one the same plane. I’m not sure but the add_face call might even raise an exception if the args are not coplanar.
So always verify the object is a valid face before calling #pushpull on it.
I can check the final array of edges I send to the add_face command and everything looks good, I also know they form a coplanar face, but for some reason the linear edges and the arc edges don’t seem to play well together when I pass them in one array to the add_face method.
I’ve tried various code combinations like those shown above but to no avail, I’m stumped.
I did come up with a workaround but it is kind of a hack in my opinion. I will try to provide a full example of this where it chokes, but theoretically shouldn’t.