1

Im new to the Revit API. I can get the Revit link instance using C# with the code below.

Element e = doc.GetElement(r);

if (e is RevitLinkInstance)
{
    //Get revit link instance
    RevitLinkInstance linkInstance = e as RevitLinkInstance;
    LinkedDocument = linkInstance.GetLinkDocument();

    //Do something
}

How do i get the LinkInstance using python. What i have tried so far.

 element = doc.GetElement(ref)

 if element is RevitLinkInstance:
    linkInstance = #need to get link instance here#
    linked_document = linkInstance.GetLinkDocument()

Would appreciate the help.

1 Answer 1

2

Your C# sample statement e as RevitLinkInstance performs a .NET cast. Hence, you can answer this question by searching the Internet for .net cast python, leading, e.g., to the question and answer can you typecast a .NET object in IronPython? The suggestion given there is to use

import clr
convertedObject = clr.Convert(someObject, someType)
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Jeremy That worked perfectly. linkInstance = clr.Convert(element, type(element))
Thank you for your appreciation. Please up-vote the answer, then. Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.