Skip to content

Added owner to Checkout Status methods #1292

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

Merged
merged 3 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Revit_Core_Engine/Query/CheckoutStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ public static partial class Query
}
return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id);
}

/***************************************************/

[Description("Returns element CheckoutStatus.")]
[Input("element", "Revit element to query for its checkout status.")]
[Output("checkoutStatus", "The worksharing ownership/CheckoutStatus of the element.")]
public static CheckoutStatus? CheckoutStatus(this Element element, out string owner)
{
if (element == null)
{
BH.Engine.Base.Compute.RecordError("Querying checkout status of element failed because the element provided was null.");
owner = null;
return null;
}

CheckoutStatus status = WorksharingUtils.GetCheckoutStatus(element.Document, element.Id, out owner);
owner = string.IsNullOrEmpty(owner) ? "Unknown User" : owner;

return status;
}

/***************************************************/
}
}
28 changes: 28 additions & 0 deletions Revit_Core_Engine/Query/IsOwnedByOtherUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,36 @@ public static bool IsOwnedByOtherUser(this Element element)
return false;
}

if (!element.Document.IsWorkshared)
{
return false;
}

return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser;
}

/***************************************************/

[Description("Check if element is owned by another user.")]
[Input("element", "Revit element to query for its checkout status.")]
[Output("ownedByOtherUser", "True if the input Revit element is owned by another user, otherwise false.")]
public static bool IsOwnedByOtherUser(this Element element, out string owner)
{
if (element == null)
{
BH.Engine.Base.Compute.RecordError("Querying checkout status of element for ownership by others failed because the element provided was null.");
owner = null;
return false;
}

if (!element.Document.IsWorkshared)
{
owner = null;
return false;
}

return element.CheckoutStatus(out owner) == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser;
}
/***************************************************/
}
}