Ruby strange error

Hi all,

in my code, I have this function

  def get_point(edge){|vertex| vertex.position}

It’s work 100% of the time , but I don’t know when its provide me this error

Error: #<NoMethodError: undefined method `position' for #<Sketchup::OptionsProvider:0x00007fc8a781d518>>
...../Adebeo_SimpleTool_extension/Adebeo_SimpleTool/models/component_skeleton.rb:63:in `block in get_point'

But how a vertices method could return a OptionsProvider ?

thanks for your answer ?

Memory corruption, likely. Exit SketchUp. Reboot Computer.

If you can get a repeatable error with a certain model, a certain code snippet in the latest SketchUp version, please log a bug report in the API issue tracker.

Aside: Your method as shown returns an Array of two points, not a single point.

For Ruby 2+ (SU 2014 and higher) you can use the shorthand notation …

  def get_points(edge)

And you can always do (which is likely faster) …

  def get_points(edge)
  	[ edge.start, edge.end ]

May be related to …

Denis, what SketchUp version are you seeing this on ?

Also, if you see this occurring after a certain Ruby exception or a certain SketchUp application error, knowing this will also be helpful.

In fact this error appear after a lot of operation in ruby ( and DC calculation). Thanks for you help, I will refactor code as you advice.

1 Like

I’d agree @DanRathbun, that seems very likely to be another case of the zombie object issue (that’s me on GitHub btw).

1 Like

Sketchup 21.0.392 on MAC and PC

Yea, this is a clear case of zombie references.

I would not bother to try to handle this in your extension. If you are running into this then you’re only catching the errors when one type if confused for another type. In which case it’s good that the extension fails, because the alternative is worse, getting a reference of a different entity of the same type - then you’d blindly operate on a random entity. If you do any error handling at all for this I’d recommend it’s merely to inform the user to restart SketchUp because all bets are off when zombies has entered the system. Worst case scenario is random modification of the model data.