[英]Cast .Net object to another .Net object in IronPython, Dynamo
Reference ref = new Reference(wall as Element);
Reference ref = new Reference(wall as Element);
ref = Reference(wall)
in python gives an exception that the reference cannot be used ref = Reference(wall)
在python中给出了一个不能使用引用的异常Can one cast a .Net object to its parent object in python (iron python)?可以在 python (iron python) 中将 .Net 对象转换为它的父对象吗? I am trying to bandage up someone's dynamo/python script and that one object is mucking it up
我试图包扎某人的发电机/python 脚本,而那个对象正在把它搞砸
In C#, if wall
is of class Wall
and that inherits from Element
, there is no need to cast wall
to Element
.在 C# 中,如果
wall
属于Wall
类并且继承自Element
,则无需将wall
为Element
。 You can just use wall
as is.您可以按原样使用
wall
。 It is already a Wall
and therefore also an Element
.它已经是一个
Wall
,因此也是一个Element
。 I would assume the same applies in Python.我认为这同样适用于 Python。 I suggest you post a code snippet for better understanding.
我建议您发布代码片段以更好地理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.