Example #1
0
        internal new void Pack(Model model, SU.EntitiesRef entitiesRef)
        {
            // The SketchUp API appears to add a "persistent ID" to vertices,
            // edges, and faces, as they are added to definitions and groups.
            // But it also appears not to do this unless the definition or
            // group reference has already been added to the model. If you
            // add those references to the model after creating their contents,
            // SketchUp will detect the missing IDs on load and "fix" them,
            // causing SketchUp to ask if you want to save the changes when
            // you close (even though you won't think you've made any).
            //
            // You can see this in the "Edit / Undo Check Validity" menu item
            // when it happens. Undo it, and then use the "Window / Model info"
            // dialog, under "Statistics" by pressing the "Fix Problems"
            // button. You'll get a report on the missing persistent IDs.
            //
            // To prevent all this from happening, we add the reference first.

            SU.GroupRef groupRef = new SU.GroupRef();
            SU.GroupCreate(groupRef);

            SU.EntitiesAddGroup(entitiesRef, groupRef);

            SU.EntitiesRef myEntitiesRef = new SU.EntitiesRef();

            SU.GroupGetEntities(groupRef, myEntitiesRef);

            //entities.Pack(model, myEntitiesRef);
            base.Pack(model, myEntitiesRef);

            // Set the group's name and transformation..

            SU.GroupSetName(
                groupRef,
                Name);

            SU.GroupSetTransform(
                groupRef,
                Transform.SUTransformation);
        }