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

    Why is a box deleted / Why is a box not a manifold?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 643 Views 2 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.
    • F Offline
      Frank Brugman
      last edited by Frank Brugman

      Hi all,

      Embarrassing simple questions (I think):

      1. The code underneath gives the message "bbx1 deleted!"
        What is happening and how do I prevent it from being deleted?
      2. The code underneath gives alse the message "bbx2 is not a manifold"
        What is happening and how do I make it a manifold?
        ( I want to learn about boolean solid operations like union etc,... )

      With kind regards,

      Frank Brugman

        bbxmax   = Geom;;Point3d.new
        bbxmin   = Geom;;Point3d.new
      
        bbxmin.x = 1000.mm
        bbxmin.y = 0.mm
        bbxmin.z = 0.mm
      
        bbxmax.x = 2000.mm
        bbxmax.y = 1000.mm
        bbxmax.z = 1000.mm
      
        boxpts = []
        boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z]
        boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z]
        boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z]
        boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z]
      
        face1 = Sketchup.active_model.entities.add_face boxpts
        face1.reverse!
        face1.pushpull(bbxmax.z-bbxmin.z )
      
        bbx1 = Sketchup.active_model.entities.add_group 
        bbx1.entities.add_group face1.all_connected
      
        bbxmin.x = 2000.mm
        bbxmin.y = 0.mm
        bbxmin.z = 0.mm
      
        bbxmax.x = 3000.mm
        bbxmax.y = 1000.mm
        bbxmax.z = 1000.mm
      
        boxpts = []
        boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z]
        boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z]
        boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z]
        boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z]
      
        face2 = Sketchup.active_model.entities.add_face boxpts
        face2.reverse!
        face2.pushpull(bbxmax.z-bbxmin.z )
      
        bbx2 = Sketchup.active_model.entities.add_group 
        bbx2.entities.add_group face2.all_connected
      
        if ( bbx1.deleted? )
          UI.messagebox("bbx1 deleted!")
        end
      
        if ( not bbx2.manifold? ) 
          UI.messagebox("bbx2 is not a manifold")
        end
      
      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        Looking at it...

        Sidenote: when using the Ruby API you create the group first then add the entities to the group. Inverse of what you do via the UI.

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          Another side note:

          Instead of this:

          
            bbxmin   = Geom;;Point3d.new
          
            bbxmin.x = 1000.mm
            bbxmin.y = 0.mm
            bbxmin.z = 0.mm
          
          

          it's much simpler to write:

          
            bbxmin   = Geom;;Point3d.new(1000.mm, 0.mm, 0.mm)
          
          
          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            Right, so the deleted? thing happen because you make the face first, then try to move it into another group - a nested group event.

            Rearranging so you create your groups first, then add the faces fixes that.

            The manifold? test fails because bbx2 contains another group inside it. That group however is a manifold. Maybe you didn't intend to create two levels of nested groups?

            
              bbxmax   = Geom;;Point3d.new
              bbxmin   = Geom;;Point3d.new
            
              bbxmin.x = 1000.mm
              bbxmin.y = 0.mm
              bbxmin.z = 0.mm
            
              bbxmax.x = 2000.mm
              bbxmax.y = 1000.mm
              bbxmax.z = 1000.mm
            
              boxpts = []
              boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z]
              boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z]
              boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z]
              boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z]
            
              bbx1 = Sketchup.active_model.entities.add_group 
              g1 = bbx1.entities.add_group
              face1 = g1.entities.add_face boxpts
              face1.reverse!
              face1.pushpull(bbxmax.z-bbxmin.z )
            
              bbxmin.x = 2000.mm
              bbxmin.y = 0.mm
              bbxmin.z = 0.mm
            
              bbxmax.x = 3000.mm
              bbxmax.y = 1000.mm
              bbxmax.z = 1000.mm
            
              boxpts = []
              boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z]
              boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z]
              boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z]
              boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z]
            
              bbx2 = Sketchup.active_model.entities.add_group 
              g2 = bbx2.entities.add_group
              face2 = g2.entities.add_face boxpts
              face2.reverse!
              face2.pushpull(bbxmax.z-bbxmin.z )
            
              if ( bbx1.deleted? )
                UI.messagebox("bbx1 deleted!")
              end
            
              if ( not bbx2.manifold? ) 
                UI.messagebox("bbx2 is not a manifold")
              end
            
            
            1 Reply Last reply Reply Quote 0
            • F Offline
              Frank Brugman
              last edited by

              Hi Thom,

              Thank you for your quick respons.
              I indeed did not want to create a two level nested group.
              Is it easy for you to tell me how I got rid of one of the two levels?

              With kind regards, Frank

              1 Reply Last reply Reply Quote 0
              • F Offline
                Frank Brugman
                last edited by

                Hi Thom,

                Thank you for your quick respons. It works!
                With exploding the groups I got rid of the two levels.

                With kind regards,

                Frank

                Enjoy spring!

                1 Reply Last reply Reply Quote 0
                • tt_suT Offline
                  tt_su
                  last edited by

                  There is no need to explode - just don't create two groups.

                  Change this:

                  
                    bbx1 = Sketchup.active_model.entities.add_group 
                    g1 = bbx1.entities.add_group
                    face1 = g1.entities.add_face boxpts
                    face1.reverse!
                    face1.pushpull(bbxmax.z-bbxmin.z )
                  
                  

                  to

                  
                    bbx1 = Sketchup.active_model.entities.add_group 
                    face1 = bbx1.entities.add_face boxpts
                    face1.reverse!
                    face1.pushpull(bbxmax.z-bbxmin.z )
                  
                  

                  If you read your code carefully you will see that you call add_group twice, once in the root entities element and once in the first group you created.

                  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