BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Why null char[] checking not working?

Newbie
Participant

I am try to put a condition checking for empty value of char[] as below code but still not working.

 
GS::Array<API_NavigatorItem> items;
API_NavigatorItem item = {};
char str[128];
memset(str, '\0', sizeof(str));
item.guid = guid;
item.mapId = mapId; //NavigatorPaletteTestGlobals::GetInstance().GetNavigatorMapID();
GSErrCode err = ACAPI_Navigator(APINavigator_GetNavigatorChildrenItemsID, &item, nullptr, &items);
if (err != NoError)
return;
for (API_NavigatorItem& childItem : items) {
if (GS::UniString(childItem.uiId).ToCStr().Get() != NULL) {
ACAPI_WriteReport("Value >>%s<>%s =>%i", true, GS::UniString(childItem.uiId).ToCStr().Get(), GS::UniString(str).ToCStr().Get(),childItem.isIndependent);
}
}
 
Appreciated for any help to fix this issue.
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

OK now I think I've understood. And I've tested it a bit.
It seems that you can't delete items which are part of a cloned folder as you've found out.
The cloned folders have itemType = API_UndefinedNavItem.

So you could check if an items parent has this item type.

To get an items parent you can use APINavigator_GetNavigatorParentItemID.

Hope that helps!

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

View solution in original post

6 REPLIES 6

I think this condition

 

GS::UniString(childItem.uiId).ToCStr().Get() != NULL

 

will never be true, since you are creating an UniString object right there and this will have a pointer existing.

 

It's a bit unclear what exactly you want to achieve.

Maybe you need this?

 

!GS::UniString(childItem.uiId).IsEmpty()

 

 

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hello bschwb,

 

Actually I want to list the viewmap of navigator and check whether the item can be deleted or not as below picture but still can't find our the way.

Not sure you have any suggestion or not.

 

Thanks in advance.

 


Snap-2023-07-10-14-54-23.png

Which ones in the picture do you want to delete?

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hello bschwb,

 

From the given picture, if you select 'Floor Plans' then you can delete, but it's sub items such as story 1 you can't delete. I still can't find way to check whether the selected item can or can not delete from API function.

 

Thanks.

 

Solution

OK now I think I've understood. And I've tested it a bit.
It seems that you can't delete items which are part of a cloned folder as you've found out.
The cloned folders have itemType = API_UndefinedNavItem.

So you could check if an items parent has this item type.

To get an items parent you can use APINavigator_GetNavigatorParentItemID.

Hope that helps!

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hello bschwb,

 

You're right, It does what I am looking.

 

Thanks for suggestion.

 

Learn and get certified!