We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-10-14 01:16 PM - last edited on 2024-10-14 10:23 PM by Laszlo Nagy
Hi everyone! Please, help me
I need to write the 1st vertex coordinate of selected Curtain Wall contour into API_Coord variable. But I get error:
GSErrCode err;
err = NoError;
API_Element CWElem = {};
API_ElementMemo CWMemo = {};
API_SelectionInfo selectionInfo;
GS::Array<API_Neig> selNeigs;
err = ACAPI_Selection_Get(&selectionInfo, &selNeigs, false);
if (err != NoError)
return err;
CWElem.header.guid = selNeigs[0].guid;
err = ACAPI_Element_Get(&CWElem);
if (err != NoError)
return err;
err = ACAPI_Element_GetMemo(CWElem.header.guid, &CWMemo, APIMemoMask_All);
if (err != NoError)
return err;
API_Coord coord = (*(*CWMemo.cWSegContour).coords)[0]; //error "Access Violation"
return err;
Please, help me to solve it. Thank you!
2024-10-16 09:57 AM
Hi,
Please try the following code to see whether you can get the coords of curtain wall. The 1st coord should be j=1.
HTH.
GS::Array<API_Guid> cwallList;
GSErrCode err = ACAPI_Element_GetElemList(API_CurtainWallID, &cwallList, APIFilt_OnActFloor| APIFilt_IsEditable | APIFilt_OnVisLayer);
for (API_Guid& guid : cwallList) {
API_Element elem = {};
elem.header.guid = guid;
err = ACAPI_Element_Get(&elem);
if (!err) {
API_ElementMemo memo = {};
err = ACAPI_Element_GetMemo(guid, &memo);
if (!err) {
for (Int32 j = 0; j <= elem.curtainWall.polygon.nCoords; j++) {
API_Tranmat tran = elem.curtainWall.planeMatrix;
double fx = (*memo.coords)[j].x;
double fy = (*memo.coords)[j].y;
double tx = tran.tmx[0] * fx + tran.tmx[1] * fy +tran.tmx[3];
double ty = tran.tmx[4] * fx + tran.tmx[5] * fy +tran.tmx[7];
DBPrintf("%d, %10.3lf, %10.3lf\n", j, tx, ty);
}
}
ACAPI_DisposeElemMemoHdls(&memo);
}
}
4 weeks ago
I'm sorry for late reply. So many work...
I created a curtain wall (length 4000 mm) and ran this code in debugger. I've got next values of variables j, tx and ty :
j | tx | ty |
0 | -1 | 0 |
1 | 0 | 0 |
2 | 4 | 0 |
Is it what you asked me?
4 weeks ago
Hi, it shows you the selected curtain wall position is from (0,0) to (4,0). if you rewrite the (*memo.coord)[1], that should be the first vertex coordinate of the selected curtain wall. you need to call element change command if you'd like to modify the selected element.
HTH.
3 weeks ago
Honestly, it's not what I asked about. But I found decision.
Thank you!