Adding to the discussion here because it’s the only forum post I’ve encountered that appears to mention this issue.
I’ve been battling a similar NoMethodError that occurs in about a third of the models I open, when running the following method. An OptionsProvider object is somehow mixed in among the edge vertices in the model. Attempting to read keys/values from that OptionsProvider crashes SketchUp.
Any given open model either will or won’t throw the error, consistently. Meaning, if I open a model and the method does not throw the error, then I can run the method as many times as I’d like, and the error is never thrown. Whereas if I open a model and the method does throw the error, then every subsequent time I run the method, it throws the error.
Closing and re-opening the model seems to effectively “re-roll the dice” — a model that was not raising the error might raise the error after being closed and re-opened, and vice versa. I’ve even saved a copy of a model after encountering the error, closed and re-opened it, and no longer encountered the error.
System/Environment Details:
Mac M1 Max Ventura 13.4.1, SketchUp 24.0.483, the only enabled extensions are native SketchUp extensions (Add Location, Dynamic Components, Sandbox Tools, SketchUp Diffusion).
Method that throws the error:
def self.get_model_height()
model = Sketchup.active_model
entities = model.entities
edges = entities.grep(Sketchup::Edge)
vertices = edges.map(&:vertices).flatten.uniq
z_values = vertices.map(&:position).map(&:z) # Error occurs here trying to access :position of OptionsProvider object
max_z = z_values.max
min_z = z_values.min
return (max_z - min_z).inch
end # get_model_height
Ruby console output error message:
get_model_height
Error: #<NoMethodError: undefined method `position' for #<Sketchup::OptionsProvider:0x00000002dfc857d0>>
(eval):6:in `map'
(eval):6:in `get_model_height'
(eval):1:in `<main>'
SketchUp:in `eval'
I’ve added the above to the official tracking issue on GitHub. I appreciate any insight you folks can offer. Hopefully those steps can be reproduced on your end and be helpful in figuring out what’s going on under the hood. Happy to provide more info if that would help.
EDIT: Attached example model in which this error has (and has not) occured.
SKP-LAFX-SHRB-PRNL-018.skp (80.4 KB)