Example #1
0
        private void CopyInstances(XbimModel newmodel, XbimModel model)
        {
            newmodel.AutoAddOwnerHistory = false;
            using (XbimReadWriteTransaction txn = newmodel.BeginTransaction("CopyInstances"))
            {
                PropertyTranformDelegate propTransform = delegate (IfcMetaProperty prop, object toCopy)
                {
                    var value = prop.PropertyInfo.GetValue(toCopy, null);
                    return value;
                };

                var copied = new XbimInstanceHandleMap(model, newmodel);

                foreach (var ent in model.Instances)
                {
                    newmodel.InsertCopy(ent, copied, txn, propTransform);
                }

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                }
            }
        }
Example #2
0
        private void CopyInstance(XbimModel newmodel, XbimModel model, IPersistIfcEntity ent)
        {
            newmodel.AutoAddOwnerHistory = false;
            using (XbimReadWriteTransaction txn = newmodel.BeginTransaction("CopyInstance"))
            {
                PropertyTranformDelegate propTransform = delegate (IfcMetaProperty prop, object toCopy)
                {
                    var value = prop.PropertyInfo.GetValue(toCopy, null);
                    return value;
                };

                var copied = new XbimInstanceHandleMap(model, newmodel);

                try
                {
                    newmodel.InsertCopy(ent, copied, txn, propTransform);
                }
                catch(Exception ex)
                {
                    AddMessages(" " + ex.Message);
                    Debug.WriteLine(" " + ex.Message);
                }

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                }
            }
        }