Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to refresh items in DropDownCommandInput in C++?

9 REPLIES 9
Reply
Message 1 of 10
amirhadi
463 Views, 9 Replies

How to refresh items in DropDownCommandInput in C++?

Hi all

How to refresh items in DropDownCommandInput in C++?

Thanks in advance

Regards

9 REPLIES 9
Message 2 of 10
amirhadi
in reply to: amirhadi

No answer??
If nobody works on C++ then where can I ask my questions?
Is there any other forum special for FUSION 360 API C++?

Message 3 of 10
amirhadi
in reply to: amirhadi

No answer??
If nobody works on C++ then where can I ask my questions?
Is there any other forum special for FUSION 360 API C++?

Message 4 of 10
marshaltu
in reply to: amirhadi

Hello,

 

Could you please explain your scenario why you need "refresh" items? 

 

There is a property "listItems" in DropDownCommandInput and you should be able to change items by it. 

 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7d435ab5-3c44-427f-8ce3-83816df1aff4

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 5 of 10
amirhadi
in reply to: amirhadi

Dear Marshal,
Thanks for your answer, the link you share was very useful but my question is still remained.
Let me explain what I want to do:
With follow code (with all prerequisite) I can create a Drop Down Menu with 3 items (Item 1, Item 2, Item 3), I want to replace them with Item 4, Item 5, Item 6, item 7.
These items are part of my data base, data base has several item groups, they are big and need to replace them several times so I can’t define DropDownCommandInput for All of Them and make visibility true/false.
Best way for me is delete menu items and load new items.
Thanks in advance
Regards A.H. Daisy




                _dropdownInput = inputs->addDropDownCommandInput("dropdown", "Dropdown", TextListDropDownStyle);
             
               
                _dropdownInput->listItems()->add("Item 1", true);
                _dropdownInput->listItems()->add("Item 2", false);
                _dropdownInput->listItems()->add("Item 3", false);
Message 6 of 10
marshaltu
in reply to: amirhadi

Hello,

 

Unfortunately there is no API to support to make item visibility true/false. As you said, you may have to clear all old items and add new ones. Or you can probably change the name of existing items. For example: change "item 1" into "item 4" by ListItem::name(const std::string& value) API.

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 7 of 10
amirhadi
in reply to: amirhadi

Hello Marshal
Special thanks
Problem solved by clear old items

Another question :

Ptr<DropDownCommandInput>dropmenu_1;
Ptr<DropDownCommandInput>dropmenu_2;
Ptr<DropDownCommandInput>dropmenu_3;
.
.
.

Can I read dropmenu_1, dropmenu_2, dropmenu_1, ... from vector or something similar?

Thanks in advance
A.H. Daisy
Message 8 of 10
marshaltu
in reply to: amirhadi

Hello,

 

If you have command object, you should be able to get those inputs by Command::commandInputs() -> CommandInputs::item() or CommandInputs::itemById().

 

Thanks,

Marshal

 

 



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 9 of 10
amirhadi
in reply to: marshaltu

Dear Mershal

Several Thanks,

It works.

Please read follow code, I use itemById there and create 3 menu, now i want to set isVisible(false) for first Menu but last one turned off, Where is my mistake?

Thanks in advance,

Regards

A.H. Daisy

 

        string MenuName;

      

        Ptr<DropDownCommandInput> _MenuName= inputs->itemById(MenuName);

        

        MenuName="Menu_1";

        _MenuName = inputs->addDropDownCommandInput(MenuName, MenuName, TextListDropDownStyle);

        if (!checkReturn(_MenuName))

            return;

        

        _MenuName->listItems()->add("Menu_1 item 1", true);

        _MenuName->listItems()->add("Menu_1 item 2", false);

        _MenuName->listItems()->add("Menu_1 item 3", false);

 

 

        MenuName="Menu_2";

        _MenuName = inputs->addDropDownCommandInput(MenuName, MenuName, TextListDropDownStyle);

        if (!checkReturn(_MenuName))

            return;

        

        _MenuName->listItems()->add("Menu_2 item 1", true);

        _MenuName->listItems()->add("Menu_2 item 2", false);

        _MenuName->listItems()->add("Menu_2 item 3", false);

        

        

        MenuName="Menu_A";

        _MenuName = inputs->addDropDownCommandInput(MenuName, MenuName, TextListDropDownStyle);

        if (!checkReturn(_MenuName))

            return;

        

        _MenuName->listItems()->add("Menu_A item 1", true);

        _MenuName->listItems()->add("Menu_A item 2", false);

        _MenuName->listItems()->add("Menu_A item 3", false);

 

        

        

        MenuName="Menu_1";

        _MenuName->isVisible(false);

 

 

Message 10 of 10
marshaltu
in reply to: amirhadi

Hello,

 

The problem was "_MenuName" was pointing to last menu you created. You may have to retrieve the first one by the following codes.

 

        MenuName="Menu_1";

        _MenuName= inputs->itemById(MenuName);

        _MenuName->isVisible(false);

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report