-
Notifications
You must be signed in to change notification settings - Fork 174
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
XBim have “IfcStore.AddModelReference” API,but where is the "Remove ModelReference" API ? #515
Comments
Moved from Windows UI project. Looks like it didn't get thought about.... You could implement as a simple extension method with a couple of lines of code: public static class IfcStoreFederationExtensions
{
public static bool RemoveModelReference(this IfcStore store, IReferencedModel model)
{
var referenced = store.ReferencedModels as ReferencedModelCollection;
return referenced!.Remove(model);
}
}
// then call like this
var toRemove = model.ReferencedModels.First(m => m.Name == "yourModelToRemove");
myStore.RemoveModelReference(toRemove), Happy to take a PR if you want to add it formally |
Thank you very much for your response. I have tried the code you provided and also studied the source code. The ReferencedModelCollection contains two parts: one is stored in the IFC file, and the other is in the ReferencedModelCollection itself. So, removing the model reference using RemoveModelReference still keeps the graphical representation in the UI, and the link document is still present when opening the IFC file again. Therefore, it is necessary to delete the link information within the IFC file as well. Below is my code, please feel free to provide any suggestions for improvement. Xbim.Ifc4.ExternalReferenceResource.IfcDocumentInformation document = refence.DocumentInformation as Xbim.Ifc4.ExternalReferenceResource.IfcDocumentInformation;
if (document != null)
{
Xbim.Ifc4.ActorResource.IfcOrganization owner = document.DocumentOwner as Xbim.Ifc4.ActorResource.IfcOrganization;
if (owner != null)
{
if (owner.Roles != null && owner.Roles.Count == 1)
{
modelIFC.Delete(owner.Roles[0]);
}
modelIFC.Delete(owner);
}
modelIFC.Delete(document);
} |
OK, that makes sense. I won't profess to being that familiar with this code That will only work for IFC4 schema (not Ifc2x3, 4.3 etc). if you cast to IIfcDocumentationInfo and IIfcOrganization it should work across schemas |
XBim have “IfcStore.AddModelReference” API,but where is the "Remove ModelReference" API ?
The text was updated successfully, but these errors were encountered: