cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Yeojin Hwang
Contributor

Zone Category Creation Issue in ArchiCAD C++ API

I'm trying to create a new Zone Category named "ABC" using the ArchiCAD C++ API, but I'm encountering an issue. My current code attempt results in an error, and I'm looking for some guidance to resolve it.

 

My Goal: To programmatically create a new Zone Category in ArchiCAD with the name "ABC".

Problem: When I run my code, the ACAPI_Attribute_Create function returns the error code -2130313112. I'm not entirely sure what this error signifies in this context.

 

GSErrCode CreateAbcZoneCategory() {
    API_Attribute attr = {};
    BNZeroMemory(&attr, sizeof(API_Attribute)); // Good practice for initialization

    attr.header.typeID = API_ZoneCatID; // Specifies Zone Category attribute type

    // Attempting to set the name.
    // Is 'uniStringNamePtr' the correct way to set the name for a new attribute?
    // And should it be 'new GS::UniString("abc")'?
    attr.header.uniStringNamePtr = new GS::UniString("abc");

    // Do I need to get default attributes first using ACAPI_Attribute_GetDefaults?
    // Or is there a different way to initialize a new attribute before creating it?

    return ACAPI_Attribute_Create(&attr, nullptr);
}

Could you provide a minimal working C++ code example for creating a new Zone Category named "ABC"?

 

Any help or insights would be greatly appreciated!

 

1 Solution

Accepted Solutions

Creating a zone category can be a bit tricky. The behaviour of a zone category includes displaying a stamp in 2D (for the zone) and managing any parameters that define the stamp content etc. I suspect this error is occurring because you haven't defined the zone stamp library part for the new category. You will also need to populate the default parameters for the stamp library part - this is included in the second parameter that you pass to ACAPI_Attribute_Create. The simplest approach is probably to copy the settings of an existing zone category and then adjust as required - then you can pick up the stamp and parameter details.

Ralph Wessel BArch
Central Innovation

Go to post

2 Replies 2

Creating a zone category can be a bit tricky. The behaviour of a zone category includes displaying a stamp in 2D (for the zone) and managing any parameters that define the stamp content etc. I suspect this error is occurring because you haven't defined the zone stamp library part for the new category. You will also need to populate the default parameters for the stamp library part - this is included in the second parameter that you pass to ACAPI_Attribute_Create. The simplest approach is probably to copy the settings of an existing zone category and then adjust as required - then you can pick up the stamp and parameter details.

Ralph Wessel BArch
Central Innovation
Yeojin Hwang
Contributor

Thank you so much for your insightful response! 

Your suggestion about defining the zone stamp library part and populating its default parameters was exactly what I was missing. I implemented your advice to copy the settings from an existing zone category, and it worked perfectly.

My problem is now solved! I really appreciate your help.

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!