I have match line view references that I'm trying to delete with no luck. The problem is in the vrIds FilteredElementCollector. It doesn't find any.
Thanks in advance for the help.
var views = new FilteredElementCollector(doc).OfClass(typeof(View)).Cast<View>()
.Where(vw => vw.ViewType == ViewType.FloorPlan || vw.ViewType == ViewType.CeilingPlan || vw.ViewType == ViewType.Elevation).ToList()
.Where(vw => vw.IsTemplate == false);
int vrCount = 0;
using (Transaction vr = new Transaction(doc))
try
{
vr.Start("Delete View Refereneces");
foreach (var vw in views)
{
var vrIds = new FilteredElementCollector(doc, vw.Id)
.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_ReferenceViewer)
.ToElementIds();
foreach (var vr_id in vrIds)
{
doc.Delete(vr_id);
vrCount++;
}
}
Solved! Go to Solution.
I have match line view references that I'm trying to delete with no luck. The problem is in the vrIds FilteredElementCollector. It doesn't find any.
Thanks in advance for the help.
var views = new FilteredElementCollector(doc).OfClass(typeof(View)).Cast<View>()
.Where(vw => vw.ViewType == ViewType.FloorPlan || vw.ViewType == ViewType.CeilingPlan || vw.ViewType == ViewType.Elevation).ToList()
.Where(vw => vw.IsTemplate == false);
int vrCount = 0;
using (Transaction vr = new Transaction(doc))
try
{
vr.Start("Delete View Refereneces");
foreach (var vw in views)
{
var vrIds = new FilteredElementCollector(doc, vw.Id)
.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_ReferenceViewer)
.ToElementIds();
foreach (var vr_id in vrIds)
{
doc.Delete(vr_id);
vrCount++;
}
}
Solved! Go to Solution.
Solved by RPTHOMAS108. Go to Solution.
I don't know what OST_ReferenceViewer stands for.
Do you?
Do the views that you wish to delete really have this category?
Use RevitLookup to check.
All you are using from the filtered element collector are the view element ids.
I would suggest extracting and storing only those ids in a list, and forgetting about the `views` variable.
That would make it cleaner and clearer.
I don't know what OST_ReferenceViewer stands for.
Do you?
Do the views that you wish to delete really have this category?
Use RevitLookup to check.
All you are using from the filtered element collector are the view element ids.
I would suggest extracting and storing only those ids in a list, and forgetting about the `views` variable.
That would make it cleaner and clearer.
Hi Jeremy,
Thanks for the reply. I'm not trying to delete the view just trying to go through all of them and delete any view references in them. RevitLookup shows that they are of the category OST.ReferenceViewer. See attached image.
Thanks again for the help.
Hi Jeremy,
Thanks for the reply. I'm not trying to delete the view just trying to go through all of them and delete any view references in them. RevitLookup shows that they are of the category OST.ReferenceViewer. See attached image.
Thanks again for the help.
Looks OK to me...
Me too but it still doesn't delete them. I have used similar code to delete other elements of different categories without issues.
Me too but it still doesn't delete them. I have used similar code to delete other elements of different categories without issues.
Maybe the view reference is not a self-determined independent element, but dependent on something else.
In that case, it can be considered a sort of view of cause, just a symptom.
In that case, it might help to find out what is generating it in the first place.
Maybe the view reference is not a self-determined independent element, but dependent on something else.
In that case, it can be considered a sort of view of cause, just a symptom.
In that case, it might help to find out what is generating it in the first place.
This is probably not what you mean by "what is generating it in the first place" but just in case it is...
This is probably not what you mean by "what is generating it in the first place" but just in case it is...
You can analyse exactly what the effect of running that commands is, specifically, what elements that adds to the Revit database, by using the element lister utility as described in How to research to find a Revit API solution:
Knowing what elements are added might help understand how to remove them again.
You can analyse exactly what the effect of running that commands is, specifically, what elements that adds to the Revit database, by using the element lister utility as described in How to research to find a Revit API solution:
Knowing what elements are added might help understand how to remove them again.
Thanks. I've created an account on GiHub but can't seem to locate the element lister file(s). Having trouble navigating their site.
Thanks. I've created an account on GiHub but can't seem to locate the element lister file(s). Having trouble navigating their site.
What type of ViewPlan are you wanting to remove the items from, you've not listed all the plan ViewTypes in the collector?
ViewType.AreaPlan
ViewType.EngineeringPlan
What type of ViewPlan are you wanting to remove the items from, you've not listed all the plan ViewTypes in the collector?
ViewType.AreaPlan
ViewType.EngineeringPlan
I have it search all of these types.
ViewType.FloorPlan
ViewType.CeilingPlan
ViewType.Elevation
Thanks
I have it search all of these types.
ViewType.FloorPlan
ViewType.CeilingPlan
ViewType.Elevation
Thanks
I can see that, are those the only types you are interested in? i.e. if the view discipline is Structural then the type will be EngineeringPlan not FloorPlan.
I can see that, are those the only types you are interested in? i.e. if the view discipline is Structural then the type will be EngineeringPlan not FloorPlan.
You don't need an account. You can download stuff without logging in at all.
I strongly recommend using GitHub if you do any programming yourself whatsoever!
You don't need to download the whole thing, just implement the Lab2_1_Elements:.
You can grab the code directly:
https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs2.cs#L429-L540
It is totally trivial, really:
With this command in place, you can compare two snapshots of the database by performing a diff between the two text files.
You don't need an account. You can download stuff without logging in at all.
I strongly recommend using GitHub if you do any programming yourself whatsoever!
You don't need to download the whole thing, just implement the Lab2_1_Elements:.
You can grab the code directly:
https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs2.cs#L429-L540
It is totally trivial, really:
With this command in place, you can compare two snapshots of the database by performing a diff between the two text files.
Hi,
You can apply parameter filter to fec. Use BuiltinParameter ELEM_CATEGORY_PARAM_MT, elementid of this parameter will be your parameter value provider, and to the value to check would be View Reference AsValueString. This way, you will get all the view references in the view by using filteredelementcollector(doc, view.id).
Cheers,
Vishal Kelani
Hi,
You can apply parameter filter to fec. Use BuiltinParameter ELEM_CATEGORY_PARAM_MT, elementid of this parameter will be your parameter value provider, and to the value to check would be View Reference AsValueString. This way, you will get all the view references in the view by using filteredelementcollector(doc, view.id).
Cheers,
Vishal Kelani
Also the object is not a FamilyInstance, it is showing as Element in RevitLookup (it would tell you there it was FamilyInstance if it was one). Therefore you will likely not find it by filtering for class of type FamilyInstance. If you take that out you may find them.
Also the object is not a FamilyInstance, it is showing as Element in RevitLookup (it would tell you there it was FamilyInstance if it was one). Therefore you will likely not find it by filtering for class of type FamilyInstance. If you take that out you may find them.
you're right, I missed that. It's recycled code from another app of mine. I'll look into it. Thanks
you're right, I missed that. It's recycled code from another app of mine. I'll look into it. Thanks
That was it. Thank you very much!
That was it. Thank you very much!
@RPTHOMAS108 - After accessing these view reference elements, can they also be updated programatically so that the "Target View" (read only parameter) is modified to another view? Thank you
@RPTHOMAS108 - After accessing these view reference elements, can they also be updated programatically so that the "Target View" (read only parameter) is modified to another view? Thank you
Can't find what you're looking for? Ask the community or share your knowledge.