Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

delete textnotetype using API

8 REPLIES 8
Reply
Message 1 of 9
sobon.konrad
769 Views, 8 Replies

delete textnotetype using API

so I was wondering if it is possible to delete a textnotetype using evit API. I have seen Jeremy's post outlining how to delete textnotetypes that are not being used in a project, but my question pertains to ones that somehow Revit thinks are being used even though there is 0 instances of that text type amongst all textnotes. I guess it could have been used in a schedule or family and loaded into a model. How would i handle that? Ideas? 

 

Thank you! 

8 REPLIES 8
Message 2 of 9
arnostlobel
in reply to: sobon.konrad

Hello Konrad:

 

I do not think there is a way to do what you want. As you guessed, text types are shared across various text annotations, some of which are not exposed in the API yet. The types are not used for Text Notes only.

 

You inquiry begs a question: Why do you want to deleted [seemingly] unused text type? Is it some kind of a custom purge command?

Arnošt Löbel
Message 3 of 9
sobon.konrad
in reply to: arnostlobel

yes, I am writing a command that allows you to replace text notes of one style with another and after that attempt to delete [the now seemingly unused] text type. However, more often than not it has failed to delete text types. I know why, question was how do i get a hold of them all (schedules/families etc)? You are saying that i cannot access and then change all of them because API doesnt allow it yet so theres my answer. 😞 Can you at least tell me what exacly uses TextTypes outside of Schedule and TextNote? 

Message 4 of 9
arnostlobel
in reply to: sobon.konrad

Hello Konrad:

Yes, that is what I am saying: The Text Types are used for elements other than those you can see in the API. There are shared by most annotation kind of elements, such as dimensions, tags, text in schedules, and others. The list is longer than what I present here and I do not actually know what are all the kinds of elements. However, what I am pretty sure of is that not all the kind of such elements are exposed in the API, therefore you cannot get to them, which makes your goal impossible to implement.

However, maybe you can use the CanBeDeleted property of ElementType to figure out whether or not a particular type can be deleted. I have not tried this approach, but I assume it is worth trying.
Arnošt Löbel
Message 5 of 9
sobon.konrad
in reply to: arnostlobel

Yes, this sounds resonable. I am just struggling with the idea that there is nothing that i can do to get rid of some text type that was loaded into my project from a different project when someone was importing a Drafting View (now I have a mix of Metric and imperial TextTypes and flavors). What would have happened if i made sure that no Tags, TextNotes, Schedules and Dimension Styles are using that given TextType. Will I be able to delete it if nothing is using it or will Revit still want to keep it around? 

 

Thanks! 

Message 6 of 9
arnostlobel
in reply to: sobon.konrad

Generally speaking, you should be able to delete a type if nothing else in a model uses it. However, there are some special types to which Revit always has reference to, which would be impossible to delete regardless of their usage. I do not think it would be the case of elements which were brought with an imported view. Even if so, however, you should not worry about such types, for I assume they would not be accessible via the UI.
Arnošt Löbel
Message 7 of 9
dbrokaw
in reply to: arnostlobel

Message 8 of 9
Dale.Bartlett
in reply to: dbrokaw

I am purging TextNoteTypes with code based on suggestions from Jeremy some time back:

https://thebuildingcoder.typepad.com/blog/2010/11/purge-unused-text-note-types.html 

I am tracking total items found (GetUnusedTextNoteTypes) to delete vs the total items actually deleted:

ICollection<ElementId> idsDeleted = doc.Delete(ids);
lintTotalDeleted = idsDeleted.Count; // actual, not attempted 

In my case, 4 items found to delete results in 25 elements deleted. I can't do the transaction roll back, so is there any suggestion as to what these addition elements would be?




______________
Yes, I'm Satoshi.
Message 9 of 9

With a bit of experimentation, I found that 4 TextNoteTypes will delete 16 elements:

4 Types

4 Graphic Styles

4 Elements

4 ???? (as shown in Snoop) - what are these?

 

So that looks safe enough. But as was pointed out, Schedules (for one example) will lose their TextNoteType and just revert to another. I gather that there is no way to determine if a TextNoteType has been used anywhere?

 

 




______________
Yes, I'm Satoshi.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community