C++
//用户头文件
#include <NXOpen/Body.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/Expression.hxx>
#include <NXOpen/ExpressionCollection.hxx>
#include <NXOpen/Features_BlockFeatureBuilder.hxx>
#include <NXOpen/Features_Feature.hxx>
#include <NXOpen/Features_FeatureBuilder.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/GeometricUtilities_BooleanOperation.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Point.hxx>
#include <NXOpen/PointCollection.hxx>
#include <NXOpen/Unit.hxx>
#include <NXOpen/UnitCollection.hxx>
#include <NXOpen/Update.hxx>
//用户代码
Part *workPart = theSession->Parts()->Work();
Part *displayPart = theSession->Parts()->Display();
Features::Feature *nullFeatures_Feature(NULL);
Features::BlockFeatureBuilder *blockFeatureBuilder1;
blockFeatureBuilder1 = workPart->Features()->CreateBlockFeatureBuilder(nullFeatures_Feature);
blockFeatureBuilder1->BooleanOption()->SetType(GeometricUtilities::BooleanOperation::BooleanTypeCreate);
blockFeatureBuilder1->SetType(Features::BlockFeatureBuilder::TypesTwoPointsAndHeight); //设置两点建方体类型
//获取UI选取的点
Point3d point1 = point01->Point();
Point3d point2 = point02->Point();
//获取UI输入的高度转char*字符
double Height = double0->Value();
char H[256];
sprintf(H,"%f",Height);
blockFeatureBuilder1->SetTwoPointsAndHeight(point1, point2, H );
Features::Feature *feature1;
feature1 = blockFeatureBuilder1->CommitFeature();
blockFeatureBuilder1->Destroy();