Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi.
I'm working on a simple add-in that creates a bunch of text styles in a project or family in Revit 2013.
I'm able to only duplicate and add 1 text type and modify it's text parameters. I'm trying to figure out how to loop it based on an array count.
I want to count & loop depending the the array count for "txtHgt".
But I cannot add a variable counter to "noteType" which is a TextNoteType and this is causing the issue.
// Action Code Starts Here
Document doc = commandData.Application.ActiveUIDocument.Document;
/// Retrieve access to all TextNote Elements
FilteredElementCollector collectorUsed
= new FilteredElementCollector(doc);
ICollection<ElementId> textNotes
= collectorUsed.OfClass(typeof(TextNote))
.ToElementIds();
foreach (ElementId textNoteid in textNotes)
{
TextNote textNote = doc.GetElement(
textNoteid) as TextNote;
Transaction trans = new Transaction(doc);
trans.Start("ChangeParam");
//Setting the Variables
string txtOPR = "_";
string[] txtHgt = { "2.38mm (3/32in)", "1.98mm (5/64in)" };
string[] txtbkgd = { "Op", "Tr" };
//string txtType = (txtHgt[1] + txtOPR + txtbkgd[1]);
//int txtCount = txtHgt.Count;
int txtCount = 1;
for (int i = 0; i < txtCount; i++)
// for (int i = 0; i < list.Count; i++)
{
//string txtvar = list[i] as string;
//Element num = textNote.TextNoteType.Duplicate(txtvar);
//TextNoteType noteType4 = num as TextNoteType;
string txtType = (txtHgt[i] + txtOPR + txtbkgd[1]);
// Create a duplicate
Element ele = textNote.TextNoteType.Duplicate(txtType);
TextNoteType noteType = ele as TextNoteType;
// Change font parameter
if (null != noteType)
{
// Text Colour (only able to modify RGB Red)
byte valRed = 0; //Set colour to black
//noteType.get_Parameter("Color").Set(4);
noteType.get_Parameter("Color").Set(valRed);
// Text Line Weight 1-16
noteType.get_Parameter("Line Weight").Set(2);
}
}
trans.Commit();
}
// Return Success
Any Suggestions?
Solved! Go to Solution.
