Load family from one project into another project

Load family from one project into another project

Joris.vd.Meulen
Collaborator Collaborator
5,020 Views
4 Replies
Message 1 of 5

Load family from one project into another project

Joris.vd.Meulen
Collaborator
Collaborator

sHi guys,

 

How to copy a whole family from a given file into another file?

 

So manually I would

- open file (A) 

- select element (let's say a detail item)

- edit family

- load into project (B) and close.

now ALL the types are loaded into project (B)

 

I tried using

 

ElementTransformUtils.CopyElements(doc, ids, targetDoc[0], None, DB.CopyPasteOptions())

 

but I get the error that it can't copy the element because it is view specific (detail item ..)

 

But I actually don't want to "copy" elements, I want them to be loaded into project instead. No need to place them.

 

How to do this?

love python coding
0 Likes
Accepted solutions (1)
5,021 Views
4 Replies
Replies (4)
Message 2 of 5

mroble
Advocate
Advocate

The alternate route you can try is to scroll down to the family in question in the Project Browser in the first file, right click on the family, save it to a location, then browse to the location is network browser, and drag and drop it into the second project.

 

You'll probably be asked to place it, but you can cancel before placement and the family will be in your project still.

 

0 Likes
Message 3 of 5

Joris.vd.Meulen
Collaborator
Collaborator

Thanks @mroble for your reply, I know how to get families into other projects doing by hand but the question is about how to doing that using the api.

 

 

love python coding
0 Likes
Message 4 of 5

franciscopossetto
Advocate
Advocate
Accepted solution

Hey,

 

I think you should use the method LoadFamily:

https://www.revitapidocs.com/2022/67277d5a-0ddf-b617-c9c9-911ecb928af9.htm

 

This is an old discussion where you can find some code to re-use:

https://forums.autodesk.com/t5/revit-api-forum/re-loadfamily-that-is-already-in-the-project-document...

 

You could get the FilePath to the Family from Project A and add then run this script on Project B. If you don´t have a path to the family, you might save it before running the process.

 

I hope it helps,

Kind regards.

Github:
https://github.com/franpossetto
0 Likes
Message 5 of 5

Joris.vd.Meulen
Collaborator
Collaborator
Yeah, good pointer.

LoadFamily works fine!
love python coding
0 Likes