APIERR_REFUSEDCMD when delete story
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2021-03-23
12:38 PM
- last edited on
2021-09-14
09:51 AM
by
Noemi Balogh
2021-03-23
12:38 PM
API_StoryInfo storyInfo; BNZeroMemory(&storyInfo, sizeof(API_StoryInfo)); GSErrCode err = ACAPI_Environment(APIEnv_GetStorySettingsID, &storyInfo, nullptr); API_StoryType** storyType= storyInfo.data; API_StoryType* temAdress = (*storyType); //删除楼层 for (int i=storyInfo.firstStory;i<= storyInfo.lastStory; i++) { API_StoryCmdType changeType; BNZeroMemory(&changeType, sizeof(API_StoryCmdType)); changeType.action = APIStory_Delete; changeType.index = temAdress->index; changeType.dispOnSections = true; changeType.dontRebuild = true; changeType.elevation = temAdress->level; //changeType.uName = temAdress->uName; err= ACAPI_Environment(APIEnv_ChangeStorySettingsID, &changeType, nullptr); temAdress++; };I try to delete story by the code above ,but it didn‘t work , and the error code was "APIERR_REFUSEDCMD -2130312312 81060388 The passed identifier is not subject to the operation. ".I can not find why.
Labels:
- Labels:
-
Add-On (C++)
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2021-03-24 05:41 PM
2021-03-24
05:41 PM
Probably it doesn't work because you try to run a command that modifies the database, and the command is not in a command scope. Try to do it like this:
More information here (under the undo scope section):
https://archicadapi.graphisoft.com/archicad-maze-generator-add-on-tutorial-part-1
ACAPI_CallUndoableCommand ("Delete Story", [&] () -> GSErrCode { // call APIEnv_ChangeStorySettingsID here });It's your choice if you create a separate undo step for all stories, or to do the whole modification in one undo step.
More information here (under the undo scope section):