possible to Pick elements of a linked Revit model and return its parameter?

possible to Pick elements of a linked Revit model and return its parameter?

glenncai
Enthusiast Enthusiast
2,589 Views
2 Replies
Message 1 of 3

possible to Pick elements of a linked Revit model and return its parameter?

glenncai
Enthusiast
Enthusiast

Try to pick a beam from a linked Revit model.

I have try this:

Reference refe = uidoc.Selection.PickObject(ObjectType.LinkedElement,"Pick a Object"); this part works

but:
Element e =doc.GetElement(refe.ElementId); element name is the link model not the beam I picked
Element e =doc.GetElement(refe.LinkedElementId); error: Object reference not set to and instance of an object.

 

also try a solution from Joe Ye:

http://adndevblog.typepad.com/aec/2014/02/how-to-get-the-picked-element-in-the-linked-model.html

still no luck

 

I tab to select the linked element and use IDs of Selection but no Id return. is it possible to get the element parameters from a link? any suggestions? Thanks

 

 

Capture.JPG

 

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

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

the linked element resides in the linked document, not in the main document.

 

You say:

"Element e =doc.GetElement(refe.ElementId); element name is the link model not the beam I picked"

 

In fact, e is a RevitLinkInstance.

 

So you find the linked document this way:

Document linkedDoc = (e as RevitLinkInstance).GetLinkDocument();

 

And the linked element:

Element eLinked =linkedDoc.GetElement(refe.LinkedElementId);

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 3

glenncai
Enthusiast
Enthusiast

Works like a charm, Thanks

0 Likes