Linking Revit By Python

i using Python to Link revit file but iam facing the below problem , the link is there but actually doesn’t exist as geometry in the current file.


Script:

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

Import geometry conversion extension methods

clr.ImportExtensions(Revit.GeometryConversion)

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

Import RevitAPI

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference(‘DSCoreNodes’)
import DSCore
from DSCore.List import *

import System
import sys
pyt_path= r"c:\program Files (x86)\ironPython 2.7\lib"
sys.path.append(pyt_path)

import math

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
pathName = IN[0]
path = Autodesk.Revit.DB.FilePath(pathName)

Start Transaction

TransactionManager.Instance.EnsureInTransaction(doc)

options = Autodesk.Revit.DB.RevitLinkOptions(True)
Autodesk.Revit.DB.RevitLinkType.Create(doc, path, options)
#RevitLinkLoadResult.Create(Autodesk.Revit.DB.Document,path,options)

#End the Transaction
TransactionManager.Instance.TransactionTaskDone()
doc.Regenerate()
OUT = dir(options)

@fathy.gad
I haven’t checked the entire code, and I have never added a link through the API,
but looking at it quickly seems like you have add/created a link type, but not a link instance.

Ie. you have
RevitLinkType.Create
but not
RevitLinkInstance.Create

See list line in this code sample:


And here is the doc on the RevitLinkInstance.Create
http://www.revitapidocs.com/2016/f67e43f0-c799-394c-00a8-9d60a7f70a1b.htm

thanx alot

Is there a node that exists for this…to link in another Revit model?

Hi,

If you don’t want to use the python script above, you can use the Morpheus package to link Revit models in the current file.

It’s better to create a new topic if the request is different from the original post.