public int SelectTheSame(string guid) { try { log("Model: " + (Model != null)); if (Model != null) { IPersistEntity selected = null; Xbim.Presentation.EntitySelection sel = new Xbim.Presentation.EntitySelection(false); var project = Model.Instances.FirstOrDefault <IIfcProject>(); if (project is Xbim.Ifc2x3.Kernel.IfcProject) { var globalIds = new Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId(guid); selected = Model.Instances.OfType <Xbim.Ifc2x3.Interfaces.IIfcRoot>().FirstOrDefault(a => a.GlobalId == globalIds); } else if (project is Xbim.Ifc4.Kernel.IfcProject) { var globalIds = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(guid); selected = Model.Instances.OfType <Xbim.Ifc4.Interfaces.IIfcRoot>().FirstOrDefault(a => a.GlobalId == globalIds); } else { throw new Exception("Undefined project"); } //System.Timers.Timer t = new System.Timers.Timer(); //t.Start(); if (selected != null) { var test = getExpressType(Model); selectTheSameElements(selected, test); log("Set selection"); } else { return(1); } //t.Stop(); //Console.WriteLine( t.Interval.ToString()); log("return 0"); return(0); } } catch (Exception ex) { log("Не удалось выделить " + ex.ToString()); } log("SelectTheSame return 0"); return(0); }
private void cmdSave_Click(object sender, RoutedEventArgs e) { var t = new FileInfo(TxtInputFile.Text + ".stripped.ifc"); var tex = t.CreateText(); tex.Write(_header); foreach (var i in _exportList) { tex.WriteLine(_ifcLines[i]); } // now export containement var max = _exportList.Max(); if (ExportContainment.IsChecked.Value) { var newid = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(); // we need to ensure that the site is exported. var exportedSite = _exportList.Intersect(_ifcSites).FirstOrDefault(); if (exportedSite == 0) { exportedSite = ++max; newid = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(); tex.WriteLine($"#{exportedSite}= IFCSITE('{newid.Value}',#{_ownerhistoryEntityLabel},'XbimCreated','Created with the stripping method of Xbim Simplify','',#{_mainPlacement},$,$,.ELEMENT.,$,$,0.,$,$);"); } newid = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(); tex.WriteLine($"#{++max}= IFCRELAGGREGATES('{newid.Value}',#{_ownerhistoryEntityLabel},$,$,#{_projectEntityLabel},(#{exportedSite}));"); foreach (var element in _ifcelements) { newid = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(); tex.WriteLine($"#{++max}= IFCRELCONTAINEDINSPATIALSTRUCTURE('{newid.Value}',#{_ownerhistoryEntityLabel},$,$,(#{element}),#{exportedSite});"); } } tex.Write(_footer); tex.Close(); TxtOutput.Text = "Done"; }