2024-05-27 09:37 AM - last edited on 2024-05-28 01:53 AM by Laszlo Nagy
I'm using the code in the SDK example and tried to create a section and switch to the newly created section window. The result is that the section is successfully created, but the databaseID of the section cannot be retrieved, making it impossible to assign a value to windInfo.databaseUnId. I am confused. How should I correct the following code?
{
/*Here are some ellipsis operations on memo and element ,give enough information to create a section.*/
err = ACAPI_Element_CreateExt(&element, &memo, 1UL, &marker);
/*Here create the section successfully.*/
ACAPI_DisposeElemMemoHdls(&memo);
ACAPI_DisposeElemMemoHdls(&marker.memo);
API_DatabaseInfo origDB = {};
ACAPI_Database_GetCurrentDatabase(&origDB);
API_DatabaseInfo planDB = {};
planDB.typeID = APIWind_FloorPlanID;
const GSErrCode err2 = ACAPI_Database_ChangeCurrentDatabase(&planDB);
if (err2 != NoError) {
return ;
}
API_WindowInfo windInfo = {};
windInfo.typeID = APIWind_SectionID;
err = ACAPI_Element_Get(&element);
if (err == NoError) {
windInfo.databaseUnId = element.cutPlane.segment.databaseID;
}
if (element.cutPlane.segment.databaseID.elemSetId == APINULLGuid) {
ACAPI_WriteReport("# There is no databaseID in the element. ", true);
}
ACAPI_Database_ChangeCurrentDatabase(&origDB);
ACAPI_Window_ChangeWindow(&windInfo);
return ;
}
Solved! Go to Solution.
2024-05-29 05:14 AM
Hi,
I suppose the problem maybe you didn't finish Undo session before you tried to get section DB ID.
Please try the following code to see whether it solves your problem:
API_Guid sectGuid;
GSErrCode err = ACAPI_CallUndoableCommand ("Create Section",
[&] () -> GSErrCode {
...
err = ACAPI_Element_CreateExt(&element, &memo, 1UL, &marker);
sectGuid = element.header.guid;
});
API_Element elemSect{};
elemSect.header.guid = sectGuid;
err = ACAPI_Element_Get(&elemSect);
API_WindowInfo windInfo = {};
windInfo.typeID = APIWind_SectionID;
windInfo.databaseUnId = elemSect.cutPlane.segment.databaseID;
if (elemSect.cutPlane.segment.databaseID.elemSetId == APINULLGuid) {
ACAPI_WriteReport("# There is no databaseID in the element. ", true);
}
ACAPI_Window_ChangeWindow(&windInfo);
HTH
2024-05-29 05:14 AM
Hi,
I suppose the problem maybe you didn't finish Undo session before you tried to get section DB ID.
Please try the following code to see whether it solves your problem:
API_Guid sectGuid;
GSErrCode err = ACAPI_CallUndoableCommand ("Create Section",
[&] () -> GSErrCode {
...
err = ACAPI_Element_CreateExt(&element, &memo, 1UL, &marker);
sectGuid = element.header.guid;
});
API_Element elemSect{};
elemSect.header.guid = sectGuid;
err = ACAPI_Element_Get(&elemSect);
API_WindowInfo windInfo = {};
windInfo.typeID = APIWind_SectionID;
windInfo.databaseUnId = elemSect.cutPlane.segment.databaseID;
if (elemSect.cutPlane.segment.databaseID.elemSetId == APINULLGuid) {
ACAPI_WriteReport("# There is no databaseID in the element. ", true);
}
ACAPI_Window_ChangeWindow(&windInfo);
HTH