Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InsertCopy with selected elements #19

Open
BalintBende opened this issue Aug 8, 2019 · 0 comments
Open

InsertCopy with selected elements #19

BalintBende opened this issue Aug 8, 2019 · 0 comments

Comments

@BalintBende
Copy link

BalintBende commented Aug 8, 2019

I would like to create a new copy from my original ifc file, but with the selected buildingelements. For this I am using InsertCopy code sample. In my case all Representations and ObjectPlacements are also needed. So I don't want to leave out them from the semantic filter.

IfcStore is my original model which is opened previously, ifcBuildingElements is a List of selected IfcBuildingElements objects.

Here is my semantic filter:

PropertyTranformDelegate semanticFilter = (property, parentObject) => {
if (property.EntityAttribute.Order < 0 &&
            !(property.PropertyInfo.Name == nameof(IIfcProduct.IsDefinedBy) ||
              property.PropertyInfo.Name == nameof(IIfcProduct.IsTypedBy)
              ))
          return null;

        return property.PropertyInfo.GetValue(parentObject, null);
      };

Then I go through my selected building elements and insert to the new model:

using (var iModel = IfcStore.Create(ifcStore.SchemaVersion,
        XbimStoreType.InMemoryModel)) {
        using (var txn = iModel.BeginTransaction("Insert copy")) {
          //single map should be used for all insertions between two models
          var map = new XbimInstanceHandleMap(ifcStore, iModel);

          foreach (var buildingElement in ifcBuildingElements) {
            //insert building element
            iModel.InsertCopy(buildingElement, map,
              semanticFilter, true, false);
          }
          txn.Commit();
        }

This results all building elements not just the selected ones. Could someone help me to fix?
Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant