We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

How to get coord of Curtain Wall

Lease
Participant

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!

4 REPLIES 4
LChen
Graphisoft
Graphisoft

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);
		 }
	}

  

Lease
Participant

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 :

 

jtxty
0-10
100
240

 

Is it what you asked me?

LChen
Graphisoft
Graphisoft

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. 

Honestly, it's not what I asked about. But I found decision.

 

Thank you!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!