I`m trying to find a way how to get coordinates for each triangular facet face.
I think i able to get quantity and type of faces in facetbody by this below:
For Each facet As NXOpen.Facet.FacetedBody In workPart.FacetedBodies
Dim fACETLIST As NXOpen.Facet.FacetedFace()
For i As Integer=0 To fACETLIST.Length-1
Catch ex As Exception
that gives me output like 30 facet and type of each one.
But how to get vertex values??
I need these outputs for creation new surfaces (it`s also question how) instead facet triangulars in order to make sew for solid body instead unselectable facetbody.
thanks in advance!
Solved! Go to Solution.
You should be able to use .GetEdges() on the FacetedFace to get the FacetedEdges, and then .GetVertices() on the FacetedEdge to get the Vertices.
However, if you want to be able to use the faceted body for NX features, you could try to convert it to a 'convergent' type facet body using the "Convert Facet Body" feature. That might give you what you need.
I agree with suggestion from NikolasLosse
Converting geometry to Convergent is the best way to use it directly in Sew feature.
If you still want to get the vertices on NX Facet Body, then following API helps
UF_FACET_ask_vertices_of_facet(nxFacetBody->Tag(), im, &num_vertices, vertices);
Thanks for proposals to Both.
But firstly I`m using nx10 where convergentbody isn`t work as i know, and this nxopen class is written for nx11. (or am i wrong?). Also I starting to think that what I got by GetFaces() method is not what i intend to find: it seems that it just faces of the facetbody and it`s not triangular facets. Because when I got output of type of the faces there were:
planar and so on.
My idea to collect all data from facetfaces and build new surfaces for sew in order to get usable solid/sheet body,
but now i don`t understand where to find facetfaces for rebuilding new solid instead.
Do you have any general idea?
Is these faces what i got from Getfaces() is rigth approach?
Ok, NX10 might not have convergent type facet bodies yet - shame.
If you just need the facet coordinates, the function @ParamveerPatil mentioned should help you out.
NX10 should already have NX type and JT type facet bodies, I think the UF.Facet functions only work on NX type.
If you need more - e.g. face normals at the facets, you can also get that using UF.Facet. Here's some code in Python that I use - should put you on the right track even if you use a different language.
def getNxFacetBodyFacetIds(body): """Get the facet IDs for a given NX type facet body. Note that there are three types of facet body (NX, Jt, Convergent) and this method only works for NX type. Args: body (NXOpen.Facet.FacetedBody) Returns: list: list of facet IDs (int) """ theUfSession = NXOpen.UF.UFSession.GetUFSession() facet_id = NXOpen.UF.UFConstants.UF_FACET_NULL_FACET_ID tag = body.Tag facet_id_list = list() for i_facet in range(theUfSession.Facet.AskNFacetsInModel(tag)): facet_id = theUfSession.Facet.CycleFacets(tag, facet_id) facet_id_list.append(facet_id) return facet_id_list def getNxFacetBodyVertices(body): """Get a list of all unique vertices in a NX type facet body, along with lists of the normal of those vertices plus lists of the facet_id and vertex_id of the vertex. Note that there are three types of facet body (NX, Jt, Convergent) and this method only works for NX type. Args: body (NXOpen.Facet.FacetedBody) Returns: list: list of dict with keys vertex, normal, facet_id, vertex_id """ theUfSession = NXOpen.UF.UFSession.GetUFSession() facet_id_list = getNxFacetBodyFacetIds(body) vertex_dict_list =  vertex_list =  for facet_id in facet_id_list: _, vertices = theUfSession.Facet.AskVerticesOfFacet(body.Tag, facet_id) _, normals = theUfSession.Facet.AskNormalsOfFacet(body.Tag, facet_id) for vertex_id, (vertex, normal) in enumerate(zip(vertices, normals)): if vertex not in vertex_list: d = dict() d['vertex'] = vertex d['normal'] = normal d['facet_id'] = facet_id d['vertex_id'] = vertex_id vertex_dict_list.append(d) vertex_list.append(vertex) return vertex_dict_list
I think what @Yamada said is absolutely correct - you are about to put a lot of work into something. Maybe try to find an existing solution first.
Does you NX version have the "fit surface" feature? That can create a body from a facet body. The result can be rather less pretty than one would hope for, but it might be a good start.
I shart to think as well after I counted all vercites in small simple facet body. Its huge amount of data, and would be too long compare to desired result and needs. Moreover, after that cycle of verticies NX close after running. I raised an issue with that by the way.
Yes in nx10 fit surface on board. Also I saw NXOpen.Facet.ConvertFacetBodyBuilder created in NX10.
Do you know its possible to get convergent body from NXfacet?
Yes, the "convert facet body" feature does exactly that! It allows you to convert any facet body type into any other (NX, JT, convergent)