Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66796

Re: Central Model

$
0
0

So basically you need to check if an Element is still "Borrowed" in the central model. I'm not aware of an API method you can call for all elements in one go. You'll need to open a (new) local file and check for each element your self.

 

private bool AreAllElementsRelinquished(Document doc)
{
	WorksetTable table = doc.GetWorksetTable();
	IList<WorksetPreview> wInfo =  WorksharingUtils.GetUserWorksetInfo(doc.GetWorksharingCentralModelPath());
	foreach(WorksetPreview info in wInfo)
	{
		if (!string.IsNullOrWhiteSpace( info.Owner)) return false;
	}
	IEnumerable<Element> types = new FilteredElementCollector(doc)
				.WhereElementIsElementType();
	foreach(Element e in types)
	{
		CheckoutStatus st = WorksharingUtils.GetCheckoutStatus(doc,e.Id);
		if(st != CheckoutStatus.NotOwned) return false;
	}
	IEnumerable<Element> elems = new FilteredElementCollector(doc)
		.WhereElementIsNotElementType();
	foreach(Element e in elems)
	{
		CheckoutStatus st = WorksharingUtils.GetCheckoutStatus(doc,e.Id);
		if(st != CheckoutStatus.NotOwned) return false;
	}
	return true;
}

Viewing all articles
Browse latest Browse all 66796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>