looks like no titleblock info available at specific sheet via lookup tool, so what is the best way to:
1) find all sheets w/ specific titleblock and then
2) change (custom) type parameter in titleblock
Solved! Go to Solution.
Solved by Michel_Alofs. Go to Solution.
more specifically, i need to get OOTB Scale parameter from sheet i.e. 1 : 200, As indicated, etc, and then use that info to change custom type parameter from specific titleblock.
in short, get info from sheet then apply that info to titleblock.
you just need to implement FilteredElementCollector.OwnedByView Method, and then filter by that specific Title Block
Use the selection option of the Lookup tool to find out how to access a specific element.
A Titleblock is a Familyinstance, and you'll see it has a value for OwningViewId (see @studio-a-int comment)
The sheet itself is a view, and from it you can find out what's used as scale parameter.
You have 2 direction to go:
A. Get all Titleblocks, and then their owning view (sheet), grab the Scale value and report it back to the titleblock and change you're custom type parameter (TYPE? -> take note that the scale value is INSTANCE)
B. Get all sheets and grab all elements, OfCategory(BuiltinCategory.OST_TitleBlocks), make sure it's only 1!, and then use the sheets scale value to drive the TitleBlock Type parameter
Below a piece of code for direction A, depending needs it would be the easier of the two.
Code is not tested and will need error checking/validations
// Collect all Titleblocks
FilteredElementCollector TitleBlocks = new FilteredElementCollector(RvtDoc);
TitleBlocks.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_TitleBlocks);
// loop all titleblocks, sheets normally have only one titleblock.
foreach (Element TitleBlock in TitleBlocks)
{
// get the OwnerView of the titleblock = Sheet
// no need to cast it to a viewsheet, we only need a parameter
Element viewobj = RvtDoc.GetElement(TitleBlock.OwnerViewId);
// get the string value of the sheet's reported scale
string ScaleValue = viewobj.Parameter(BuiltInParameter.SHEET_SCALE).AsString;
// evaluate the scale value
switch (ScaleValue)
{
case "As indicated":
// Do X to TitleBlock
case "1 : 100":
// Do Y to TitleBlock
case "":
// Do Z to TitleBlock
}
}
- Michel
thanks studio-a-int, i did quick test, no titleblock from FilteredElementCollector.OwnedByView Method, perhaps i missed something?
thanks Michel, i used method B (1st sheet 2nd titleblock) which sounds more logic at first, but FilteredElementCollector.OwnedByView Method doesn't work, so method A (1st titleblock 2nd sheet) is more efficient via OwnerViewId
You can use OwnerViewId as a Where clause in the collector.
See:
revitapidocs: FilteredElementCollector Constructor
new FilteredElementCollector(RvtDoc, SheetId);
// SheetId => with this argument added the collector will only search the view's element.
// and then limit the search to titleblocks (which could be none or more than 1)
This approach is complexer than the other option.
Here you first have to gather all sheets and then all Titleblocks per sheet.
Good luck.
- Michel
Can't find what you're looking for? Ask the community or share your knowledge.