NX二次开发 PK创建棱柱 PK_BODY_create_solid_prism
//创建棱柱
bool PK_CreatePrism(const double point[3], const double dir[3], const double diam, const double height, const int n_sides, PK_BODY_t& pkBody)
{
double diam1 = 0.0, height1 = 0.0;
double mm = 0.001, mat_3d[9] = { 0.0 };
diam1 = fabs(diam);
height1 = fabs(height);
pkBody = PK_ENTITY_null;
if (diam1 < g_dist_tol
|| height1 < g_dist_tol
|| n_sides < 3
|| n_sides > 1000)
return false;
if (UF_MTX3_initialize_z(dir, mat_3d))
return false;
PK_AXIS2_sf_t basis_set;
basis_set.location.coord[0] = point[0] * mm;
basis_set.location.coord[1] = point[1] * mm;
basis_set.location.coord[2] = point[2] * mm;
UF_MTX3_z_vec(mat_3d, basis_set.axis.coord);
UF_MTX3_x_vec(mat_3d, basis_set.ref_direction.coord);
PK_BODY_create_solid_prism(diam1 * 0.5 * mm, height1 * mm, n_sides, &basis_set, &pkBody);
return true;
}