public MProject GetProject() { MProject proj = new MProject(); IIfcProject iProj = _model.Instances.OfType <IIfcProject>().First(); proj.FileName = file; proj.Author = iProj.OwnerHistory.OwningUser.ThePerson.ToString(); var createTime = DateTimeOffset.FromUnixTimeSeconds(iProj.OwnerHistory.CreationDate); proj.Created = createTime.DateTime; if (iProj.OwnerHistory.LastModifiedDate.HasValue == false) { proj.LastChanged = createTime.DateTime; } else { var time = DateTimeOffset.FromUnixTimeSeconds(iProj.OwnerHistory.LastModifiedDate.Value); proj.LastChanged = time.DateTime; } proj.ProjectName = iProj.Name; return(proj); }
public ETLLoad() { InitializeComponent(); button_OK.IsEnabled = false; if (_model != null) { IfcStore model = _model as IfcStore; string projName = string.Empty; IIfcProject project = model.Instances.OfType <IIfcProject>(true).FirstOrDefault(); //if (model.IfcSchemaVersion == IfcSchemaVersion.Ifc4) //{ // var project = model.Instances.FirstOrDefault<Xbim.Ifc4.Kernel.IfcProject>(); // projName = project.Name; //} //else if (model.IfcSchemaVersion == IfcSchemaVersion.Ifc2X3) //{ // var project = model.Instances.FirstOrDefault<Xbim.Ifc2x3.Kernel.IfcProject>(); // projName = project.Name; //} if (String.Compare(projName, "Empty Project") != 0) { button_OK.IsEnabled = true; } } }
public XbimModelViewModel(IIfcProject project, IXbimViewModel parent) { _model = project.Model; _project = project; CreatingParent = parent; IEnumerable subs = Children; //call this once to preload first level of hierarchy }
public void ToleratesEmptyMultibyteStringsTest() { // I have stumbled across a file containing empty multibyte string sequences '\X2\\X0\'. using (IfcStore store = IfcStore.Open(@"TestFiles\EmptyMultibyteString.ifc")) { IIfcProject project = store.Instances.OfType <IIfcProject>().SingleOrDefault(); Assert.AreEqual("Test Test Test", (string)project.Name); } }
public SpatialViewModel(IIfcProject project) { if (project == null) { throw new ArgumentNullException("project"); } _model = project.Model; _spatialStructure = project; }
private SceneModel CreateNew(IIfcProject p, IfcSceneExportSettings settings) { return(new SceneModel() { Name = p?.Name, Id = p?.GlobalId.ToGlobalUniqueId(), UnitsPerMeter = settings.UnitsPerMeter, Stamp = Timestamp.FromDateTime(DateTime.Now.ToUniversalTime()) }); }
public ProjectType(IIfcProject ifcProject, CoBieLiteHelper helper) : this() { // _ifcProject = ifcProject; externalEntityName = helper.ExternalEntityName(ifcProject); externalID = helper.ExternalEntityIdentity(ifcProject); externalSystemName = helper.ExternalSystemName(ifcProject); ProjectName = ifcProject.Name; ProjectDescription = ifcProject.Description; }
protected override Project Mapping(IIfcProject source, Project target) { var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper; target.ExternalEntity = helper.ExternalEntityName(source); target.ExternalId = helper.ExternalEntityIdentity(source); target.AltExternalId = source.GlobalId; target.Name = source.Name; target.Description = source.Description; return(target); }
public void BindUi(IXbimXplorerPluginMasterWindow mainWindow) { _parentWindow = mainWindow; _model = mainWindow.Model; if (_model != null) { IfcStore model = _model as IfcStore; string projName = string.Empty; IIfcProject project = model.Instances.OfType <IIfcProject>(true).FirstOrDefault(); if (String.Compare(projName, "Empty Project") != 0) { button_OK.IsEnabled = true; } } SetBinding(ModelProperty, new Binding()); }
static void Main() { using (var model = ifcRepo.Model) { using (var txn = model.BeginTransaction("Modification")) { IIfcProject ifcProject = model.Instances.FirstOrDefault <IIfcProject>(); ifcProject.Name = "TEST4"; var ifcProjectID = ifcProject.GlobalId.ToString(); Db.Transact(() => { new B5DTest().CreateProjectTree(ifcProject); //var root = Db.SQL($"SELECT r FROM {typeof(IfcRoot)} r WHERE r.{nameof(IfcRoot.ExternalIfcGlobalId)} = ?", ifcProjectID).FirstOrDefault(); //if (root == null) //{ // new B5DTest().CreateProjectTree(ifcProject); //} }); } } }
public void CreateProjectTree(IIfcProject ifcProject) { BuildTree(null, null, ifcProject); }
public IfcLocationData(string path) { using (IfcStore model = IfcStore.Open(path)) { if (model.SchemaVersion == XbimSchemaVersion.Ifc2X3) { Schema = "Ifc 2x3"; SchemaIsSupported = true; } else if (model.SchemaVersion == XbimSchemaVersion.Ifc4) { Schema = "Ifc4"; SchemaIsSupported = false; return; } else { Schema = model.SchemaVersion.ToString(); SchemaIsSupported = false; return; } IIfcProject project = model.Instances.FirstOrDefault <IIfcProject>(); string applicationFullname = project.OwnerHistory.OwningApplication.ApplicationFullName; if (applicationFullname == null) { AuthoringTool = "N/A"; } else { AuthoringTool = project.OwnerHistory.OwningApplication.ApplicationFullName; } IIfcSIUnit lengtUnit = project.UnitsInContext.Units.FirstOrDefault <IIfcSIUnit>(q => q.UnitType == IfcUnitEnum.LENGTHUNIT); LengthUnit = lengtUnit.FullName; IIfcSite site = model.Instances.FirstOrDefault <IIfcSite>(); if (site.RefElevation.HasValue) { refElevation = site.RefElevation.Value; } else { refElevation = double.NaN; } IIfcLocalPlacement placement = site.ObjectPlacement as IIfcLocalPlacement; IIfcAxis2Placement3D axis2Placement = placement.RelativePlacement as IIfcAxis2Placement3D; double x = axis2Placement.RefDirection.DirectionRatios.GetAt(0); double y = axis2Placement.RefDirection.DirectionRatios.GetAt(1); double angle = 360 - Math.Atan2(y, x) * 180 / Math.PI; if (angle.Equals(360)) { angle = 0; } Orientation = angle; EW = axis2Placement.Location.Coordinates.GetAt(0); NS = axis2Placement.Location.Coordinates.GetAt(1); elevation = axis2Placement.Location.Coordinates.GetAt(2); } }
public XbimModelViewModel(IIfcProject project, IXbimViewModel parent) { Model = project.Model; _project = project; CreatingParent = parent; }
public static IEnumerable <IIfcSpatialStructureElement> GetSpatialStructuralElements(this IIfcProject project) { return(project.IsDecomposedBy.SelectMany(rel => rel.RelatedObjects.OfType <IIfcSpatialStructureElement>())); }
public static IEnumerable <EntityIndex <IfcLabeledElement <IPersistEntity> > > FlattenEntityIndex(this IIfcProject p) { var stack = new Stack <IIfcSpatialElement>(p.SpatialStructuralElements.Reverse()); var index = new Dictionary <IIfcSpatialElement, EntityIndex <IfcLabeledElement <IPersistEntity> > >(); while (0 < stack.Count) { var element = stack.Pop(); EntityIndex <IfcLabeledElement <IPersistEntity> > parent = null; index.TryGetValue(element.IsContainedIn, out parent); // Depth first for structural elements branch foreach (var relAggregate in element.Decomposes.Reverse()) { foreach (var subElement in relAggregate.RelatedObjects.OfType <IIfcSpatialStructureElement>().Reverse()) { var e = new EntityIndex <IfcLabeledElement <IPersistEntity> >( parent, new IfcLabeledElement <IPersistEntity>(subElement) ); index.Add(subElement, e); stack.Push(subElement); yield return(e); } } // Finally return all products foreach (var product in element.ContainsElements.SelectMany(x => x.RelatedElements)) { yield return(new EntityIndex <IfcLabeledElement <IPersistEntity> >(parent, new IfcLabeledElement <IPersistEntity>(product))); } } }