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

    Can't glue to face that Sketchup thinks is deleted

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 430 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.
    • C Offline
      crawfojj
      last edited by

      I have an external custom program that creates a .rb file for Sketchup to draw a building and place doors, windows and other accessories on it selected in the custom program. The 1st part is a sample of two of the walls that are created. End1 and Side1.
      Later on I test for the accessories and place on the wall that is specified in the program. If I take out the glue_to option the door/window won't cutout the wall for the window, but if I leave it in it gives me an error Error: #<TypeError: reference to deleted Entity> on the line that has the glue_to=side1_face.
      However it works correctly on the items that have end1_face as long as they are before the other walls. So wondering why it works on one of the walls, but not the others. Does the two transformations have anything to do with it?
      Thanks,
      Jon

      END1 PANEL ********************************************************************************

      pt1 = [x1, y1, z]
      pt2 = [x2, y1, z]
      pt3 = [x2, y1, height]
      pt4 = [x2 + eave2, y1, height]
      pt5 = [roofcenter, y1, roofheight - fascia]
      pt6 = [x1 - eave1, y1, height]
      pt7 = [x1, y1, height]
      pt8= [x1, y1, z]
      end1_face = entities.add_face pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8
      end1_face.material = "ForestGreen_Panel"
      

      SIDE1. *************************************************************************************

      pt1 = [x1, y1, z]
      pt2 = [x1, y1, height]
      pt3 = [x1, y2, height]
      pt4 = [x1, y2, z]
      pt5 = [x1, y1, z]
      side1_face = entities.add_face pt1, pt2, pt3, pt4, pt5
      side1_face.material = "ForestGreen_Panel"
      

      Later in the code I place the doors/windows/etc.

      definitions = model.definitions
      

      Acc1 *****

      point1=Geom;;Point3d.new x1+156,y1-1,gradeboard+1.1
      transform1=Geom;;Transformation.new point1
      transformscale1=Geom;;Transformation.scaling 1.16666666666667,1.4, 1
      path1=Sketchup.find_support_file "Overhead_Door_FO.skp","Components/NB"
      componentdefinition1=model.definitions.load path1
      instance1 = entities.add_instance componentdefinition1, (transform1 * transformscale1)
      entities.transform_entities(Geom;;Transformation.rotation(point1,X_AXIS,90.degrees),instance1)
      instance1.definition.behavior.is2d=true
      instance1.glued_to=end1_face
      

      Acc2 *****

      point2=Geom;;Point3d.new x1-0.5,y2-60,gradeboard+1.1
      transform2=Geom;;Transformation.new point2
      transformscale2=Geom;;Transformation.scaling 0.833333333333333,1.4, 1
      path2=Sketchup.find_support_file "Overhead_Door_FO.skp","Components/NB"
      componentdefinition2=model.definitions.load path2
      instance2 = entities.add_instance componentdefinition2, (transform2 * transformscale2)
      entities.transform_entities(Geom;;Transformation.rotation(point2,Z_AXIS,-90.degrees),instance2)
      entities.transform_entities(Geom;;Transformation.rotation(point2,Y_AXIS,270.degrees),instance2)
      instance2.definition.behavior.is2d=true
      instance2.glued_to=side1_face
      
      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        @Jon

        You have not made it easy to debug your code by giving us it in so many 'bits'...
        AND offering NO error-message clues...

        If you have a face, and you insert an instance on the same plane as that face, and you set the instance's gluing behavior to be on that face etc, then all should be well...

        So...
        Is the insertion point definitely on that face.plane ?
        Is the definition's behavior set to glue to any face ?
        Try giving the definition a 'snapto' behavior of 'SnapTo_Arbitrary' ?

        When you look at the result is the instance on the expected face ?

        Etc ???

        TIG

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

          Thanks @TIG for the quick response.

          Sorry I didn't include enough code to debug, I didn't want to clutter it up with too much info.
          I figured if I showed how the 1st face was created along with how the component was being placed on it and same with the 2nd face that wasn't working that would keep it simpler.

          As for the error I only received the one Error: #<TypeError: reference to deleted Entity>. The only additional info it had was the line # and the glue_to statement that was on that line.
          <Path>\Color.rb:773:in `glued_to='

          The components definition was set to glue to Any and I also tried the snaptobehavior, but that didn't change anything.

          As I was playing around with it some more I did figure out what was triggering it cause it was working before. If the building has wainscot on the bottom of the wall this is when it would trip up. For some reason if I also draw basically another face onto the current one it would cause the error. If I didn't do the pushpullit would work sometimes

          So I drew it 0.01 away from the main face/wall to get this to work like it did before with no wainscot. Still not sure why it didn't trip up the 1st face though since they were done the same.

          It is now working as expected and having the wainscot not directly on the wall doesn't really matter since it's hard to even tell it's off. The only thing is that because of this the wainscot doesn't get cut out like the wall does so sometimes have to make additional adjustments. If there was a way to simply draw on line onto the 1st face/wall where the wainscot should be and color the bottom differently I think that would work. Not sure how to do that however.

          Any insight on why this happens would be greatly appreciated.
          Thanks,
          Jon

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

            If you are 'losing geometry' because your new geometry is inferring with existing geometry - either geometry which is already in the model, or it has just been created in your code - consider doing this...
            Instead of entities = model.active_entities try this alternative...
            group = model.active_entities.add_group() entities = group.entities
            Now all of your new geometry is inside that group and so it won't merge with other existing geometry that might share the same line, same plane etc...
            If you want to, at the very end group.explode and the new geometry merges with the existing...

            TIG

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

              Group doesn't have an active_entities method (that I know of?)

              Should be just entities = group.entities

              (P.S.: var/ref names being the same as method names are confusing to newbies.)

              I'm not here much anymore.

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

                @Dan you are right.
                Typo mess.
                I've corrected the original post. 😒

                TIG

                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