A strange problem intesting the revit link file

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I link a revit file to another and do some test, but the the Code Region1 can not find the revit link file, while the other 3 parts can work:
// -------------- Code Region1 ---- can not work -------------------------------
TaskDialog.Show("Simple test", "4.1 " );
Category linkCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_RvtLinks);
if (linkCat != null)
{
TaskDialog.Show("Simple test", "4.2 " + linkCat.ToString());
}
TaskDialog.Show("Simple test", "4.3 " );
only prompt ["Simple test", "4.1 " ] and ["Simple test", "4.3 " ], so it can not find the revit link file
// -------------- end of Code Region1 -------------------------------
// -------------- Code Region2 --- can work -------------------------------
FilteredElementCollector collector = new FilteredElementCollector(doc);
IList<Element> walls = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
String prompt = "The walls in the current document are:\n";
foreach (Element e in walls)
{
prompt += e.Name + "\n";
}
TaskDialog.Show("filter", prompt);
it can find all the walls
// -------------- end of Code Region2 -------------------------------
// -------------- Code Region3 --- can work -------------------------------
ElementCategoryFilter linkFilter = new ElementCategoryFilter(BuiltInCategory.OST_RvtLinks);
FilteredElementCollector linkCollector = new FilteredElementCollector(doc);
IList<Element> linkDocs = linkCollector.WherePasses(linkFilter).WhereElementIsElementType().ToElements();
int count = linkDocs.Count();
prompt = "";
if (count > 0)
{
foreach (Element e in linkDocs)
{
prompt += e.Name + "\n";
}
}
TaskDialog.Show("filter", prompt);
it can show the link revit file name, so it can work
// --------------end of Code Region3 ----------------------------------
// -------------- Code Region4 --- can work -------------------------------
Category roomcat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Rooms);
if (roomcat != null)
{
TaskDialog.Show("Simple test", "3 " + roomcat.ToString());
}
// --------------end of Code Region4 ---------------------------------
As can be seen above, the Code Region2 and -Code Region3 are similar and both can work.
The Code Region1 and -Code Region4 are similar, but the Code Region4 can work while the Code Region1 cannot work.
And the Code Region3 can show the revit link file.
What's the problem? Can anyone tell me ?
Thx !
Davix