Design: Adding, Editing and Deleting Component Parameters

Modified on Fri, 20 Oct 2023 at 09:30 AM

This example assumes you are part of at least one workspace in Altium 365.


Using the Design scope of the Nexar API, we can update, add or delete the parameters of components in a PCB.


First, you need to query for your Workspace. 


QUERY YOUR WORKSPACE

query Workspaces {
  desWorkspaces {
    url
    id
    name
    description
    projects {
      id
      name
    }
  }
}


Running the query above should return a response similar to the one below. The data returned in your response will differ based on your workspace, and the projects within them. Copy and paste the URL in the response. In this example, this URL is:

https://altium-inc-123.365.altium.com/


QUERY YOUR WORKSPACES: RESPONSE

{
  "data": {
    "desWorkspaces": [
      {
        "url": "https://altium-inc-123.365.altium.com/",
        "id": "RGVz...",
        "name": "Test",
        "description": "Shared workspace for development and testing",
        "projects": [
          {
            "id": "RGVz...,
            "name": "Sample - PCB"
          }...
        ]
      }
    ]
  },
  "extensions": {
    "requestId": "47456fa8-33af-478b-b784-3408dfb401e2"
  }
}

Paste that URL after "workspaceUrl:" into this next query:


QUERY YOUR LIBRARY

query library {
  desLibrary(workspaceUrl: "https://altium-inc-123.365.altium.com/") {
    components {
      nodes {
        id
        name
        details {
          parameters {
            type
            name
            value
          }
        }
      }
    }
  }
}


This will return the components, and their IDs along with details (e.g. parameters). Copy the value in "id". In this response, that is the value, "RGVzQ29tc..."

QUERY YOUR LIBRARY: RESPONSE

{
  "data": {
    "desLibrary": {
      "components": {
        "nodes": [
          {
            "id": "RGVzQ29tc...",
            "name": "CMP-00000",
            "details": {
              "parameters": [
                {
                  "type": "TEXT",
                  "name": "Test",
                  "value": "123"
                }
              ]
            }
          }
        ]
      }
    }
  }
  "extensions": {
    "requestId": "fff0e457-21f4-484f-8b8c-ce7ab77547f9"
  }
}


Paste that ID into the mutation. Mutations allow you to change data - in this case, a component's parameters. With this mutation, you can:

Add a parameter

by providing a new parameter name and value, you can add a parameter to this component


Editing a parameter

by providing the existing parameter name and a new value, you can change the value of this component. Note that if you enter an empty string "", the parameter will still exist and can be called via the API, but it may not be visible in Altium 365.


Deleting a parameter

by setting the field "replaceExisting: true", you will delete all existing parameters for this component. Note that there is currently no way of deleting a single parameter with a mutation, but can add your desired parameters back programmatically. 


Note: By mutating your component parameters, your componentId will also change as this is linked to the component revision.

MUTATION OF COMPONENT PARAMETERS

mutation updateComponentParams {
  desUpdateComponentRevisionParameters(
    input: {
      componentId: "RGVzQ29tc..."
      releaseNote: "Change parameter Test value to abc. Add parameter 
               Test2 with value 123"
      replaceExisting: false
      parameters: [
        { name: "Test", value: "abc" }
        { name: "Test2", value: "123" }
      ]
    }
  ) {
    componentId
  }
}



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article