【发布时间】:2022-01-16 12:54:06
【问题描述】:
我正在尝试使用函数 init 创建一个新实体。 但我不知道我应该给什么“e”。 “e”必须是一个元组。但是我怎么知道它长什么样呢?
class entity_instance(object):
def __init__(self, e):
if isinstance(e, tuple):
e = ifcopenshell_wrapper.new_IfcBaseClass(*e)
super(entity_instance, self).__setattr__('wrapped_data', e)
这里是函数 new_IfcBaseClass:
def new_IfcBaseClass(schema_identifier, name):
"""new_IfcBaseClass(std::string const & schema_identifier, std::string const & name) -> entity_instance"""
return _ifcopenshell_wrapper.new_IfcBaseClass(schema_identifier, name)
这是我的主要代码:
import ifcopenshell
from ifcopenshell import entity_instance
ifc=ifcopenshell.open('file.ifc')
Object = entity_instance()
entity_instance.__init__(('#1','ifctoken'))
我给了一个随机元组来测试,我是否可以构建一个新的 entify_instance。但我得到“init() missing 1 required positional argument: 'e'”作为错误消息。
【问题讨论】:
-
当你试图传递一个元组时出现了什么问题?
-
那么,
ifcopenshell_wrapper.new_IfcBaseClass来自哪里?您是否尝试过阅读文档?我们无法告诉您有关此代码的任何信息,因为您没有向我们展示,我们也无法知道它的来源。 -
您似乎尝试过ask this question before。之前不清楚你想做什么,现在更不清楚了。
-
@mkrieger 我尝试使用随机元组。我得到“__init__() missing 1 required positional argument: 'e'” 作为错误
-
请显示您尝试过的代码的minimal reproducible example。