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.

We’re seeing the same kind of errors in VR Sketch. For reference, during the last two weeks, we got 5 automated reports with this error, all about an OptionsProvider object showing up randomly (why OptionsProvider??), all on OS X. I tried previously to handle the exception by retrying the faulty piece of code a few times, but it seems not to help—i.e. we seem to get the same bogus OptionsProvider from reading the same attribute repeatedly. In view of the discussion here, I’ve now changed the logic to ask the user to restart SketchUp. I’ve also added a note that if someone can reproduce the problem, we’d be very interested in the model. We’ll see!

…Looking through the error logs of the past three months, the versions of SketchUp we see are all OS X, and most of them are 2100000392, plus a few 2000000362 (that’s Sketchup.version_number)—there is a bias, though, in that VR Sketch on OS X doesn’t really work with SU2019 or older.