Autodesk Revit Architecture 2014 .NET API C # найти хост для FamilyInstance по ссылке

Свойство хоста familyInstance возвращает RevitLinkInstance, когда хост помещается в связанный документ. Есть ли способ получить реальный элемент (или его идентификатор) вместо RevitLinkInstance?

Я надеялся, что стабильная презентация может дать мне больше информации, но, к сожалению, это не так.

Reference hostFaceReference = instance.HostFace;
string stableRepresentation = hostFaceReference.ConvertToStableRepresentation(instance.Document);

это даст "ac669fa6-4686-4f47-b1d0-5d7de6a40550-000a6a4a:0:RVTLINK:234297:0:218", где 234297 - это идентификатор элемента, на который указывает ссылка, в данном случае это все еще RevitLinkInstance.


person KenGey    schedule 11.08.2014    source источник


Ответы (2)


Вы пробовали это?

ElementId hostFaceReferenceId = instance.HostFace.LinkedElementId;

Затем вы можете попробовать получить элемент через связанный документ.

Документ LinkedDoc = RevitLinkInstance01.GetLinkDocument ();

Элемент connectedEl = LinkedDoc.GetElement (hostFaceReferenceId);

person mtumminello    schedule 21.08.2014
comment
За исключением того, что GetLinkedDocument () всегда возвращает nill (в моем случае, не знаю почему), это работает. - person KenGey; 27.08.2014

В зависимости от хоста вам, возможно, придется сделать это несколькими способами. Например, со стеной вы можете попробовать следующее (кстати, с использованием LINQ):

// filter the Host's document's items
FilteredElementCollector linkdocfec = new FilteredElementCollector(elem_inst.Host.Document);

// establish the host's type
linkdocfec.OfClass(elem_inst.Host.GetType());

// find the host in the list by comparing the UNIQUEIDS
Element hostwallinlinkedfile = (from posshost in linkdocfec
                                where posshost.UniqueId.ToString().Equals(elem_inst.Host.UniqueId.ToString())
                                select posshost).First();

// check the different faces of the host (wall in this case) and select the exterior one
Reference linkrefface = HostObjectUtils.GetSideFaces((hostwallinlinkedfile as HostObject), ShellLayerType.Exterior).First<Reference>();
// create a reference to the linked face in the the CURRENT document (not the linked document)
Reference linkref = linkrefface.CreateLinkReference(rvtlink_other);

В конечном итоге, согласно документации, вы должны использовать метод CreateReferenceInLink для получения вашего элемента.

person prestonsmith    schedule 09.02.2015