BIM 360 - GastonBC/adeskForgeWrapper GitHub Wiki

Guides for afw's BIM 360 module - afw.b360

Retrieve all projects in the your Hub

projs = afw.b360.Project.get_projects(token)

# Print some properties
for p in projs:
    print(p.name)
    print(p.id)

Get project by ID

project = afw.b360.Project.project_by_id(token, "PROJECT_ID")

Get all users in the project

users = project.get_users(token)

Get companies in your hub

comps = afw.b360.Company.get_companies(token)
# Again, you can print their properties
for company in comps:
    print(company.name)
    print(company.id)
    print(company.country)

The Options class:

Some methods require particular options in order to perform the request, these options are ordered in each module in an "Options" class. The name of the options method is the same name with Options at the end.

Eg: For the afw.b360.Project.update_project(token, options) method, the options method is afw.b360.Project.update_project_options(token, options). Don't worry, examples below.

Create a project

# Get a token
cli = afw.client.Client(
    forge_client_id, forge_client_secret, bim_account_id, bim_account_name)
token = afw.client.Token.get_2_legged_token("account:write", cli)


# Our Options class organizes parameters and makes sure there are no mandatory fields empty
ops = afw.b360.Options.create_project_options(
    "NewAfwProject", "2020-06-05", "2021-06-05", "Commercial", 3000, "USD)

# Then we just create our project
project = afw.b360.Project.create_project(token, ops)

print(project.name, project.id)

Update a project

# Get your project, we need multiple scopes for this
# notice the scopes separated by a space
cli = afw.client.Client(
    forge_client_id, forge_client_secret, bim_account_id, bim_account_name)

token = afw.client.Token.get_2_legged_token("account:read account:write", cli)

proj = afw.b360.Project.project_by_id(token, "YOUR_PROJECT_ID")

# The Options class in each module makes it easy to send the needed data/parameters
# Ensures its format and fields

ops = afw.b360.Options.update_project_options(
    name="AFWProject", status="active", end_date="2021-04-30")

updated_project= proj.update_project(token, ops)

print(updated_project.name)
print(updated_project.status)
print(updated_project.end_date)