DetachClone(string revitYear, bool all, bool currentAndAllUsers = false) { if (revitYear != null) { int revitYearNumber = 0; if (int.TryParse(revitYear, out revitYearNumber)) { PyRevitAttachments.Detach(revitYearNumber, currentAndAllUsers: true); } else { throw new PyRevitException(string.Format("Invalid Revit year \"{0}\"", revitYear)); } } else if (all) { PyRevitAttachments.DetachAll(currentAndAllUsers); } }
DeleteClone(bool allClones, string cloneName, bool clearConfigs) { if (allClones) { PyRevitClones.DeleteAllClones(clearConfigs: clearConfigs); } else if (cloneName != null) { // lets detach the clone if there is any attachments to it var clone = PyRevitClones.GetRegisteredClone(cloneName); foreach (var attachment in PyRevitAttachments.GetAttachments()) { if (attachment.Clone.Equals(clone)) { logger.Debug($"Detaching existing attachment: {attachment}"); PyRevitAttachments.Detach(attachment.Product.ProductYear, attachment.AllUsers); } } PyRevitClones.Delete(clone, clearConfigs: clearConfigs); } }