Request

Response

    Add Property Definition to Collection

    This topic provides instructions on how to add a property definition to a property definition collection. Property definitions allow you to add custom data to your Fusion designs.

    You will use the following query in this topic:

    TypeOperationDescription
    mutation CreatePropertyDefinition A property definition is an object that acts as a template to create properties on component or componentVersion.

    Step 1 - Create a Property Definition

    The following steps demonstrate how you can run the CreatePropertyDefinition query to add a property definition to a property definition collection.

    1. Enter the following query in the Query Pane of the Manufacturing Data Model Explorer.

      Query

      mutation CreateDynamicAtVersionPropertyDefinition($input: CreatePropertyDefinitionInput!) {
          createPropertyDefinition(input: $input) {
              propertyDefinition {
                  id
                  name
                  specification
                  isHidden
                  isReadOnly
                  shouldCopy
                  isArchived
                  description
                  propertyBehavior
                  units {
                      id
                      name
                  }
              }
          }
      }
      
      Show More

    Note: The shouldCopy field dictates how this property behaves when the primary Autodesk Fusion file is saved using the “Save As” or “Copy” options. When you set shouldCopy to true, the property will be copied over to the newly saved file. When set to false, the newly saved file will not contain the property. By default, the shouldCopy is set to false.

    1. In the Query Variables Pane, enter the following query and values:

      • name: Add a preferred name. For this example, we are using "material length" as name.
      • propertyDefinitionCollectionId: Enter the propertyDefinitionCollectionId. To know how to obtain propertyDefinitionCollectionId, refer to Create Property Definition Collection topic.
      • specification: Add a preferred property specification. To know the supported data types for property definition specification, refer to CreatePropertyDefinitionInput page.
      • description: Enter the description of the property.
      • propertyBehavior: Set the propertyBehavior to STANDARD. Several other Property Behaviors are also supported. For more details, refer to PropertyBehaviorEnum.
      • shouldCopy: Set the shouldCopy as true.

        Note: To prevent error responses, do not use names of the existing collections.

      Query Variables

       {
          "input": {
             "name": "material length",
             "propertyDefinitionCollectionId": "cHJvcGRlZmNvbH5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn50ZXN0Y29sbGVjdGlvbjE",
             "specification": "STRING",
             "description": "description of this property",
             "propertyBehavior": "STANDARD",
             "shouldCopy": true
           }
      }
      
      Show More

    1. Click Play. The response will display the updated description of the property definition collection.

      Response

      {
      "data": {
          "createPropertyDefinition": {
              "propertyDefinition": {
                  "id": "cHJvcGRlZn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5wcm9wX2RlZl9jb2xfMTcxNzMxNzM1NjEzM35wYXJhbWV0ZXJzLkNmWG9hQzRLNTNTVHdiNlRuSXJYWFpUQUlFZGRHOUFyOjU0NGZmYWMwNGYzZjQ3MjY4NGUzMzVkYmUwNzA5ZjkzLTEuMC4w",
                  "name": "material length",
                  "specification": "FLOAT",
                  "isHidden": false,
                  "isReadOnly": false,
                  "shouldCopy": true,
                  "isArchived": false,
                  "description": "description",
                  "propertyBehavior": "STANDARD",
                  "units": null
                  }
                 }
                }
               }
      
      Show More

    Step 2 - Verify the Added Property Definition

    When you use the propertyDefinition query, it retrieves the details of a property definition. This information can help you understand which property elements are mapped to the property definition. After running the query, it returns a propertyDefinition object that provides all the details of the property definition. This includes information such as the behavior of the property, the collection to which it’s mapped, and the units of the property.

    1. Enter the following query in the Query Pane of the Manufacturing Data Model Explorer.

      Query

      query hub($hubId: ID!, $collectionId: ID!, $ids: [ID!]!) {
              hub(hubId: $hubId) {
                  id
                  name
                  propertyDefinitionCollections(filter: { id: [$collectionId] }) {
                      results {
                          id
                          name
                          description
                          definitions(filter: { ids: $ids }) {
                              results {
                                  id
                                  name
                                  isHidden
                                  isReadOnly
                                  isArchived
                                  shouldCopy
                                  description
                                  specification
                                  propertyBehavior
                                  units {
                                      id
                                      name
                                  }
                              }
                          }
                      }
                  }
              }
          }
      
      Show More

    2. In the Query Variables Pane, enter the following query and values:

      • hubId: Enter the value of the hubId. To know how to obtain the hubId, refer to Retrieve Hubs.
      • collectionId: Enter the value of the collectionId (propertyDefinitionCollectionId). To know how to obtain propertyDefinitionCollectionId, refer to Create Property Definition Collection topic.
      • propertyDefinitionId: Enter the ID of the propertyDefinition obtained in the “Step 1” of this topic.

        Note: You can add multiple propertyDefinitionId values for a collectionId in the ids field to retrieve details of multiple property definitions. But you cannot add multiple collectionId values in the collectionId field.

      Query Variables

      {
          "hubId": "a.YnVzaW5lc3M6YXV0b2Rlc2syMzk4",
          "collectionId": "cHJvcGRlZmNvbH5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5URVNUX0NQX0RPQw",
          "ids": ["cHJvcGRlZn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5URVNUX0NQX0RPQ35wYXJhbWV0ZXJzLkNmWG9hQzRLNTNTVHdiNlRuSXJYWFpUQUlFZGRHOUFyOmY4Mzg3MjNiOGQ1MjRjMmFhMzZkNjg3MzU5OWI0YjVhLTEuMC4w"]
      }
      

    1. Click Play. The response you will receive includes details about a propertyDefinitionId and its mapping to the propertyDefinitionCollection field.

      Response

      {
      "data": {
          "hub": {
          "id": "a.YnVzaW5lc3M6YXV0b2Rlc2syMzk4",
          "name": "stg-hds-test-hub",
          "propertyDefinitionCollections": {
              "results": [
              {
                  "id": "cHJvcGRlZmNvbH5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5URVNUX0NQX0RPQw",
                  "name": "TEST_CP_DOC",
                  "description": "collection description",
                  "definitions": {
                  "results": [
                      {
                      "id": "cHJvcGRlZn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5URVNUX0NQX0RPQ35wYXJhbWV0ZXJzLkNmWG9hQzRLNTNTVHdiNlRuSXJYWFpUQUlFZGRHOUFyOmY4Mzg3MjNiOGQ1MjRjMmFhMzZkNjg3MzU5OWI0YjVhLTEuMC4w",
                      "name": "material length",
                      "isHidden": false,
                      "isReadOnly": false,
                      "isArchived": false,
                      "shouldCopy": true,
                      "description": "description",
                      "specification": "FLOAT",
                      "propertyBehavior": "STANDARD",
                      "units": null
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      }
      
      Show More

      Note: You can create multiple properties using the CreatePropertyDefinitions mutation. For more information, see Create Property Definitions.