sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    SU 8 Mac & strange content

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 795 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tomasz
      last edited by

      @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 through Sketchup.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.

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

      1 Reply Last reply Reply Quote 0
      • TIGT Online
        TIG Moderator
        last edited by

        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...

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          @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 through Sketchup.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.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @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 is Sketchup::Entity, not Object.

            Also, .parent() does not work for Sketchup::RenderingOptions instances. It returns nil.
            It would be nice if .parent() returned the model for the model's rendering options hash, and the specific Sketchup::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's Sketchup::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
            

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • T Offline
              tomasz
              last edited by

              @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.

              Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                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.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement