1、创建直线墙
API_Element wallElement = {};
GSErrCode err;
wallElement.header.typeID = API_ElemTypeID::API_WallID;
ACAPI_Element_GetDefaults(&wallElement, nullptr);
err = ACAPI_CallUndoableCommand("Create Element", [&]() -> GSErrCode {
wallElement.wall.begC = { 0, 0.0 };
wallElement.wall.endC = { 0, 2.0 };
ACAPI_Element_Create(&wallElement, nullptr);
return NoError;
});
if (err==NoError)
{
ACAPI_Element_Get(&wallElement);
MessageBox(ACAPI_GetMainWindow(), APIGuidToString(wallElement.header.guid).ToCStr(), "title", 0);
}
2、创建曲线墙
API_Element wallElement = {};
GSErrCode err;
wallElement.header.typeID = API_ElemTypeID::API_WallID;
ACAPI_Element_GetDefaults(&wallElement, nullptr);
err = ACAPI_CallUndoableCommand("Create Element", [&]() -> GSErrCode {
wallElement.wall.begC = { 0, 0.0 };
wallElement.wall.endC = { 0, 10.0 };
wallElement.wall.angle = PI/4;
ACAPI_Element_Create(&wallElement, nullptr);
return NoError;
});
if (err==NoError)
{
ACAPI_Element_Get(&wallElement);
MessageBox(ACAPI_GetMainWindow(), APIGuidToString(wallElement.header.guid).ToCStr(), "title", 0);
}
3、创建柱子
API_Coord point;
if (!ClickAPoint("Click to place column at this position.", &point)) {
return Error;
}
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 Error;
}
element.column.origoPos = point;
err = ACAPI_CallUndoableCommand("Create Element", [&]() -> GSErrCode {
return ACAPI_Element_Create(&element, &memo);
});
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Column) has failed with error code %ld!", true, err);
}
ACAPI_DisposeElemMemoHdls(&memo);
MessageBox(ACAPI_GetMainWindow(), APIGuidToString(element.header.guid).ToCStr(), "title", 0);
4、创建梁
API_Element element;
API_ElementMemo memo;
BNClear(element);
BNClear(memo);
element.header.typeID = API_BeamID;
GSErrCode err = ACAPI_Element_GetDefaults(&element, &memo);
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_GetDefaults (Beam) has failed with error code %ld!", true, err);
ACAPI_DisposeElemMemoHdls(&memo);
return Error;
}
element.beam.begC = { 0,0 };
element.beam.endC = { 10,0 };
err = ACAPI_CallUndoableCommand("Create Element", [&]() -> GSErrCode {
return ACAPI_Element_Create(&element, &memo);
});
if (err != NoError) {
ACAPI_WriteReport("ACAPI_Element_Create (Beam) has failed with error code %ld!", true, err);
}
ACAPI_DisposeElemMemoHdls(&memo);