【问题标题】:Get Revit Link Instance using Python使用 Python 获取 Revit 链接实例
【发布时间】:2022-10-23 23:35:18
【问题描述】:

我是 Revit API 的新手。我可以使用 C# 和下面的代码获取 Revit 链接实例。

Element e = doc.GetElement(r);

if (e is RevitLinkInstance)
{
    //Get revit link instance
    RevitLinkInstance linkInstance = e as RevitLinkInstance;
    LinkedDocument = linkInstance.GetLinkDocument();

    //Do something
}

如何使用 python 获取 LinkInstance。 到目前为止我所尝试的。

 element = doc.GetElement(ref)

 if element is RevitLinkInstance:
    linkInstance = #need to get link instance here#
    linked_document = linkInstance.GetLinkDocument()

将不胜感激帮助。

【问题讨论】:

    标签: python revit-api revitpythonshell


    【解决方案1】:

    您的 C# 示例语句 e as RevitLinkInstance 执行 .NET 强制转换。因此,您可以通过在 Internet 上搜索 .net cast python 来回答这个问题,例如,引导到问题和回答 can you typecast a .NET object in IronPython? 那里给出的建议是使用

    import clr
    convertedObject = clr.Convert(someObject, someType)
    

    【讨论】:

      猜你喜欢
      • 2021-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多