|
创建块
Part *workpart(theSession->Parts()->Work());
NXString length,width,height;
Point3d origin=this->point0->GetProperties()->GetPoint("Point");
double lengthValue =this->doubleLength->GetProperties()->GetDouble("Value");
double widthValue =this->doubleWidth->GetProperties()->GetDouble("Value");
double heightValue =this->doubleHeight->GetProperties()->GetDouble("Value");
std::stringstream slength;
slength<<lengthValue;
length=slength.str();
std::stringstream swidth;
swidth<<widthValue;
width=swidth.str();
std::stringstream sheight;
sheight<<heightValue;
height=sheight.str();
Features::Feature *null_block_feature(NULL);
Features::BlockFeatureBuilder *blockfeaturebuilder;
blockfeaturebuilder=workpart->Features()->CreateBlockFeatureBuilder(null_block_feature);
blockfeaturebuilder->SetOriginAndLengths(origin,length,width,height);
//commit
blockfeaturebuilder->CommitFeature();
//destroy
blockfeaturebuilder->Destroy();
创建圆柱
NXString diamerString,heihtString;
std::stringstream ssdia,ssheight;
BlockStyler::PropertyList*vectorProperty=vector0->GetProperties();
Vector3d vec=vectorProperty->GetVector("Vector");
delete vectorProperty;
vectorProperty=NULL;
BlockStyler::PropertyList*pointProperty=point0->GetProperties();
Point3d point=pointProperty->GetPoint("Point");
delete pointProperty;
pointProperty=NULL;
BlockStyler::PropertyList*diaProperty=expressionDia->GetProperties();
double dia=diaProperty->GetDouble("Value");
delete diaProperty;
diaProperty=NULL;
BlockStyler::PropertyList*heightProperty=expressionH->GetProperties();
double height=heightProperty->GetDouble("Value");
delete heightProperty;
heightProperty=NULL;
ssdia<<dia;
diamerString=ssdia.str();
ssheight<<height;
heihtString=ssheight.str();
//create the cylinder feature
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
Features::Feature *nullNXOpen_Features_Feature(NULL);
Features::CylinderBuilder *cylinderBuilder1;
cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(nullNXOpen_Features_Feature);
cylinderBuilder1->Diameter()->SetRightHandSide(diamerString);
cylinderBuilder1->Height()->SetRightHandSide(heihtString);
cylinderBuilder1->SetDirection(vec);
cylinderBuilder1->SetOrigin(point);
cylinderBuilder1->CommitFeature();
cylinderBuilder1->Destroy();
|
|