Cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert all the surfaces in NX into B-surface?

Pioneer
Pioneer

Hello everyone,

 

I would like to ask whether there exists a function in NX which can convert all the faces of a CAD body into B-surface .

I made a NXopen code which is able to read the information of B-surface, but it seems that not all the surfaces of a CAD body in NX are B-surface.

 

PS : You can use "information" - > "B-surface " to check whether a face is a B-surface

 

Thanks

6 REPLIES

Re: How to convert all the surfaces in NX into B-surface?

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

If you use X-form or I-form on an existing face (start the command, select a face, press OK without making any edits) it will be converted to a B-surf.

 

Also, the extract geometry command (type: face) allows you to specify the output surface type as B-surface. In this case you will have a copy of the original surface, it won't convert the original face into a B-surface.

 

Other surface commands may have a similar effect to those listed above.

Re: How to convert all the surfaces in NX into B-surface?

Pioneer
Pioneer

Thank your for your reply.

 

But If I want to use Xform or Iform in Nxopen to convert a face into a B-surf. First I need to know the coordinates of poles(control points). But up to now, I don't know how to get the coordiantes of control points for a face.

 

From my point of view, the sequence for solving my problem is like:

find the controls points of a face(but normally the oringal surface is not a B-surf, I don't know how to get the control points)  ---->use Xform to convert the face into  B-surf

 

 

 

Re: How to convert all the surfaces in NX into B-surface?

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Analytical surfaces (planes, cylinders, etc) don't have control points (poles).

 

I'm not sure why you would need to know the poles before using the X-form command?

Re: How to convert all the surfaces in NX into B-surface?

Pioneer
Pioneer

Here is the code for Xform:

As you can see, before assigning the ControlPoleManger for the StudioXformBuilderEx1

 , I need to know the coordinates of all the control points. If I wouldn't know the control points, I can't define Xform in Nxopen.

 

Are there any other ways to define Xform in NXopen without knowing the coordinates of the control points.

 

 

 

 

#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/BasePart.hxx>
#include <NXOpen/Body.hxx>
#include <NXOpen/BodyCollection.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/CoordinateSystem.hxx>
#include <NXOpen/Direction.hxx>
#include <NXOpen/DisplayableObject.hxx>
#include <NXOpen/Expression.hxx>
#include <NXOpen/ExpressionCollection.hxx>
#include <NXOpen/Face.hxx>
#include <NXOpen/Features_Extrude.hxx>
#include <NXOpen/Features_FaceRecognitionBuilder.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/Features_StudioXformBuilderEx.hxx>
#include <NXOpen/GeometricUtilities_Continuity.hxx>
#include <NXOpen/GeometricUtilities_ControlPoleManagerData.hxx>
#include <NXOpen/GeometricUtilities_CurveRangeBuilder.hxx>
#include <NXOpen/GeometricUtilities_DegreesAndSegmentsOrPatchesBuilder.hxx>
#include <NXOpen/GeometricUtilities_OnPathDimensionBuilder.hxx>
#include <NXOpen/GeometricUtilities_OrientXpressBuilder.hxx>
#include <NXOpen/GeometricUtilities_SurfaceRangeBuilder.hxx>
#include <NXOpen/IPlane.hxx>
#include <NXOpen/ModelingView.hxx>
#include <NXOpen/ModelingViewCollection.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Plane.hxx>
#include <NXOpen/PlaneCollection.hxx>
#include <NXOpen/PlaneTypes.hxx>
#include <NXOpen/Point.hxx>
#include <NXOpen/PointCollection.hxx>
#include <NXOpen/Preferences_PartModeling.hxx>
#include <NXOpen/Preferences_PartPreferences.hxx>
#include <NXOpen/ScCollector.hxx>
#include <NXOpen/SelectNXObjectList.hxx>
#include <NXOpen/SelectObject.hxx>
#include <NXOpen/SelectObjectList.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/SmartObject.hxx>
#include <NXOpen/TaggedObject.hxx>
#include <NXOpen/Unit.hxx>
#include <NXOpen/UnitCollection.hxx>
#include <NXOpen/Xform.hxx>
using namespace NXOpen;

extern "C" DllExport int ufusr_ask_unload()
{
	return (int)NXOpen::Session::LibraryUnloadOptionImmediately;
}

extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
{


	NXOpen::Session *theSession = NXOpen::Session::GetSession();
	NXOpen::Part *workPart(theSession->Parts()->Work());
	NXOpen::Part *displayPart(theSession->Parts()->Display());
	// ----------------------------------------------
	//   Menu: Edit->Surface->X-Form...
	// ----------------------------------------------

	NXOpen::Features::StudioXform *nullNXOpen_Features_StudioXform(NULL);
	NXOpen::Features::StudioXformBuilderEx *studioXformBuilderEx1;
	studioXformBuilderEx1 = workPart->Features()->CreateStudioXformBuilderEx(nullNXOpen_Features_StudioXform);

	NXOpen::Unit *unit1(dynamic_cast<NXOpen::Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));

	NXOpen::Features::Extrude *extrude1(dynamic_cast<NXOpen::Features::Extrude *>(workPart->Features()->FindObject("EXTRUDE(2)")));
	NXOpen::Face *face1(dynamic_cast<NXOpen::Face *>(extrude1->FindObject("FACE 120 {(37.5,17.5,0) EXTRUDE(2)}")));
	NXOpen::Point3d point2(100, 100, 100.0);
	NXObject *object = face1;
	bool added1;
	added1 = studioXformBuilderEx1->XformObjects()->Add(object);  // this point is not important 

	studioXformBuilderEx1->ChangeDegreeWithParameters(face1, 2, 3, 4, 6);

	studioXformBuilderEx1->ControlPoleManager()->SetUDimension(0, 6);

	studioXformBuilderEx1->ControlPoleManager()->SetVDimension(0, 9);

	studioXformBuilderEx1->ControlPoleManager()->SetIsUPeriodic(0, false);

	studioXformBuilderEx1->ControlPoleManager()->SetIsVPeriodic(0, false);


	NXOpen::Point3d coordinates48(0.0, 0.0, 0.0);
	NXOpen::Point *point49;
	point49 = workPart->Points()->CreatePoint(coordinates48);

	NXOpen::Point3d coordinates49(9.68768799409648e-005, 1.53938040044276, 0.0);
	NXOpen::Point *point50;
	point50 = workPart->Points()->CreatePoint(coordinates49);

	NXOpen::Point3d coordinates50(-2.00520028047213e-008, 5.10417962710984, 0.0);
	NXOpen::Point *point51;
	point51 = workPart->Points()->CreatePoint(coordinates50);

	NXOpen::Point3d coordinates51(3.07517375934396e-005, 10.6944434522669, 0.0);
	NXOpen::Point *point52;
	point52 = workPart->Points()->CreatePoint(coordinates51);

	NXOpen::Point3d coordinates52(1.35441227431615e-005, 16.7708261395103, 0.0);
	NXOpen::Point *point53;
	point53 = workPart->Points()->CreatePoint(coordinates52);

	NXOpen::Point3d coordinates53(2.77889683855757e-005, 22.847238869422, 0.0);
	NXOpen::Point *point54;
	point54 = workPart->Points()->CreatePoint(coordinates53);

	NXOpen::Point3d coordinates54(2.50418391734379e-007, 28.9235861481734, 0.0);
	NXOpen::Point *point55;
	point55 = workPart->Points()->CreatePoint(coordinates54);

	NXOpen::Point3d coordinates55(8.74542273049684e-005, 32.9745181294631, 0.0);
	NXOpen::Point *point56;
	point56 = workPart->Points()->CreatePoint(coordinates55);

	NXOpen::Point3d coordinates56(0.0, 35.0, 0.0);
	NXOpen::Point *point57;
	point57 = workPart->Points()->CreatePoint(coordinates56);

	NXOpen::Point3d coordinates57(7.03145951415992, 1.90682759552987e-005, -0.0);
	NXOpen::Point *point58;
	point58 = workPart->Points()->CreatePoint(coordinates57);

	NXOpen::Point3d coordinates58(7.03146647072949, 1.53937303727496, 0.0);
	NXOpen::Point *point59;
	point59 = workPart->Points()->CreatePoint(coordinates58);

	NXOpen::Point3d coordinates59(7.03129496220528, 5.10418096519167, 0.0);
	NXOpen::Point *point60;
	point60 = workPart->Points()->CreatePoint(coordinates59);

	NXOpen::Point3d coordinates60(7.03131863377699, 10.6944431530698, 0.0);
	NXOpen::Point *point61;
	point61 = workPart->Points()->CreatePoint(coordinates60);

	NXOpen::Point3d coordinates61(7.03131232967415, 16.7708258106556, 0.0);
	NXOpen::Point *point62;
	point62 = workPart->Points()->CreatePoint(coordinates61);

	NXOpen::Point3d coordinates62(7.03130876089896, 22.8472400985479, 0.0);
	NXOpen::Point *point63;
	point63 = workPart->Points()->CreatePoint(coordinates62);

	NXOpen::Point3d coordinates63(7.03130118924827, 28.9235820781127, 0.0);
	NXOpen::Point *point64;
	point64 = workPart->Points()->CreatePoint(coordinates63);

	NXOpen::Point3d coordinates64(7.0314267672504, 32.9745308836689, 0.0);
	NXOpen::Point *point65;
	point65 = workPart->Points()->CreatePoint(coordinates64);

	NXOpen::Point3d coordinates65(7.03143079197295, 34.9999744955331, 0.0);
	NXOpen::Point *point66;
	point66 = workPart->Points()->CreatePoint(coordinates65);

	NXOpen::Point3d coordinates66(24.2186561922301, 4.80828643530822e-006, 0.0);
	NXOpen::Point *point67;
	point67 = workPart->Points()->CreatePoint(coordinates66);

	NXOpen::Point3d coordinates67(24.2186584055014, 1.53935912796372, 0.0);
	NXOpen::Point *point68;
	point68 = workPart->Points()->CreatePoint(coordinates67);

	NXOpen::Point3d coordinates68(24.2187294455495, 5.1041717069099, 0.0);
	NXOpen::Point *point69;
	point69 = workPart->Points()->CreatePoint(coordinates68);

	NXOpen::Point3d coordinates69(24.2187210733609, 10.6944439031052, 0.0);
	NXOpen::Point *point70;
	point70 = workPart->Points()->CreatePoint(coordinates69);

	NXOpen::Point3d coordinates70(24.2187226447721, 16.7708308286216, 0.0);
	NXOpen::Point *point71;
	point71 = workPart->Points()->CreatePoint(coordinates70);

	NXOpen::Point3d coordinates71(24.2187252010378, 22.84722825747, 0.0);
	NXOpen::Point *point72;
	point72 = workPart->Points()->CreatePoint(coordinates71);

	NXOpen::Point3d coordinates72(24.218726991063, 28.9236013771929, 0.0);
	NXOpen::Point *point73;
	point73 = workPart->Points()->CreatePoint(coordinates72);

	NXOpen::Point3d coordinates73(24.2186753197849, 32.9745342734357, 0.0);
	NXOpen::Point *point74;
	point74 = workPart->Points()->CreatePoint(coordinates73);

	NXOpen::Point3d coordinates74(24.2186691541951, 34.999993648255, 0.0);
	NXOpen::Point *point75;
	point75 = workPart->Points()->CreatePoint(coordinates74);

	NXOpen::Point3d coordinates75(44.5313600030204, 3.04890175270708e-006, 0.0);
	NXOpen::Point *point76;
	point76 = workPart->Points()->CreatePoint(coordinates75);

	NXOpen::Point3d coordinates76(44.5313573944511, 1.53935839946227, 0.0);
	NXOpen::Point *point77;
	point77 = workPart->Points()->CreatePoint(coordinates76);

	NXOpen::Point3d coordinates77(44.5312737468677, 5.1041704471028, 0.0);
	NXOpen::Point *point78;
	point78 = workPart->Points()->CreatePoint(coordinates77);

	NXOpen::Point3d coordinates78(44.5312840176435, 10.6944441113145, 0.0);
	NXOpen::Point *point79;
	point79 = workPart->Points()->CreatePoint(coordinates78);

	NXOpen::Point3d coordinates79(44.5312819195997, 16.7708313225245, 0.0);
	NXOpen::Point *point80;
	point80 = workPart->Points()->CreatePoint(coordinates79);

	NXOpen::Point3d coordinates80(44.5312790588308, 22.8472269636633, 0.0);
	NXOpen::Point *point81;
	point81 = workPart->Points()->CreatePoint(coordinates80);

	NXOpen::Point3d coordinates81(44.531276911777, 28.9236036346449, 0.0);
	NXOpen::Point *point82;
	point82 = workPart->Points()->CreatePoint(coordinates81);

	NXOpen::Point3d coordinates82(44.531337257937, 32.9745339587885, 0.0);
	NXOpen::Point *point83;
	point83 = workPart->Points()->CreatePoint(coordinates82);

	NXOpen::Point3d coordinates83(44.5313448865708, 34.9999959380158, 0.0);
	NXOpen::Point *point84;
	point84 = workPart->Points()->CreatePoint(coordinates83);

	NXOpen::Point3d coordinates84(64.8435469118027, 1.74959570782354e-005, 0.0);
	NXOpen::Point *point85;
	point85 = workPart->Points()->CreatePoint(coordinates84);

	NXOpen::Point3d coordinates85(64.8435601145667, 1.5393680768471, 0.0);
	NXOpen::Point *point86;
	point86 = workPart->Points()->CreatePoint(coordinates85);

	NXOpen::Point3d coordinates86(64.8437069273532, 5.1041789153043, 0.0);
	NXOpen::Point *point87;
	point87 = workPart->Points()->CreatePoint(coordinates86);

	NXOpen::Point3d coordinates87(64.8436896535431, 10.6944432133197, 0.0);
	NXOpen::Point *point88;
	point88 = workPart->Points()->CreatePoint(coordinates87);

	NXOpen::Point3d coordinates88(64.843692595086, 16.7708271167441, 0.0);
	NXOpen::Point *point89;
	point89 = workPart->Points()->CreatePoint(coordinates88);

	NXOpen::Point3d coordinates89(64.8436987876206, 22.8472371672248, 0.0);
	NXOpen::Point *point90;
	point90 = workPart->Points()->CreatePoint(coordinates89);

	NXOpen::Point3d coordinates90(64.8437005293471, 28.9235865274838, 0.0);
	NXOpen::Point *point91;
	point91 = workPart->Points()->CreatePoint(coordinates90);

	NXOpen::Point3d coordinates91(64.8435970969882, 32.974533587467, 0.0);
	NXOpen::Point *point92;
	point92 = workPart->Points()->CreatePoint(coordinates91);

	NXOpen::Point3d coordinates92(64.8435746472291, 34.9999766738847, 0.0);
	NXOpen::Point *point93;
	point93 = workPart->Points()->CreatePoint(coordinates92);

	NXOpen::Point3d coordinates93(75.0, 0.0, 0.0);
	NXOpen::Point *point94;
	point94 = workPart->Points()->CreatePoint(coordinates93);

	NXOpen::Point3d coordinates94(74.9998783843842, 1.53937537650772, 0.0);
	NXOpen::Point *point95;
	point95 = workPart->Points()->CreatePoint(coordinates94);

	NXOpen::Point3d coordinates95(74.9999997900562, 5.10417713215534, 0.0);
	NXOpen::Point *point96;
	point96 = workPart->Points()->CreatePoint(coordinates95);

	NXOpen::Point3d coordinates96(74.9999614752174, 10.6944436846302, 0.0);
	NXOpen::Point *point97;
	point97 = workPart->Points()->CreatePoint(coordinates96);

	NXOpen::Point3d coordinates97(74.9999829034657, 16.7708274500478, 0.0);
	NXOpen::Point *point98;
	point98 = workPart->Points()->CreatePoint(coordinates97);

	NXOpen::Point3d coordinates98(74.9999651018552, 22.8472357887178, 0.0);
	NXOpen::Point *point99;
	point99 = workPart->Points()->CreatePoint(coordinates98);

	NXOpen::Point3d coordinates99(74.9999996624004, 28.9235908168865, 0.0);
	NXOpen::Point *point100;
	point100 = workPart->Points()->CreatePoint(coordinates99);

	NXOpen::Point3d coordinates100(74.9998900122981, 32.9745214243691, 0.0);
	NXOpen::Point *point101;
	point101 = workPart->Points()->CreatePoint(coordinates100);

	NXOpen::Point3d coordinates101(75.0, 35.0, 0.0);
	NXOpen::Point *point102;
	point102 = workPart->Points()->CreatePoint(coordinates101);

	//create the index
	std::vector<int> polesindex77(54);
	const int polesindex77_initial_values[] = {
		0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
		10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
		20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
		30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
		40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
		50, 51, 52, 53
	};
	polesindex77.assign(polesindex77_initial_values, polesindex77_initial_values + 54); 

	//create the points
	std::vector<NXOpen::Point *> poles77(54);
	poles77[0] = point49;
	poles77[1] = point50;
	poles77[2] = point51;
	poles77[3] = point52;
	poles77[4] = point53;
	poles77[5] = point54;
	poles77[6] = point55;
	poles77[7] = point56;
	poles77[8] = point57;
	poles77[9] = point58;
	poles77[10] = point59;
	poles77[11] = point60;
	poles77[12] = point61;
	poles77[13] = point62;
	poles77[14] = point63;
	poles77[15] = point64;
	poles77[16] = point65;
	poles77[17] = point66;
	poles77[18] = point67;
	poles77[19] = point68;
	poles77[20] = point69;
	poles77[21] = point70;
	poles77[22] = point71;
	poles77[23] = point72;
	poles77[24] = point73;
	poles77[25] = point74;
	poles77[26] = point75;
	poles77[27] = point76;
	poles77[28] = point77;
	poles77[29] = point78;
	poles77[30] = point79;
	poles77[31] = point80;
	poles77[32] = point81;
	poles77[33] = point82;
	poles77[34] = point83;
	poles77[35] = point84;
	poles77[36] = point85;
	poles77[37] = point86;
	poles77[38] = point87;
	poles77[39] = point88;
	poles77[40] = point89;
	poles77[41] = point90;
	poles77[42] = point91;
	poles77[43] = point92;
	poles77[44] = point93;
	poles77[45] = point94;
	poles77[46] = point95;
	poles77[47] = point96;
	poles77[48] = point97;
	poles77[49] = point98;
	poles77[50] = point99;
	poles77[51] = point100;
	poles77[52] = point101;
	poles77[53] = point102;


	studioXformBuilderEx1->ControlPoleManager()->SetPoles(0, polesindex77, poles77);
	studioXformBuilderEx1->ControlPoleManager()->SetPoleGroupEntity(0, face1);
	NXOpen::NXObject *nXObject1;
	nXObject1 = studioXformBuilderEx1->Commit();
	studioXformBuilderEx1->Destroy();
}

 

Re: How to convert all the surfaces in NX into B-surface?

Siemens Phenom Siemens Phenom
Siemens Phenom

I don't understand why you think XForm is the right tool.

 

If you want to convert a face to a b-surface (or at least, if you want to make a copy of a face in b-surface form), then the best tool is not X-Form, it's "Extract". Record an Insert--> Associative Copy --> Extract Geometry --> Face operation, and look at the code you get. Set the "Surface Type" option equal to "General B-surface".

 

Alternatively, you can call NXOpen.UF.UFModl.ExtractFace. Set mode=2 to get a general b-surface as output.

山田
yamada

Re: How to convert all the surfaces in NX into B-surface?

Legend
Legend

I had a need to use a b-surface for a specific application.  Using VB I used a the try error catching method.  In the try part I would ask for the b-surface properties.  If the face is a b-surface then no error results and the b-surfcae properties are available.  If the face is not a b-surface then in the catch section I create the b-surface.  I have included the code snippets

 

Try
     ufs.Modl.AskBsurf(theFace.Tag, bsurface1)
     testface = theFace
Catch ex As Exception
     createExtractedBSurface(theFace, extractedfeat1)
     extractedbodyfeat1 = DirectCast(extractedfeat1, BodyFeature)
     extractedbody1 = extractedbodyfeat1.GetBodies
     faces = extractedbody1(0).GetFaces
     ufs.Modl.AskBsurf(faces(0).Tag, bsurface1)
     testface = faces(0)
End Try

Public Sub createExtractedBSurface(ByVal face1 As Face, ByRef extractedfeat1 As Feature)
        Dim nullFeatures_Feature As Features.Feature = Nothing
        Dim extractFaceBuilder1 As Features.ExtractFaceBuilder
        extractFaceBuilder1 = workPart.Features.CreateExtractFaceBuilder(nullFeatures_Feature)
        extractFaceBuilder1.ParentPart = Features.ExtractFaceBuilder.ParentPartType.WorkPart
        extractFaceBuilder1.Associative = True
        extractFaceBuilder1.FixAtCurrentTimestamp = True
        extractFaceBuilder1.HideOriginal = False
        extractFaceBuilder1.Type = Features.ExtractFaceBuilder.ExtractType.Face
        extractFaceBuilder1.InheritDisplayProperties = False
        extractFaceBuilder1.SurfaceType = Features.ExtractFaceBuilder.FaceSurfaceType.PolynomialCubic
        Dim added1 As Boolean
        added1 = extractFaceBuilder1.ObjectToExtract.Add(face1)
        extractedfeat1 = extractFaceBuilder1.Commit
End Sub

 

Frank Swinkels