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

How to change building material in column?

Anonymous
Not applicable
Hello.

I try to chage column's building material in ArchiCAD24.

But there is no buildingMaterial parameter in column. I remember there was existed buildingMaterial in ArchiCAD22.

I found that at API_ColumnSegmentType. But I don't know how to change this.

Could you please explain with example code?
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
YongWoo wrote:
I found that at API_ColumnSegmentType. But I don't know how to change this.
From Archicad 24 the columns can have multiple segments. Each segment can have different parameters, building materials. So the building material parameter belongs to the segments and not to the column itself.

API_ColumnType has the nSegments member which defines the number of the segments. Using the ACAPI_Element_GetMemo function you can retrieve the array of the segments and you can find the building material paramters of the segments in the returned memo.
API_ElementMemo memo = {};
ACAPI_Element_GetMemo (element.header.guid, &memo, APIMemoMask_ColumnSegment);

if (memo.columnSegments != nullptr) {
	for (UIndex idx = 0; idx < element.column.nSegments; ++idx) {
		API_ColumnSegmentType& columnSegment = memo.columnSegments[idx];
		// modify attributes of columnSegment here
	}

	API_Element maskElem;
	ACAPI_ELEMENT_MASK_CLEAR (maskElem);	// change only the parameters of the segments

	ACAPI_Element_Change (&element, &maskElem, &memo, APIMemoMask_ColumnSegment, true);
}

View solution in original post

3 REPLIES 3
Solution
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
YongWoo wrote:
I found that at API_ColumnSegmentType. But I don't know how to change this.
From Archicad 24 the columns can have multiple segments. Each segment can have different parameters, building materials. So the building material parameter belongs to the segments and not to the column itself.

API_ColumnType has the nSegments member which defines the number of the segments. Using the ACAPI_Element_GetMemo function you can retrieve the array of the segments and you can find the building material paramters of the segments in the returned memo.
API_ElementMemo memo = {};
ACAPI_Element_GetMemo (element.header.guid, &memo, APIMemoMask_ColumnSegment);

if (memo.columnSegments != nullptr) {
	for (UIndex idx = 0; idx < element.column.nSegments; ++idx) {
		API_ColumnSegmentType& columnSegment = memo.columnSegments[idx];
		// modify attributes of columnSegment here
	}

	API_Element maskElem;
	ACAPI_ELEMENT_MASK_CLEAR (maskElem);	// change only the parameters of the segments

	ACAPI_Element_Change (&element, &maskElem, &memo, APIMemoMask_ColumnSegment, true);
}
Anonymous
Not applicable
Thank you.

I only checked the element and didn't check the memo.

@Tibor Lorantfy can you post some code to demonstrate how to change a rectangle column segment (only one segment) section size, ie:400x600, I'm new to develop C++ add-on, adding some columns to Archicad 24, but different section size

 

void Do_CreateColumn (void) //创建柱
{
API_Coord point;

if (!ClickAPoint ("请点取要放置柱的点.", &point)) {
return;
}

API_Element element;
API_ElementMemo memo;
BNClear (element);
BNClear (memo);

element.header.typeID = API_ColumnID; //设置为柱
GSErrCode err = ACAPI_Element_GetDefaults (&element, &memo); //获取柱当前设置

if (err != NoError) {
ACAPI_WriteReport ("ACAPI_Element_GetDefaults (Column) has failed with error code %ld!", true, err);
ACAPI_DisposeElemMemoHdls (&memo);
return;
}

element.column.origoPos = point;
element.column.bottomOffset = -0.05;
element.column.topOffset = -0.05;
// element.column.height = 3.0;
// element.column.nSegments

err = ACAPI_Element_Create (&element, &memo); //创建柱
if (err != NoError) {
ACAPI_WriteReport ("ACAPI_Element_Create (Column) has failed with error code %ld!", true, err);

//How to change section size?
   //please put some code here 

}

 

ArchiCAD 25