1

当宿主放置在链接文档中时,familyInstance 的宿主属性会返回 RevitLinkInstance。我有办法获取真正的元素(或其 ID)而不是 RevitLinkInstance 吗?

我希望 stableREpresentation 可以给我更多信息,但不幸的是,它没有。

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

这将给出"ac669fa6-4686-4f47-b1d0-5d7de6a40550-000a6a4a:0:RVTLINK:234297:0:218"234297 是引用元素的 ID,在这种情况下,仍然是 RevitLinkInstance。

4

2 回答 2

0

根据主机的不同,您可能需要采取几种方式。例如,对于一面墙,您可以尝试以下操作(顺便说一下,这是使用 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 方法来获取您的项目。

于 2015-02-09T15:07:13.903 回答
0

你试过这个吗?

ElementId hostFaceReferenceId = instance.HostFace.LinkedElementId;

然后,您可以尝试通过linkedDocument 获取元素。

文档 LinkedDoc = RevitLinkInstance01.GetLinkDocument();

元素linkedEl = LinkedDoc.GetElement(hostFaceReferenceId);

于 2014-08-21T04:03:45.030 回答