NX二次开发源码分享:NXOpen C++创建圆柱体特征
NX二次开发源码分享:NXOpen C++创建圆柱体特征<P> </P>
<P>void CreateCylinder_UsingUDB::CreateCylinder()
{
Part* workPart(theSession->Parts()->Work());</P>
<P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
<P>//Get the point
PropertyList* pointPropertyList = point0->GetProperties();
Point3d originPoint = pointPropertyList->GetPoint("Point");
delete pointPropertyList;
pointPropertyList = NULL;</P>
<P>//Get the direction
PropertyList* vectorPropertyList = vector0->GetProperties();
Vector3d direction = vectorPropertyList->GetVector("Vector");
delete vectorPropertyList;
vectorPropertyList = NULL;</P>
<P>Direction* direction1 = NULL;
direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
<P>//Set diameter and height
std::stringstream diameterValue;
diameterValue << diameter->GetValue();
std::stringstream heightValue;
heightValue << height->GetValue();</P>
<P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
<P>//Set the axis
Axis* axis1 = NULL;
axis1 = cylinderBuilder1->Axis();
axis1->Point()->SetCoordinates(originPoint);
axis1->SetDirection(direction1);</P>
<P>//Commit
cylinderBuilder1->Commit();
cylinderBuilder1->Destroy();
cylinderBuilder1 = NULL;
}
</P>
页:
[1]