Cannot Open .rfa File

Cannot Open .rfa File

Anonymous
Not applicable
1,315 Views
3 Replies
Message 1 of 4

Cannot Open .rfa File

Anonymous
Not applicable

Hi all,

 

I'm having some issues importing *.rfa files into a project via code.  I've created a watered down version of the code I am using below:

 

string currentDirectory = "C:/Users/spaceroppa/Documents/bim_examples/";
string fileName = "Single Window.rfa";
string fullPath = currentDirectory + fileName;

if (!File.Exists(fullPath))
{
	TaskDialog.Show("Load Bim Object", "Can't find the file " + fullPath);
}

Document rvtDoc = uiApp.ActiveUIDocument.Document;
using (Transaction t = new Transaction(rvtDoc, "Import Bim Object"))
{
	t.Start();
	bool loadSuccess = rvtDoc.LoadFamily(fullPath);
	t.Commit();
	if (loadSuccess)
	{
		TaskDialog.Show("Load Bim Object", fullPath + " successfully loaded!");
	} else
	{
		TaskDialog.Show("Load Bim Object", "Failed to load " + fullPath);
	}
}

However, I cannot get this to work correctly.  Can anybody point out what I've done wrong or provide me with a functional example?

 

 

Cheers,

Adam

0 Likes
Accepted solutions (1)
1,316 Views
3 Replies
Replies (3)
Message 2 of 4

matthew_taylor
Advisor
Advisor
Accepted solution

Try putting backslashes in your path.

If the family is already loaded in the model, that can cause issues also.


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?
Message 3 of 4

Anonymous
Not applicable

Hi Matthew,

 

Thanks for the speedy response!

 

It would appear my problem was caused because the family already existed in the test project I was working on, even though I could have sworn I deleted it before I began testing earlier..  I'll add a check to my code to see if the Family already exists before attempting import.

 

I feel like quite the fool now!  Perhaps it is time to take a break.

 

 

Thanks again,

Adam

0 Likes
Message 4 of 4

matthew_taylor
Advisor
Advisor

Hi Adam,

No problem.

 

Yes, do that. Much faster than loading anyway!

 

Glad you got it sorted.

 

-Matt

 

p.s. Don't be so hard on yourself!


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