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: 

Add KeynoteTag in DraftinvView to a Line Based Detail Component

7 REPLIES 7
Reply
Message 1 of 8
atiefenbach
607 Views, 7 Replies

Add KeynoteTag in DraftinvView to a Line Based Detail Component

How can I use the API to create a new KeynoteTag hosted to a Line Based Detail Component in a DraftingView?

 

Now, keep in mind that I'm new to Revit API and C#, so my questions will be pretty basic.  My past experience is with Visual Basic. but I'm looking to improve my skills in C# and a better understanding of C#.  My best learning method is to see sample codes.  Thanks for all your help!!

 

Here's my current code to add the IndependentTag to the Element:

 

Element FindLine(Document doc)
{
FilteredElementCollector collector
= new FilteredElementCollector(doc, doc.ActiveView.Id);

foreach (Element e in collector)
{
if( e.Name.Equals("Line"))
{
return e;
}
}
return null;
}

 

Element elemLine = FindLine(doc);

LocationCurve elc = elemLine.Location as LocationCurve;
Line elLine = elc.Curve as Line;
XYZ p = elLine.get_EndPoint(0);

FamilySymbol KeynoteTagType = GetFirstFamilySymbol(doc, BuiltInCategory.OST_KeynoteTags);
IndependentTag newTag = createDoc.NewTag(view, elemLine, false, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, p);

 

I'm know this code would just tag the detail line, and I'm pretty sure the issue is the XYZ.

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
7 REPLIES 7
Message 2 of 8
Joe.Ye
in reply to: atiefenbach

What's the problem then?

 

Probably forgot to use the transaction, so it failed to create the tag.

If this cannot help, Please give detailed information abou the problem. 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 8
atiefenbach
in reply to: atiefenbach

I was using the transaction but at the begining of the routine, because I wanted 1 undo for the entire routine, not for each keynote I was adding.  I learned after playing with it more that my XYZ coordinate was coorect, but that the API won't allow you to add keynotes, unless you have sample code or documentation to support otherwise.

 

Thanks.

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 4 of 8
Joe.Ye
in reply to: atiefenbach

 

Thanks for your update.  Even via the Revit UI command, we cannot create tag for the detail line. I think this is the cause that you cannot create a tag for the detail line in the drafting view. 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 5 of 8
atiefenbach
in reply to: Joe.Ye

You seem to have trouble understanding what I'm talking about.  You're first solution suggests that it IS possible to create the keynote tag via the API, but after my next post where I asked you to provide some sample code or documentation showing it's possible, you respond with "Thanks for your update.  Even via the Revit UI command, we cannot create tag for the detail line. I think this is the cause that you cannot create a tag for the detail line in the drafting view. "  Even though my first post clearly states "Line Based Detail Component", NOT a detail line.

 

Since you seem to think it might be possible to use the Revit API to generate a keynote tag for a Line Based Detail Component I'd love to see some sample code or documentation to support that.

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 6 of 8
Joe.Ye
in reply to: atiefenbach

 

HI atiefenbach,

 

Sorry for the confusion. When I replied your firstly, I didn't write code to test if tags can be created for  Line Based Detail Component . There is no full code. So I just provide the possible reason.

 

Via the Revit UI command,  tags cannot be created for  Line Based Detail Component  either. Normally If UI commands cannot achieve a functionality, neither do the correspondant Revit API.

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 7 of 8
atiefenbach
in reply to: atiefenbach

Joe,

 

Unfortunately, you are wrong about not being able to keynote a "Line Based Detail Component" via the UI.  I think your confused about what a "Line Based Detail Component" is.  Maybe you're still thinking of a "Detail Line" or a "Repeating Detail Component"?

 

And example of a Line Based Detail Component would be the Gypsum Wallboard family that comes with Revit.

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 8 of 8
Joe.Ye
in reply to: atiefenbach


Hi atiefenbach,

 

Sorry for keeping misunderstanding. As you said, i was thinking the "Repeating Detail Component".

 

 

We can use Revit API to create a non-keynote  tag for  line based component as the UI does. (for example, the category tag, and material tag)

 

However there is no available API to change the tag type to Keynote tag type.

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network

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