selecting items in linked model

selecting items in linked model

james.levieux
Advocate Advocate
2,259 Views
2 Replies
Message 1 of 3

selecting items in linked model

james.levieux
Advocate
Advocate

After items in a linked model the UIdocument.Selection.GetElementIds() yeilds nothing.  As a work-around, I've toyed with UIdocument.Selection.PickObjects() which does return an IList<Reference> which is an improvement!

 

I want to be able to hide some linked elements depending on their properties.  The problem is that I can't figure out how to access the elements using the Reference objects I've acquired.  What is the purpose of the CreateLinkReference  method and how can I acquire the RevitLinkedInstance object to use it?  I feel like I'm stabbing blindly into the dark.

 

Can anyone explain how to use these reference objects?

 

James

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

smarente1
Enthusiast
Enthusiast
Accepted solution

Here is an example of selecting a linked element: 

#Current document
doc = revit.doc
uidoc = revit.uidoc
#Collect the linked instances, grab the first instance in the list
linked_instance = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()[0]
# Get linked document from instance
linked_doc = linked_instance.GetLinkDocument()
#Ask User to select linked element
linked_reference = uidoc.Selection.PickObject(ObjectType.LinkedElement, "Pick Linked Element")
#Get Linked element from linked document
linked_element = linked_doc.GetElement(linked_reference.LinkedElementId)
#Hide or do something with element ... 

 

 

Message 3 of 3

james.levieux
Advocate
Advocate

That does the trick. Thank you! Disappointed to find that I can't hide the element once I've acquired it!

 

https://forums.autodesk.com/t5/revit-ideas/hide-elements-in-linked-model/idi-p/10780414

 

Regards, 

James

0 Likes