NCS Indicator -- Revised

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2021-06-06
02:52 AM
- last edited on
2021-09-14
09:35 AM
by
Noemi Balogh
2021-06-06
02:52 AM
I am writing a Add-On to just place a NCS Indicator Label. Unfortunately the code will only place the default label and ignores anything else. I can't figure this out because, using the exact same code, -- just changinge the type ,index, guid etc. it works perfectly well for library Parts.I demo this in the attached private video. Element Test is no help since it only demos using the GetDefault to place a label . i need to override the default and select a non-default label as i do for a Library Part.
Attached is the demo video and my code for placing NCS Indicator label
https://www.youtube.com/watch?v=1WRa9kU-J_E
Attached is the demo video and my code for placing NCS Indicator label
static GS::ErrCode Do_CreateNCS(API_Coord c) { keyParams keys; GS::UniString name("NCS Indicator 24"); API_LibPart libPart; API_Element element; API_ElementMemo memo; API_AddParType **addPars = nullptr; API_Guid nn; double a, b; Int32 addParNum; GS::ErrCode err; BNZeroMemory(&libPart, sizeof(API_LibPart)); BNZeroMemory(&element, sizeof(API_Element)); BNZeroMemory(&memo, sizeof(API_ElementMemo)); GS::ucscpy(libPart.docu_UName, name.ToUStr()); // "DB8C3EE - 4019 - 46C8 - 91D0 - 7A8DE0A5EC6D" - NCS guid err = ACAPI_LibPart_Search(&libPart, false); if (err == NoError) { ACAPI_WriteReport(" Lib Part index %d", true,libPart.index); } else { ACAPI_WriteReport(" Did Not Find Lib Part", true); return err; } if (libPart.location != nullptr) delete libPart.location; element.label.labelClass = APILblClass_Symbol; element.label.parent = APINULLGuid; API_Coord xx; xx.x = 0; xx.y = 0; element.label.begC = xx; element.label.midC.x = xx.x + 1.0; element.label.midC.y = xx.y + 0.5; element.label.endC.x = xx.x + 3.0; element.label.endC.y = xx.y + 0.5; GS::Guid buf("BDB8C3EE - 4019 - 46C8 - 91D0 - 7A8DE0A5EC6D");// NCS Indicator Guid element.label.u.head.guid = GSGuid2APIGuid(buf); element.header.typeID = API_LabelID; //ElementTypeID element.header.variationID = APIVarId_LabelSymb; element.label.parent = APINULLGuid; element.label.u.symbol.libInd= libPart.index; //library part index; element.header.hasMemo = true; err = ACAPI_Element_GetDefaults(&element, &memo); if (err == NOERROR) { GS::Guid gs(APIGuid2GSGuid(element.label.u.head.guid)); char hold[254] = {}; gs.ConvertToString(hold); ACAPI_WriteReport("Label GUID %s ", true, hold); // label guid -- should be the same as NCS Indicator Guid but is reset to 0 by GetDefault? } API_StoryInfo storyInfo; BNZeroMemory(&storyInfo, sizeof(API_StoryInfo)); err = ACAPI_Environment(APIEnv_GetStorySettingsID, &storyInfo, nullptr); //element.object.libInd = libPart.index; //library part index; element.header.floorInd = storyInfo.actStory; element.object.level = 0; //height from the floor element.object.pos.x = c.x + .25; //End of Arrow element.object.pos.y = c.y; element.object.angle = 1; //element angle BMKillHandle((GSHandle *)&storyInfo.data); //err = ACAPI_LibPart_GetParams(libPart.index, &a, &b, &addParNum, &addPars); UInt32 totalParams = BMGetHandleSize((GSConstHandle)addPars) / (UInt32)sizeof(API_AddParType); // totalParams redundant but retain for future use //memo.params = addPars; err = ACAPI_CallUndoableCommand("NCS Test API Function", [&]() -> GSErrCode { err = ACAPI_Element_Create(&element, &memo); return err; }); if (err) ACAPI_WriteReport("Create Error %s ", true, ErrID_To_Name(err)); return NOERROR; }Thanks for any help -- I hope this isn't a bug??
Gerry
Windows 11 - Visual Studio 2022; ArchiCAD 27
Windows 11 - Visual Studio 2022; ArchiCAD 27
Labels:
- Labels:
-
Add-On (C++)
0 REPLIES 0