Working with BCF @ Python

Hi All,

I'm trying to get all (?) the ToDos from Trimble Connect into BCF file. The BCF API is https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.6.0/src/bcf/src/bcf/v2/bcfxml.py , the code is trivial:

todos_info = tc.get_todos(project_id = project)
 __bcf = BcfXml().new_project()
 __bcf.project.name = project_info['name']
 __bcf.author = __config['email']
 for todo in todos_info:
    topic = __bcf.add_topic(title=todo['title'], description = todo['description'], author = F"{todo['createdBy']['firstName']} {todo['createdBy']['lastName']} {todo['createdBy']['email']}")
    topic.title = todo['title']
...
    print(topic)

__bcf.edit_topic(topic)

What I get:

<bcf.v2.topic.TopicHandler object at 0x000002BB2E77F5D0>
Traceback (most recent call last):
  File "tc_to_bcf.py", line 146, in <module>
    __bcf.edit_topic(topic)

TypeError: BcfXml.edit_topic() takes 1 positional argument but 2 were given

If I can read the source code on line 224, the edit_topic() takes self and topic arguments. What I'm getting wrong ?

Tagged:

Comments

  • Ok, so my API reference is REALLY old: edit_topic() is deprecated, as well as a lot of other functions.
    Fun part: just modify the topic, the API will do the rest:
    ---
    for todo in todos_info:
    topic = __bcf.add_topic(title=todo['title'], description = todo['description'], author = F"{todo['createdBy']['firstName']} {todo['createdBy']['lastName']} {todo['createdBy']['email']}")
    topic.title = todo['title']
    ...
    topic.modified_date = todo['modifiedOn']
    topic.modified_author = F"{todo['modifiedBy']['firstName']} {todo['modifiedBy']['lastName']} {todo['modifiedBy']['email']}"
    ...
    __bcf.save_project(os.path.join(pcf.get_config_path(), output_file))
    ---

  • Ok, it seems like "Topic" object in BCF v2.1 (and v3 ?) is lacking some setters or getters.
    @Moult , will you have a look at the pull request?

  • Ok, I'm stuck again and it seems for a longer time.
    In Trimble Connect I can get the snapshot, attached to a ToDo. But neither a ToDo nor a view information is related anyway to an IfcGUID, which is needed to create a viewpoint in the BcfXml module, which is needed to save a snapshot in a BCF. From what I see in the BCF specification or examples, an IfcGUID is optional.
    Will adding an empty view direction open a can of worms?

Sign In or Register to comment.