python 3 for Revit 2022:TypeError:必须通过类insctance访问实例属性
我正在将 python 2.7 脚本转换为 python 3。该脚本在 Dynamo for Revit 2022 中使用。 在 2.7 中,代码可以工作,但在 python 3 中,它给出了类型错误:实例属性必须通过类实例访问。谁能帮忙解决这个问题吗?
def Typenaam_Family(itm):
Typenaam = []
Collector_Element_And_Typename = []
Bcat = itm[0]
Dict_Element_And_Typename = itm[1]
Collector = FilteredElementCollector(doc).OfCategory(Bcat).WhereElementIsElementType().ToElements()
for itm in Collector:
Typenaam.append(Element.Name.GetValue(itm))
Collector_Element_And_Typename.extend(list(zip(Typenaam,Collector)))
for itm in Collector_Element_And_Typename:
Dict_Element_And_Typename[itm[0]] = itm[1]
Benodigde_Categorys = [[BuiltInCategory.OST_Doors,Dict_Door_Element_And_Typename],[BuiltInCategory.OST_PlumbingFixtures,Dict_Plumbing_Element_And_Typename],[BuiltInCategory.OST_Walls,Dict_Wall_Element_And_Typename],[BuiltInCategory.OST_Floors,Dict_Floor_Element_And_Typename],[BuiltInCategory.OST_StructuralColumns,Dict_Kolommen_Liggers_Element_And_Typename],[BuiltInCategory.OST_StructuralFraming,Dict_Kolommen_Liggers_Element_And_Typename]]
for itm in Benodigde_Categorys:
Typenaam_Family(itm)
我尝试
___get___
代替 .GetValue 但没有解决。
I`m converting a python 2.7 script to python 3. The script is used in Dynamo for Revit 2022.
In 2.7 the code works but in python 3 it gives a typeerror: instance property must be accessed through a class insctance. Can anyone help with this?
def Typenaam_Family(itm):
Typenaam = []
Collector_Element_And_Typename = []
Bcat = itm[0]
Dict_Element_And_Typename = itm[1]
Collector = FilteredElementCollector(doc).OfCategory(Bcat).WhereElementIsElementType().ToElements()
for itm in Collector:
Typenaam.append(Element.Name.GetValue(itm))
Collector_Element_And_Typename.extend(list(zip(Typenaam,Collector)))
for itm in Collector_Element_And_Typename:
Dict_Element_And_Typename[itm[0]] = itm[1]
Benodigde_Categorys = [[BuiltInCategory.OST_Doors,Dict_Door_Element_And_Typename],[BuiltInCategory.OST_PlumbingFixtures,Dict_Plumbing_Element_And_Typename],[BuiltInCategory.OST_Walls,Dict_Wall_Element_And_Typename],[BuiltInCategory.OST_Floors,Dict_Floor_Element_And_Typename],[BuiltInCategory.OST_StructuralColumns,Dict_Kolommen_Liggers_Element_And_Typename],[BuiltInCategory.OST_StructuralFraming,Dict_Kolommen_Liggers_Element_And_Typename]]
for itm in Benodigde_Categorys:
Typenaam_Family(itm)
I tried
___get___
instead of .GetValue but that didn`t solve.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其更改
为:
理论上它应该作为
itm.Name
工作,但随后会引发 interperer 无法读取值的错误。itm.Name
在 RevitPythonShell 中工作,但 Dynamo 使用itm.get_Name()
。我不知道他们为什么要这样做,但可能是由于 .NET 兼容性。仅在 Revit 2023.1/Dynamo 2.16.1 上测试
Change this:
to this:
In theory it should work as
itm.Name
, but then it raise error that interperer can't read value.itm.Name
works in RevitPythonShell, but Dynamo has it'sitm.get_Name()
. I have no idea why they did such implementation, but probably due to .NET compability.Tested only on Revit 2023.1/Dynamo 2.16.1