Is it possible to delete Arrowhead types?

Is it possible to delete Arrowhead types?

gopinath.rajendran
Enthusiast Enthusiast
1,118 Views
11 Replies
Message 1 of 12

Is it possible to delete Arrowhead types?

gopinath.rajendran
Enthusiast
Enthusiast

var arrowHeads = new FilteredElementCollector(doc).WhereElementIsElementType().Cast<ElementType>().Where(t => t.FamilyName == "Arrowhead").ToList();

using (Transaction trans = new Transaction(doc, "Remove Arrowhead"))
{
trans.Start();

foreach (var arrowHead in arrowHeads)
{
doc.Delete(arrowHead.Id);
}

trans.Commit();
}

Throws an Autodesk.Revit.Exceptions.InternalException: 'An internal error has occurred,' and then Revit crashed

0 Likes
1,119 Views
11 Replies
Replies (11)
Message 2 of 12

jeremy_tammik
Alumni
Alumni

Maybe the type is in use? Can you share a complete minimal reproducible case for us and the development team to take a closer look?

  

  

Thank you.

  

P.S. Your code will be more readable if you use the insert code button marked </> to add it to your post.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 12

Mohamed_Arshad
Advisor
Advisor

Hi @gopinath.rajendran 

 

     You can't able to delete the System Types, we can able to purge the system types. Kindly check the below link for additional reference.

 

Reference Image

Mohamed_Arshad_0-1726557582704.png

 

 

Reference Links

https://forums.autodesk.com/t5/revit-api-forum/purge-unused-via-the-api/td-p/6431564 

https://thebuildingcoder.typepad.com/blog/2017/11/purge-and-detecting-an-empty-view.html

https://thebuildingcoder.typepad.com/blog/2022/03/purge-unused-and-the-autodesk-camel.html 

 

Hope this will Helps 🙂 


Mohamed Arshad K
Software Developer (CAD & BIM)

Message 4 of 12

gopinath.rajendran
Enthusiast
Enthusiast

gopinathrajendran_0-1726556972928.png

After the exception mentioned above, if I try to commit the transaction, the following window appears

gopinathrajendran_1-1726558528750.png

 

I couldn't replicate the crash in a separate piece of code. Maybe resolving this error will fix the crashing issue. After encountering the first error window, Revit always crashes when using the plugin.

Here complete code:

var doc = ActiveUIDocument.Document;
var arrowHeads = new FilteredElementCollector(doc).WhereElementIsElementType().Cast<ElementType>().Where(t => t.FamilyName == "Arrowhead").ToList();

using (Transaction trans = new Transaction(doc, "Remove Arrowhead"))
{
trans.Start();

foreach (var arrowHead in arrowHeads)
{
try
{
doc.Delete(arrowHead.Id);

}
catch (System.Exception ex)
{
}
}

trans.Commit();
}

This error window can be replicated using the rac_basic_sample_project.rvt sample model in Revit.

it happens on Revit 2023, Revit 2024 and Revit 2025.

0 Likes
Message 5 of 12

gopinath.rajendran
Enthusiast
Enthusiast

@Mohamed_ArshadThanks for your input. It's not about deleting all the elements. I need to know how to prevent Revit from crashing when an element is not deletable.

0 Likes
Message 6 of 12

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @gopinath.rajendran ,

 

You can determine whether the Arrowhead type is deletable or not by using the CanBeDeleted property.
This will help prevent Revit from crashing.

https://www.revitapidocs.com/2015/5efe8253-d555-00c2-8db6-9114e328fcc7.htm 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 12

gopinath.rajendran
Enthusiast
Enthusiast

@naveen.kumar.t  I tried this before, and it is true for all elements.

gopinathrajendran_0-1726564008803.png

 

0 Likes
Message 8 of 12

Mohamed_Arshad
Advisor
Advisor

HI @naveen.kumar.t  @gopinath.rajendran 

 

     @naveen.kumar.t  I checked the mentioned property but it true for Arrow Head, My suggestion is to try use IFailurePreProcessor to handle Revit based errors. If we got any serious errors we can skip the process without crashing Revit.

 

Hope this will Helps 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 9 of 12

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi,

 

 

I’ve escalated the issue to the Revit Engineering team, and I’ll get back to you as soon as I hear from them


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 10 of 12

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @gopinath.rajendran ,

 

I have tested deleting all arrowhead types and was able to remove all except "Arrow Open 90 Degree 1.25mm".

Each time I attempt to delete this specific arrowhead type, I encounter an exception/crash.
The issue persists regardless of whether I try to delete this arrowhead type first or last.

Could you please verify if the same arrowhead type is causing the issue on your end?

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 11 of 12

gopinath.rajendran
Enthusiast
Enthusiast

Yes. It is

0 Likes
Message 12 of 12

naveen.kumar.t
Autodesk Support
Autodesk Support

The Arrow Open 90 Degree 1.25mm arrowhead type is being used by a component.

Upon reviewing the journal file, I discovered that this particular arrowhead type is internally utilized by StairsPathType StairsPathType::setArrowheadTypeId.

 

This explains why Revit throws an exception when attempting to delete it.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes