Loading rfa and accessing family instance

Loading rfa and accessing family instance

Anonymous
Not applicable
1,480 Views
5 Replies
Message 1 of 6

Loading rfa and accessing family instance

Anonymous
Not applicable

Hi all,

 

I'm using UIApplication.ActiveUIDocument.Document.LoadFamily to load an *.rfa file into a project and I'm wondering if there is a better way to access the FamilyInstance and FamilySymbol of the loaded Family rather than using a FamilyInstanceFilter and FilteredElementCollector and using a foreach to access these every time a new *.rfa file is loaded?

 

 

I know what I'm doing is inefficient, but I can't think of another way.

 

 

Cheers,

Adam

0 Likes
Accepted solutions (2)
1,481 Views
5 Replies
Replies (5)
Message 2 of 6

matthew_taylor
Advisor
Advisor
Accepted solution

Hi Adam,

If you're just wanting the symbol use loadFamilySymbol..

If you have loaded the family, and have the family object (it can be passed byref - to use vb.net terminology), you can use family.GetFamilySymbolIds.

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hello again Matthew, hope you are well!

 

Yeah I've tried LoadFamilySymbol, but that is only useful in instances where the name/type of the symbol is already known.

 

If I use GetFamilySymbolIds, would it be possible to create a separate FamilySymbol variable for each ID?

 

 

Cheers,

Adam

0 Likes
Message 4 of 6

matthew_taylor
Advisor
Advisor
Accepted solution

Hi again!

Yes all good, thanks. Hope you are also?

 

It's quite easy (once you know!):

  	Dim symbolIds As ISet(Of DB.ElementId) = family.GetFamilySymbolIds
        Dim doc As DB.Document = family.Document
         For Each id As DB.ElementId In symbolIds
            Dim element As DB.Element = doc.GetElement(id)
            Dim familySymbol As DB.FamilySymbol = TryCast(element, DB.FamilySymbol)
	    'do something with your familySymbol, or store it for later use.
	 Next

If you got an elementId some other way, you should also have to check that the familySymbol object isNot nothing - it may be another element type.

 

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 5 of 6

Anonymous
Not applicable

All good here too thanks, apart from the occasional Revit API woe!

 

Excellent, that looks easy enough.

 

Many thanks once again.

 

 

Cheers,

Adam

0 Likes
Message 6 of 6

matthew_taylor
Advisor
Advisor

No problem. Best of luck with your app!

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes