I’ve just spent over an hour trying to track down a bug. It turns out to be what I would consider a bug in the api. The creation of the face fails, and there is no error. The operation is also aborted at the same time.
I’m not sure how to correct the problem, other than modifying my points in such a way that the problem is circumvented.
Here is the model.
Face Test Bug.skp (117.2 KB)
Here is the code to reproduce the error.
shed = Sketchup.active_model.entities.grep(Sketchup::ComponentInstance)[0]
shed.set_attribute('bc', 'test', 'value1')
puts "expected text value: value1, got value: #{shed.get_attribute('bc', 'test')}"
Sketchup.active_model.start_operation('Face Test')
points = [[192.0, -96.0, 120.0],
[96.0, -96.0, 152.0],
[5.0, -96.0, 121.66666666666667],
[5.0, -96.0, 39.0],
[67.0, -96.0, 39.0],
[67.0, -96.0, 120.0],
[192.0, -96.0, 120.0],
[192.0, -96.0, 116.0]]
shed.set_attribute('bc', 'test', 'value2')
shed.definition.entities.add_face(points)
#this demonstrates that the operation was aborted and the previous value is in the dictionary.
puts "expected text value: value2, got value: #{shed.get_attribute('bc', 'test')}"
Sketchup.active_model.commit_operation
PS: I want to get some other input before posting an issue in the api issue tracker.