Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am writing a routine that would unload 3 worksets from our linked models. Based on everything I have found online, I believe I written this correctly. However everytime i run this routine nothing appears to happen. The only thing I can think of that would be limiting me is how i filter down to just those names that is the issue. I have never tried to write anything that is accessing inside a linked model.
public void unloadlinkwrkst(UIApplication uiapp, Document doc) { Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; try { List<Element> lstRvtLinkType = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkType)).ToList(); foreach (Document _linkdoc in app.Documents) { if (!_linkdoc.IsLinked) continue; RevitLinkType _RvtLinkType = null; foreach (Element elmnt in lstRvtLinkType) { _RvtLinkType = elmnt as RevitLinkType; if (_RvtLinkType.Name != _linkdoc.Title) continue; else break; } List<WorksetId> lstWkSet_Close = new List<WorksetId>(); WorksetConfiguration wk = new WorksetConfiguration(); ModelPath _modelpath = _linkdoc.GetWorksharingCentralModelPath(); WorksetTable _worksetTable = _linkdoc.GetWorksetTable(); IList<WorksetPreview> lstPreview = WorksharingUtils.GetUserWorksetInfo(_modelpath); foreach (WorksetPreview item in lstPreview) { Workset wkset = _worksetTable.GetWorkset(item.Id); if (!wkset.IsOpen) { if ((item.Name.CompareTo("Shared Levels and Grids") == 0) || (item.Name.CompareTo("1/4 SCOPEBOX AND MATCHLINE") == 0) || (item.Name.CompareTo("1/8 SCOPEBOX AND MATCHLINE") == 0)) { lstWkSet_Close.Add(item.Id); continue; } } } wk.Close(lstWkSet_Close); _RvtLinkType.LoadFrom(_modelpath, wk); } } catch (Exception e) { TaskDialog.Show("dd", e.Message); return; } return; }
Solved! Go to Solution.