sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Error Message

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 275 Views 4 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.
    • C Offline
      Chris88
      last edited by

      Sorry guys, it's me again.
      Can someone say something about this error message:
      'add_instance': Insertion would result in recursive definition
      It appears in a rotation command.

      Thanks

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        Looks like you're attempting to insert the new instance into its own definition.

        So instead of inserting the instance into the entities of the definition, insert it into the entities of the model.

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • GaieusG Offline
          Gaieus
          last edited by

          Well, I know no ruby so a "rural" example: Make a component and while editing it, try to insert the same component inside itself...


          CompInComp.png

          Gai...

          1 Reply Last reply Reply Quote 0
          • C Offline
            Chris88
            last edited by

            I'm not sure what do you mean.
            So it's better if i'll show you my code,
            then you can teach me by reference to the code:

            ` model = Sketchup.active_model
            entities = model.active_entities
            group = entities.add_group
            entities = group.entities

            #-----------------------------------

            Kettensaege kreiern

            width_kettensaege = 40    
            depth_kettensaege = 1 
            height_kettensaege = 6  
            color_kettensaege = Sketchup::Color.new(169,169,169)
            
            pts = []
            pts[0] = [0.5, 0.5, 0.5]
            pts[1] = [width_kettensaege+0.5, 0.5, 0.5]
            pts[2] = [width_kettensaege + 0.5, 0.5 + depth_kettensaege, 0.5]
            pts[3] = [0.5, 0.5 + depth_kettensaege, 0.5]
            base = entities.add_face pts	
            

            create material

            mat_kettensaege=model.materials.add("Material_Kettensaege")
            mat_kettensaege.color=color_kettensaege 
             
            area = base.area
            base.back_material = mat_kettensaege
            base.material = mat_kettensaege
            base.pushpull(height_kettensaege) 
            
            kettensaege = my_definition = Sketchup.active_model.definitions[0]
            

            to hide the original object

             entities.each { |entity|
               entity.visible = false
               }
            

            #----------------------------------
            point = Geom::Point3d.new(0,0,0)
            vector = [0,0,1]
            angle = 1.57079
            rotation = Geom::Transformation.rotation point, vector, angle
            instance = entities.add_instance kettensaege, rotation # here is the error
            #-----------------------------------`

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              What is your intention with this line?

              kettensaege = my_definition = Sketchup.active_model.definitions[0]

              You're making a reference to an arbitrary component definition - which in your case is the definition for the group which you try to add an instance into.

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                angle = 1.57079
                I assume you want a 90 degree angle in radians - which you can write as 90.degrees. See the Numeric class for modifications that SU has done to the base class: http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • C Offline
                  Chris88
                  last edited by

                  Thanks to all,
                  the problem is solved

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @chris88 said:

                    the problem is solved

                    I'm curious to what it was...

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    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