We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2012-08-27 10:16 PM - last edited on 2023-08-02 04:19 PM by Doreena Deng
2012-08-28 03:52 PM
GSErrCode err; API_SelectionInfo selectionInfo; API_Element tElem; API_Neig **selNeigs; // set the corners of the selection box selectionInfo.marquee.box.xMin = 0.0; selectionInfo.marquee.box.xMax = 10.0; selectionInfo.marquee.box.yMin = 0.0; selectionInfo.marquee.box.yMax = 10.0; selectionInfo.typeID = API_MarqueeHorBox; ACAPI_Selection_SetMarquee (&selectionInfo); // collect elements err = ACAPI_Selection_Get (&selectionInfo, &selNeigs, false); BMKillHandle ((GSHandle *) &selectionInfo.marquee.coords); if (err == APIERR_NOSEL) err = NoError; if (err != NoError) { BMKillHandle ((GSHandle *) &selNeigs); return; } if (selectionInfo.typeID != API_SelEmpty) { UInt32 ii, nSel; nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); for (ii = 0; ii < nSel && err == NoError; ii++) { tElem.header.typeID = Neig_To_ElemID ((*selNeigs)[ii].neigID); // filter elements if (tElem.header.typeID == API_DimensionID) continue; tElem.header.guid = (*selNeigs)[ii].guid; tElem.header.index = 0; if (ACAPI_Element_Get (&tElem) != NoError) continue; // now tElem is one of the elements in the created marquee box } } BMKillHandle ((GSHandle *) &selNeigs); // remove selection box selectionInfo.typeID = API_SelEmpty; ACAPI_Selection_SetMarquee (&selectionInfo);Regards,
2012-08-30 11:08 AM
2012-08-31 09:55 AM
GSErrCode err; API_SelectionInfo selectionInfo; API_Neig **selNeigs; // set the corners of the selection box selectionInfo.marquee.box.xMin = 0.0; selectionInfo.marquee.box.xMax = 10.0; selectionInfo.marquee.box.yMin = 0.0; selectionInfo.marquee.box.yMax = 10.0; selectionInfo.typeID = API_MarqueeHorBox; ACAPI_Selection_SetMarquee (&selectionInfo); // collect elements err = ACAPI_Selection_Get (&selectionInfo, &selNeigs, false); BMKillHandle ((GSHandle *) &selectionInfo.marquee.coords); if (err == APIERR_NOSEL) err = NoError; if (err != NoError) { BMKillHandle ((GSHandle *) &selNeigs); return; } if (selectionInfo.typeID != API_SelEmpty) { // you can deselect all before the operation like this err = ACAPI_Element_Select (NULL, 0, false); if (err != NoError) ACAPI_WriteReport ("ACAPI_Element_Select deselect all error", true); // ------------------------------------------------------------------------------------------ UInt32 nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); // select the elements within the marquee ACAPI_Element_Select (selNeigs, nSel, true); if (err != NoError) ACAPI_WriteReport ("ACAPI_Element_Select select all error", true); // ------------------------------------------------------------------------------------------ } BMKillHandle ((GSHandle *) &selNeigs); // remove selection box selectionInfo.typeID = API_SelEmpty; ACAPI_Selection_SetMarquee (&selectionInfo);
2012-09-03 10:20 AM
2012-09-10 10:37 AM
GSErrCode err; API_Neig **selNeigs; API_SelectionInfo selectionInfo; Int32 nCoords = 6; // first and last coordinates are the same, so this will be only a pentagon selectionInfo.typeID = API_MarqueePoly; selectionInfo.marquee.nCoords = nCoords; // Allocate memory and set the coordinates API_Coord* coords = reinterpret_cast<API_Coord*> (BMAllocatePtr (nCoords * sizeof (API_Coord), ALLOCATE_CLEAR, 0));; if (coords != NULL) { coords[0].x = 2.0; coords[0].y = 0.0; coords[1].x = 5.0; coords[1].y = 3.0; coords[2].x = 0.0; coords[2].y = 5.0; coords[3].x = -5.0; coords[3].y = 3.0; coords[4].x = -2.0; coords[4].y = 0.0; coords[5].x = 2.0; coords[5].y = 0.0; selectionInfo.marquee.coords = &coords; ACAPI_Selection_SetMarquee (&selectionInfo); // Releasing allocated memory BMKillPtr ((GSPtr *) &coords); // collect elements within the pentagon err = ACAPI_Selection_Get (&selectionInfo, &selNeigs, false); BMKillHandle ((GSHandle *) &selectionInfo.marquee.coords); if (err == APIERR_NOSEL) err = NoError; if (err != NoError) { BMKillHandle ((GSHandle *) &selNeigs); return; } // ... // ... }
2012-09-16 09:43 PM