Announcements
Welcome to the Revit Ideas Board! Before posting, please read the helpful tips here. Thank you for your Ideas!
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Keynote Creation via API

Keynote Creation via API

Presently, it is not possible to create or pick a new host for Keynote Tags within Revit. Keynote tags exist as an internally modified sub-type of the "IndependentTag" Class.img 1.jpg

Unfortunately, whenever attempting to create an instance of "IndependentTag" using the Keynote Tag TypeId, Revit will not allow the Key Value or Key Source to be set. In fact, if created through the IndependentTag.Create() method, the Key Value and Key Source parameters don't even exist. The parameters only seem to exist when a Keynote is created through the UI.Img 2.jpg

 

2 Comments
djohansing
Contributor

I thought we got lucky in 2019 and were given the ability to create a keynote tag with the new IndependentTag.Create override by passing in the keynote tag symbol ID, but nope ... it creates a tag without a key source, which seems useless.

 

I was however able to set the BuiltInParameter.KEY_VALUE parameter, the BuiltInParameter.KEY_SOURCE_PARAM parameter is set to read only.

 

@jeremytammik , any ideas here? 

Anonymous
Not applicable

This makes me very sad! 😞 I was trying to script a fix where a user reloaded from the wrong RVT link several days ago in a complex model, so all of the keynotes that were hosted to elements in that link (inadvisable I know) were broken. All of the elements still exist, and I can identify the relationships between keynotes and hosts in older versions of the model, but there is no way to reconcile the hosting en masse.

 

Unfortunately I don't know if there is much @jeremytammik  can do for us here. Just comes down to the source code. This is probably an oversimplification of what is needed, but if we could just set the IndependentTag.TaggedElementId.LinkedElementId property that would do it. At least I think it would for my scenario.

 

See the property below, can only get the property value.

https://www.revitapidocs.com/2018/02246788-d4e8-0d71-95dc-95301e95f1a1.htm

 

I added my code below for reference, note that it is python code and uses pyrevit functions as well. It's pretty simple what I'm trying to do actually. Make no mistake I am definitely an amateur coder, so feel free to correct me. Of course this code fails when trying to write to a read-only property. I don't see a way around it in the API either.

 

doc is of course the active document (where the unhosted keynotes are).

reference_doc is an old copy of the same model where the relationship between tag and host still exists.

I have double-checked the Element Ids and verified the linked element ids I'm trying to rehost the keynotes to exist and are the same in both models.

 

 

 

import pyrevit
from pyrevit import forms
import sys

doc = __revit__.ActiveUIDocument.Document

try:
    reference_doc = forms.select_open_docs(multiple=False)
    all_keynotes = pyrevit.revit.db.query.get_used_keynotes(doc)

    for keynote in all_keynotes:
        if keynote.IsOrphaned:
            keynote_id = keynote.Id
            reference_keynote = reference_doc.GetElement(keynote_id)
            tagged_element_id = reference_keynote.TaggedElementId
            linked_element_id = tagged_element_id.LinkedElementId
            keynote.TaggedElementId.LinkedElementId = linked_element_id
        else:
            continue
except:
    sys.exit()

 

 

The fact that we can't even create Keynote tags kinda feels like a bug since we can with other kinds of tags.

 

 Voted!

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

Submit Idea  

Technology Administrators


Autodesk Design & Make Report