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: 

what is the most efficient way to find all sheets w/ specific title block

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Ning_Zhou
954 Views, 6 Replies

what is the most efficient way to find all sheets w/ specific title block

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

6 REPLIES 6
Message 2 of 7
Ning_Zhou
in reply to: Ning_Zhou

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.

Message 3 of 7
studio-a-int
in reply to: Ning_Zhou

you just need to implement FilteredElementCollector.OwnedByView Method, and then filter by that specific Title Block

Message 4 of 7
Michel_Alofs
in reply to: studio-a-int

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)

TitleBlock.png

 

The sheet itself is a view, and from it you can find out what's used as scale parameter.

 

SheetScale.png

 

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

Message 5 of 7
Ning_Zhou
in reply to: studio-a-int

thanks studio-a-int, i did quick test, no titleblock from FilteredElementCollector.OwnedByView Method, perhaps i missed something?

Message 6 of 7
Ning_Zhou
in reply to: Michel_Alofs

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

Message 7 of 7
TripleM-Dev.net
in reply to: Ning_Zhou

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.

Post to forums  

Rail Community


Autodesk Design & Make Report