.GetLinkDocument() returns 'None'

.GetLinkDocument() returns 'None'

adkaJK5HX
Participant Participant
490 Views
5 Replies
Message 1 of 6

.GetLinkDocument() returns 'None'

adkaJK5HX
Participant
Participant

Hello!

 

I try to get the linked document, however when Im applying GetLinkDocument() method on revit link instance it returns 'none'

adkaJK5HX_0-1716404212786.png

 

0 Likes
491 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

This looks like a typical example of a trusting human assuming and hoping that a computer will do what they think it should do, and not what they tell it to do. As far as I can see from your screen snapshot, your code looks like this:

   

81 linked_doc = link. GetLinkDocument()
82 print(link, linked doc)

  

You initialise a variable with an underscore, linked_doc.

  

Then, in the call to print, you list two separate new uninitialised variables, linked and doc.

  

They are both null, of course.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 6

adkaJK5HX
Participant
Participant

Thank you for the reply, but there is an underscore - it was just hidden under the green line I have used to highlight the variable. If I would try to print a variable that is not defined, I would get just an error.

0 Likes
Message 4 of 6

jeremy_tammik
Alumni
Alumni

Oh, sorry. One danger of posting screen snapshots instead of source code text...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 6

jeremy_tammik
Alumni
Alumni

Taking another look, I must mention that ToElements()[0] is potentially a lot more expensive than FirstElement()...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 6

jeremy_tammik
Alumni
Alumni

Sorry, I see no obvious reason for the None return.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes