SU 8 Mac & strange content
-
@unknownuser said:
Error: #<NoMethodError: undefined method
layer' for #<Sketchup::RenderingOptions:0x1cc090c4>> (eval):2537:in
collect_faces'This is a dump of a Ruby console, when an exporter stopped with the error.
The 'collect_faces' method browse throughSketchup.active_model.entities
or through a selection.How is it possible that suddenly Sketchup::RenderingOptions:0x1cc090c4 are part of entities, among edges, faces, groups and components?
Has anyone experienced similar thing on Mac? I haven't spotted such a strange content in Windows version.
-
What export tool were you running when the error appeared ?
Is it repeatable ?
Did the export complete OK or fail ?
Does it only happen with a certain SKP or consistently ?
Is there anything 'unusual' about the SKP ? e.g. very big, very small, many textures, unusual rendering settings, fog etc... -
@unknownuser said:
@unknownuser said:
Error: #<NoMethodError: undefined method
layer' for #<Sketchup::RenderingOptions:0x1cc090c4>> (eval):2537:in
collect_faces'This is a dump of a Ruby console, when an exporter stopped with the error.
The 'collect_faces' method browse throughSketchup.active_model.entities
or through a selection.How is it possible that suddenly Sketchup::RenderingOptions:0x1cc090c4 are part of entities, among edges, faces, groups and components?
The simpliest explanation would be that you have a reference error. Somehow the reference variable you are using to walk the entities is also being set to refer to a
Sketchup::RenderingOptions
object, which can be for the active_model or a Scene(Page) object.Make sure if you are within a method,
collect_faces()
that you use unique var names. Use a different var name for accessing the rendering options than you do for walking the entities.Also you can do Type checking... check the return type from your method:
ret = collect_faces() if ret.is_a?(Array) && ret.all?{|member| member.kind_of?(Sketchup;;Drawingelement) } # do code else # recover code, such as slicing non-drawingelement # members out of the array end
I also notice you are getting a "eval:line number" in the exception error. If this error is occuring in a scrambled rbs file.. you should load and debug your non-scrambled version, which should return the file and line number where the error is occuring.
-
@dan rathbun said:
@unknownuser said:
How is it possible that suddenly Sketchup::RenderingOptions:0x1cc090c4 are part of entities, among edges, faces, groups and components?
The simpliest explanation would be that you have a reference error. Somehow the reference variable you are using to walk the entities is also being set to refer to a
Sketchup::RenderingOptions
object, which can be for the active_model or a Scene(Page) object.There is an error in the APC docs for
Sketchup::RenderingOptions
.The superclass of
Sketchup::RenderingOptions
isSketchup::Entity
, notObject
.Also,
.parent()
does not work forSketchup::RenderingOptions
instances. It returnsnil
.
It would be nice if.parent()
returned the model for the model's rendering options hash, and the specificSketchup::Page
object for a scenepage rendering options hash. (Something for the wishlist..)Anyway.. I tested the model's
entities
collection on a new model, and it does not (normally,) contain the reference to it'sSketchup::RenderingOptions
instance. Perhaps you've found a bug?Just to be safe, I would suggest typechecking each member of the entities collection while iterating to test that it is indeed a subclass of
Sketchup::Drawingelement
before calling any method on the object, such as.layer()
in your example above.Inside your entities iteration loop:
# ents= model.active_entites # or the entities of a group or component ents.each do |ent| if ent.kind_of?(Sketchup;;Drawingelement) # process for export end # if # else ignore the object end
-
@tig said:
What export tool were you running when the error appeared ?
Is it repeatable ?
Did the export complete OK or fail ?
Does it only happen with a certain SKP or consistently ?
Is there anything 'unusual' about the SKP ? e.g. very big, very small, many textures, unusual rendering settings, fog etc...I am testing Thea Exporter SU2TH.
The problem is that the error is not repeatable.I haven't discovered a certain pattern that leads to the appearance of 'strange' objects among entities. When such an unexpected entity appears it leads to a failure of an export.
There is nothing unusual in files.
It is strange. I started to set up a traps in my code to hijack such a 'foreign entities', but I am not able to guard all the code.I have noticed that those errors appear on MACs only (so far). I work primarily under Win. I have to spend more time on MAC to figure out what is going on.
Thank you Dan for all suggestions. I will give them a try.
My intuition tells me that there might me a 'leak' in SU 8 on MAC that allows such a behavior. -
Just a reminder (for anyone reading,) that we should not change entities when iterating the C++
entities
collection. (Strange things can happen... items can be missed, or be processed more than once, etc.)If you need to change entities, then make an array copy to iterate:
ents = Sketchup.active_model.entities**.to_a** ents.class
Array
Although an exporter usually should not be making changes to the model.
Advertisement