Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Extraction of surface data from FacetedBody in C++

Hi everyone,

I am currently having some issues with the NXOpen API, maybe someone here is able to help me...

I am using the code below to extract surface data from FacetedBody objects, but all I get is an exception (type NXExceptionInvalid) saying "Invalid object type for this operation" for every single value of i...

NX Version is 10.0

 

parameter const boost::shared_ptr<NXOpen::Facet::FacetedBody>& facetedBodySP

int numberFaces = facetedBodySP->NumberOfFaces(); NXOpen::Point3d position(0.,0.,0.); NXOpen::Point3d dir(0., 0., 0.); double radius = 0.; double angle = 0.;
bool sense = false;

for (int i = 0; i < numberFaces; i++) {
((facetedBodySP->GetFaces())[i])->GetSurfaceData(&position, &dir, &radius, &angle, &sense);
}

 Many thanks in advance

14 REPLIES

Re: Extraction of surface data from FacetedBody in C++

You cannot get surface data from a facet, you can only get the vertexes and the direction of the facet.

You can only use the methods of the Facet namespace, if I remember correctly.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Extraction of surface data from FacetedBody in C++

[ Edited ]

Thanks for your reply. Hm okay.. according to both Intellisense and the Reference Guide, the only available members are edges and faces. It tells me I can access the vertices through the edges, however, as soon as I try to access the edges the same exception is thrown. I cannot even ask for the number of edges... at least that worked for the faces.

Solution
Solution
Accepted by topic author DennisWeir
‎06-08-2017 12:48 PM

Re: Extraction of surface data from FacetedBody in C++

I think the NXOpen.Facet namespace is only valid for faceted bodies derived from solid bodies, where the solid is still available.

I use the UF_FACET_... functions to handle STL imports, see the STLtoSolid attachment.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Extraction of surface data from FacetedBody in C++

[ Edited ]

Thanks a lot, now it doesn't crash anymore! It doesn't find any facets, but that's a different problem... Return code is always 1105000, but that number is too low for any of the defined error codes I found.

Re: Extraction of surface data from FacetedBody in C++

[ Edited ]

What kind of faceted body is this, STL or JT?NxStlImport.PNG

 

 NX Facets have been easier to handle and are the only ones to be used with CAM.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Extraction of surface data from FacetedBody in C++

Under properties->general->information it says

 

Type                 Facet Body
Facet Body           Decimated Facet Body_faceted body
Number of Facets     12406

 

It's already in a prt file.

Re: Extraction of surface data from FacetedBody in C++

A faceted body that works for me has the following object information (Ctrl+I {upper case i}):

Type                 Facet Body
 
Information Units    mm
Facet Body           faceted body
 
Status               Disassociated
Tolerance specification origin is unknown 
Tolerances           
Surface Angular      =       0.000000000
Surface Distance     =       0.000000000
Curve Distance       =       0.000000000
Curve Angular        =       0.000000000
Curve Maximum Length =       0.000000000
Precision            Single
Maximum Facet Size   =       0.000000000
 
Convex Facets        No
Max Facet Edges      0
 
Number of Facets     9931

If you hit Ctrl+I (upper case i), select the faceted body and hit OK, what information is shown?

The number of facets doesn't matter.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Extraction of surface data from FacetedBody in C++

 

Type                 Facet Body

Information Units    mm
Facet Body           faceted body
 
Status               Disassociated
Tolerance specification origin is unknown 
Tolerances           
Surface Angular      =       0.000000000
Surface Distance     =       0.000000000
Curve Distance       =       0.000000000
Curve Angular        =       0.000000000
Curve Maximum Length =       0.000000000
Precision            Single
Maximum Facet Size   =       0.000000000
 
Convex Facets        No
Max Facet Edges      0
 
Number of Facets     5445640

That's mine. I noticed that the model I used before was decimated - therefore the old Facet Body value. After changing the model it still doesn't work though, UF_FACET_ask_num_faces returns 0.

 

I use the NXOpen::Facet::FacetedBody.Tag() as the model tag, is that correct? That's about what the code looks like.

 

tag_t mtag = facetedBodySP->Tag();
UF_FACET_ask_n_facets_in_model(mtag, &fnum)
int fID = UF_FACET_NULL_FACET_ID;
UF_FACET_cycle_facets(mtag, &fID);
while (fID != UF_FACET_NULL_FACET_ID) {
   UF_FACET_ask_num_verts_in_facet(mtag, fID, &fnum);
   UF_FACET_ask_vertices_of_facet(mtag, fID, &fnum, (double(*)[3])verts);
... UF_FACET_cycle_facets(mtag, &fID); }

 

Re: Extraction of surface data from FacetedBody in C++

What is the selection mask set to?

From the example linked to above, I set it as follows:

Dim BodyMask(0) As Selection.MaskTriple

With BodyMask(0)
	.Type = UF.UFConstants.UF_faceted_model_type
	.Subtype = 0
	.SolidBodySubtype = 0
End With

If nothing helps, I would contact GTAC, since it might be a problem in their code.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community