Request

Response

    Add Property Definitions 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 operation in this topic:

    TypeOperationDescription
    Mutation CreatePropertyDefinitions Creates multiple property definitions in a property definition collection.

    Step 1 - Create a Property Definition

    The following steps demonstrate how you can run the CreatePropertyDefinitions 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.
      • 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": {
            "propertyDefinitionCollectionId": "cHJvcGRlZmNvbH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5wcm9wX2RlZl9jb2xfMTc0NjE4ODM3NDgzMA",
            "propertyDefinitionsInput": [
               {
                  "name": "Background Color 1746539412451",
                  "specification": "STRING",
                  "propertyBehavior": "STANDARD",
                  "description": "bg color",
                  "isHidden": false
               },
               {
                  "name": "Border Color 1746539412451",
                  "specification": "STRING",
                  "propertyBehavior": "STANDARD",
                  "description": "border color",
                  "isReadOnly": false
               }
            ]
         }
      }
      
      Show More

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

      Response

      {
         "data": {
            "createPropertyDefinitions": {
               "propertyDefinitions": [
                  {
                     "id": "cHJvcGRlZn5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5wcm9wX2RlZl9jb2xfMTc0NjE4ODM3NDgzMH5wYXJhbWV0ZXJzLkFDTjRFdmRITE1UWml3N25ma0hVcFBqc0E0VmZaYW5UOmQ4MDM2YTkzNzNlNjQyMzlhZWM1NDBlOWFhNWJjOGZjLTEuMC4w",
                     "name": "Background Color 1746539412451",
                     "propertyBehavior": "STANDARD",
                     "specification": "STRING",
                     "description": "bg color",
                     "isHidden": false,
                     "isArchived": false,
                     "units": null
                  },
                  {
                     "id": "cHJvcGRlZn5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5wcm9wX2RlZl9jb2xfMTc0NjE4ODM3NDgzMH5wYXJhbWV0ZXJzLkFDTjRFdmRITE1UWml3N25ma0hVcFBqc0E0VmZaYW5UOmUyNzEyZjFkNTRjNTQ3YzM4ZmEyZDA2MGQ2ZTgyMGYyLTEuMC4w",
                     "name": "Border Color 1746539412451",
                     "propertyBehavior": "STANDARD",
                     "specification": "STRING",
                     "description": "border color",
                     "isHidden": false,
                     "isArchived": false,
                     "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

    1. 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.