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

    [Bug] Groups in ComponentInstances made unique

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 206 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.
    • thomthomT Offline
      thomthom
      last edited by

      I know that if you edit a group copy via the API it affects all copies, but I've not found anyone describing this related problem:

      Scenario:

      You have a Component Instance ( Comp1)
      Inside that component there's a group ( Group1 of GroupDef1)
      You make a copy of the Component Instance ( Comp2)
      Then you make Comp2 unique

      Group1 inside Comp2 is still a copy of GroupDef1

      You open Comp2 and edit the group inside, now it's made unique Group2 of GroupDef2
      However, via the API, Group2.entities.parent still refer to GroupDef1
      What's more, GroupDef1.instances does not refer to Group2

      So while SU create a new definition when you edit Group2, the back-reference of Group2.entities.parent is not.

      The only work around I've found is group.make_unique if not group.entities.parent.instances.include?(group). All though, this will break any group/copy links of group instances that actually is identical. So it's not ideal.

      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

        I think this would be a non-destructive workaround:

        
        def get_real_parent(group)
          Sketchup.active_model.definitions.each { |d|
            return d if d.group? && d.instances.include?(group)
          }
        end
        
        group_parent = ( group.entities.parent.instances.include?(group) ) ? group.entities.parent ; get_real_parent(group)
        
        

        Next time the model is loaded the mixed up .parent references is corrected.

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

        1 Reply Last reply Reply Quote 0
        • R Offline
          remon_v
          last edited by

          thnx for the workaround,

          haven't tried it yet tho.... but gj

          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