//private void Add_Click(object sender, RoutedEventArgs e) //{ // XbimModel model = DataContext as XbimModel; // if (model != null) // { // AddFederatedModel fdlg = new AddFederatedModel(); // bool? done = fdlg.ShowDialog(); // if (done.HasValue && done.Value == true) // { // string fileName = fdlg.FileName; // string ext = System.IO.Path.GetExtension(fileName); // using (XbimModel refM = new XbimModel()) // { // if (string.Compare(ext, ".xbim", true) != 0) // { // refM.CreateFrom(fileName, null, null, true); // XbimMesher.GenerateGeometry(refM); // fileName = System.IO.Path.ChangeExtension(fileName, "xbim"); // } // } // IfcRole role = fdlg.Role; // if (role == IfcRole.UserDefined) // model.AddModelReference(fileName, fdlg.OrganisationName, fdlg.RoleName); // else // model.AddModelReference(fileName, fdlg.OrganisationName, role); // } // } //} private void Add_Click(object sender, RoutedEventArgs e) { XbimModel model = DataContext as XbimModel; if (model != null) { AddFederatedModel fdlg = new AddFederatedModel(); bool?done = fdlg.ShowDialog(); if (done.HasValue && done.Value == true) { string fileName = fdlg.FileName; string ext = System.IO.Path.GetExtension(fileName); using (XbimModel refM = new XbimModel()) { if (string.Compare(ext, ".xbim", true) != 0) { refM.CreateFrom(fileName, null, null, true); var m3D = new Xbim3DModelContext(refM); m3D.CreateContext(); fileName = System.IO.Path.ChangeExtension(fileName, "xbim"); } } IfcRole role = fdlg.Role; if (role == IfcRole.UserDefined) { model.AddModelReference(fileName, fdlg.OrganisationName, fdlg.RoleName); } else { model.AddModelReference(fileName, fdlg.OrganisationName, role); } } } }
/// <summary> /// Add the refrence models /// </summary> /// <param name="file">FileInfo for the xbimf file</param> /// <param name="organizationName">Organisation Name</param> /// <param name="role">RoleFilter</param> /// <param name="displayName"></param> public void AddRefModel(FileInfo file, string organizationName, RoleFilter roles = RoleFilter.Unknown, string displayName = null) { if (!file.Exists) { throw new FileNotFoundException("Cannot find reference model file", file.FullName); } //add model to list of referenced models IfcIdentifier docId = _fedModel.AddModelReference(file.FullName, organizationName, IfcRole.UserDefined).Identifier; using (var txn = _fedModel.BeginTransaction()) { IfcDocumentInformation addDocId = _fedModel.ReferencedModels.Where(item => item.DocumentInformation.DocumentId == docId).Select(item => item.DocumentInformation).FirstOrDefault(); IfcOrganization org = addDocId.DocumentOwner as IfcOrganization; if (org != null) { org.Roles.Clear(); //Add Roles foreach (var item in GetActorRoles(roles)) { org.AddRole(item); } } //add display name if required if (displayName != null) { addDocId.Description = displayName; } txn.Commit(); } }
/// <summary> /// Validates all data and creates model. /// Provide a "XbimModel model = DataContext as XbimModel;" /// </summary> /// <returns>Returns XbimReferencedModel == null </returns> public bool TryBuild(XbimModel model) { //it's already build, so no need to recreate it if (ReferencedModel != null) { return(true); } if (string.IsNullOrWhiteSpace(Name)) { return(false); } else { string ext = System.IO.Path.GetExtension(Name).ToLowerInvariant(); using (XbimModel refM = new XbimModel()) { if (ext != ".xbim") { refM.CreateFrom(Name, null, null, true); var m3D = new Xbim3DModelContext(refM); m3D.CreateContext(); Name = System.IO.Path.ChangeExtension(Name, "xbim"); } } _xbimReferencedModel = model.AddModelReference(Name, OrganisationName, OrganisationRole); } if (_xbimReferencedModel != null) { //refresh all OnPropertyChanged("Identifier"); OnPropertyChanged("Name"); OnPropertyChanged("OrganisationName"); OnPropertyChanged("OrganisationRole"); } return(ReferencedModel != null); }
/// <summary> /// Validates all data and creates model. /// Provide a "XbimModel model = DataContext as XbimModel;" /// </summary> /// <returns>Returns XbimReferencedModel == null </returns> public bool TryBuild(XbimModel model) { //it's already build, so no need to recreate it if (ReferencedModel != null) { return(true); } if (string.IsNullOrWhiteSpace(Name)) { return(false); } var ext = Path.GetExtension(Name).ToLowerInvariant(); using (var refM = new XbimModel()) { var xbimName = Path.ChangeExtension(Name, "xbim"); if (ext != ".xbim" && !File.Exists(xbimName)) { refM.CreateFrom(Name, null, null, true); var m3D = new Xbim3DModelContext(refM); m3D.CreateContext(geomStorageType: XbimGeometryType.PolyhedronBinary, progDelegate: null, adjustWCS: false); Name = Path.ChangeExtension(Name, "xbim"); } Name = xbimName; } _xbimReferencedModel = model.AddModelReference(Name, OrganisationName, OrganisationRole); if (_xbimReferencedModel == null) { return(ReferencedModel != null); } //refresh all OnPropertyChanged("Identifier"); OnPropertyChanged("Name"); OnPropertyChanged("OrganisationName"); OnPropertyChanged("OrganisationRole"); return(ReferencedModel != null); }
/// <summary> /// Validates all data and creates model. /// Provide a "XbimModel model = DataContext as XbimModel;" /// </summary> /// <returns>Returns XbimReferencedModel == null </returns> public bool TryBuild(XbimModel model) { //it's already build, so no need to recreate it if (ReferencedModel != null) return true; if (string.IsNullOrWhiteSpace(Name)) return false; else { string ext = System.IO.Path.GetExtension(Name).ToLowerInvariant(); using (XbimModel refM = new XbimModel()) { if (ext != ".xbim") { refM.CreateFrom(Name, null, null, true); XbimMesher.GenerateGeometry(refM); Name = System.IO.Path.ChangeExtension(Name, "xbim"); } } _xbimReferencedModel = model.AddModelReference(Name, OrganisationName, OrganisationRole); } if (_xbimReferencedModel != null) { //refresh all OnPropertyChanged("Identifier"); OnPropertyChanged("Name"); OnPropertyChanged("OrganisationName"); OnPropertyChanged("OrganisationRole"); } return ReferencedModel != null; }
/// <summary> /// Validates all data and creates model. /// Provide a "XbimModel model = DataContext as XbimModel;" /// </summary> /// <returns>Returns XbimReferencedModel == null </returns> public bool TryBuild(XbimModel model) { //it's already build, so no need to recreate it if (ReferencedModel != null) return true; if (string.IsNullOrWhiteSpace(Name)) return false; var ext = Path.GetExtension(Name).ToLowerInvariant(); using (var refM = new XbimModel()) { var xbimName = Path.ChangeExtension(Name, "xbim"); if (ext != ".xbim" && !File.Exists(xbimName)) { refM.CreateFrom(Name, null, null, true); var m3D = new Xbim3DModelContext(refM); m3D.CreateContext(geomStorageType: XbimGeometryType.PolyhedronBinary, progDelegate: null, adjustWCS: false); Name = Path.ChangeExtension(Name, "xbim"); } Name = xbimName; } _xbimReferencedModel = model.AddModelReference(Name, OrganisationName, OrganisationRole); if (_xbimReferencedModel == null) return ReferencedModel != null; //refresh all OnPropertyChanged("Identifier"); OnPropertyChanged("Name"); OnPropertyChanged("OrganisationName"); OnPropertyChanged("OrganisationRole"); return ReferencedModel != null; }