We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

Adding new navigator item [SOLVED TEMPORARILY]

ReignBough
Enthusiast
I am trying to add a navigator item using ACAPI_Environment(APIEnv_NewNavigatorViewID, ...). I followed the sample code on the documentation and just modify the parent_child values to the first child (index 0) of navigation set (index 1), but unable to do so.

Here is my code
if (navi_map_id == API_PublicViewMap && j == 0)
{
  API_NavigatorItem navi_item;
  navi_item.mapId = API_PublicViewMap;
  navi_item.itemType = API_UndefinedNavItem;
  //navi_item.itemType = API_FolderNavItem;
  sprintf(navi_item.name, "sample navi item");

  // sets the navigator view to default values
  API_NavigatorView navi_view;
  BNZeroMemory(&navi_view, sizeof(API_NavigatorView));

  GS::Guid parent_child[2];
  parent_child[0] = APIGuid2GSGuid((*items).guid);
  parent_child[1] = APIGuid2GSGuid(set.guid);

  err = ACAPI_Environment(APIEnv_NewNavigatorViewID, &navi_item, &navi_view, &parent_child);
  if (err != NoError)
  {
    DBPrintf("ERROR@%d: ACAPI_Environment(APIEnv_NewNavigatorViewID) error 0x%08X [%s]",
      __LINE__ - 4, err, ErrID_To_Name(err));
    continue;
    //return err;
  }
  DBPrintf("Successfully added \"%s\".", navi_item.name);
}
This codes loops to each child of navigator set.

This is the error that I got.
ERROR@xxx: ACAPI_Environment(APIEnv_NewNavigatorViewID) error 0x81060065 [APIERR_BADID]
If I use the API_FolderNavItem and NULL instead of &navi_view, I am able to add it. But other than that, I failed. Is there a rule set for each type, like this type (API_NavigatorItemTypeID) can only be used on this map (API_NavigatorMapID)?


EDIT

I found out that you need to get and save an existing item by using APIEnv_GetNavigatorItemID as a new API_NavigatorItem. Then use it together with an API_NavigatorView on APIEnv_NewNavigatorViewID.
API_NavigatorItem navi_item;
BNZeroMemory(&navi_item, sizeof(API_NavigatorItem));
navi_item.mapId = API_ProjectMap;
ACAPI_Environment(APIEnv_GetNavigatorItemID, &some_guid, &navi_item);

API_NavigatorView navi_view;
BNZeroMemory(&navi_view, sizeof(API_NavigatorView));
//... add navi_view settings here

GS::Guid parent_child[2];
//... parent_child guids here

ACAPI_Environment(APIEnv_NewNavigatorViewID, &navi_item, &navi_view, &parent_child);
Now that I can create it, the problem is I can't add it on a folder. I first tried to create a folder within a folder to see if it is possible to add an item (API_FolderNavItem in this case) within a folder and I am able to do so. I was able to create up to 3 subfolders (if written as a folder path: folder/subfolder1/subfolder2/subfolder3). But not on other item (I used API_StoryNavItem in this case).

EDIT 2

Is this the correct parent_child relationship?
:
|-- parent_item_guid
| |-- <APINULLGuid>
| |-- child_item_guid
| |-- *<-- new item here
: :
| '-- last_child_item_guid
:
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
2 REPLIES 2
ReignBough
Enthusiast
I think this is some kind of a bug.

When ACAPI_Environment(APIEnv_NewNavigatorViewID) is called with the parentAndChildGuids argument, it is supposed to put the view on that location.

But I found a hack on this. After creating the said view, I just used ACAPI_Environment(APIEnv_SetNavigatorItemPositionID) to change the location of the newly created view to the parentAndChildGuids location. It took me a while to figure this out since APIEnv_SetNavigatorItemPositionID is not in the list of a API_EnvironmentID on ACAPI_Environment documentation.

Hope this helps.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi,

Thanks for pointing out this issue!
We are working on this, trying to make easier to add new navigator item.
I'll fix it in the documentation also.

Regards,
Tibor

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!