Jump to content

Project keyword definition, list type


---
 Share

Recommended Posts

Hi,

is there a way to define a custom list keyword type in the SW2023 in the json file? I would like to offer the user more options for a keyword but do not want to allow free string in that field. For example nest of the injected part could be just only: A, B or C (no other choices).

I mean a json like this (but it does not work so):

{
    "content": {
        "": [
            {
                "description": "Nest",
                "key": "nest",
                "type": "list",
                "value": ["A", "B", "C"]
            },
...

Thanks!

Edited
Link to comment
Share on other sites

I dont think you can make project keywords anything other than a string, date, or number. 

image.png.34aa98ca948d924c59bc0d21914b217b.png

you could present the user with a dialog, and feed the result of that dialog into a project keyword? 
 

  • Like! 1
Link to comment
Share on other sites

Yes, but for that I have to do some Python exercises. At the moment I am not very practiced in that. But it seems that I have to get familiar with it... 🙂

Thank you!

Link to comment
Share on other sites

  • 1 month later...

Yes you can, you just need to use the proper variables (Items).

diag={
    "content": [
        [
            {
                "columns": 1,
                "default": "A",
                "items": [
                    {
                        "id": "",
                        "text": "A",
                        "translatable": True
                    },
                    {
                        "id": "",
                        "text": "B",
                        "translatable": True
                    }

                ],
                "name": "list",
                "rows": 1,
                "tooltip": {
                    "id": "",
                    "text": "",
                    "translatable": True
                },
                "type": "input::list"
            }
        ]...
.... 

I wrote out a taught script to a json file, edited it Notepad++, read it back in, and it worked fine.

 

Link to comment
Share on other sites

Also, if you have a dialog defined with a list named "partlist" once the dialog is loaded you can add a list of items.

part_list = ['nut','bolt','washer','lock washer']

DIALOG.partlist.items = part_list

 

Link to comment
Share on other sites

Hi

Please sign in to view this username.

,

thank you for your answer. It is not clear for me but is this solution relates to the keyword set in the add-on environment (see attached pic, red marking)? I ask because the structure of your file looks a bit different and I do not know how to implement it in the keyword set JSON. My text starts with "content" and your descriptiopn is with "diag".

Névtelen.png

Link to comment
Share on other sites

 Share

×
×
  • Create New...