Skip to content

Commit

Permalink
fixed bug detaching all users
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Jan 30, 2021
1 parent 450dbe9 commit 92a40e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion dev/pyRevitLabs/pyRevitCLI/PyRevitCLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ private static void ProcessArguments() {
else
PyRevitCLICloneCmds.DetachClone(
revitYear: TryGetValue("<revit_year>"),
all: arguments["--all"].IsTrue
all: arguments["--all"].IsTrue,
currentAndAllUsers: true
);
}

Expand Down
4 changes: 2 additions & 2 deletions dev/pyRevitLabs/pyRevitCLI/PyRevitCLICloneCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ internal static void
}

internal static void
DetachClone(string revitYear, bool all) {
DetachClone(string revitYear, bool all, bool currentAndAllUsers = false) {
if (revitYear != null) {
int revitYearNumber = 0;
if (int.TryParse(revitYear, out revitYearNumber))
Expand All @@ -311,7 +311,7 @@ internal static void
throw new PyRevitException(string.Format("Invalid Revit year \"{0}\"", revitYear));
}
else if (all)
PyRevitAttachments.DetachAll();
PyRevitAttachments.DetachAll(currentAndAllUsers);
}

internal static void
Expand Down
8 changes: 4 additions & 4 deletions dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitAttachments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ public static void Detach(int revitYear, bool currentAndAllUsers = false) {

// detach pyrevit attachment
// @handled @logs
public static void Detach(PyRevitAttachment attachment) {
public static void Detach(PyRevitAttachment attachment, bool currentAndAllUsers = false) {
logger.Debug("Detaching from Revit {0}", attachment.Product.ProductYear);
Detach(attachment.Product.ProductYear);
Detach(attachment.Product.ProductYear, currentAndAllUsers);
}

// detach from all attached revits
// @handled @logs
public static void DetachAll() {
public static void DetachAll(bool currentAndAllUsers = false) {
foreach (var attachment in GetAttachments()) {
Detach(attachment);
Detach(attachment, currentAndAllUsers);
}
}

Expand Down

0 comments on commit 92a40e6

Please sign in to comment.