cancel
Showing results for 
Search instead for 
Did you mean: 

parameter for facet surface data method?

Genius
Genius

I am trying to call the uf.facet.AskSurfaceDataForFace method in Python. What is the tag for "facetface" argument? I looked through the documentation and I cannot find a reference to this.

 

In the AskFaceIdofFacet method, I have used the model( tag) and the facet Id successfully. Below is my code

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

 

 

In the documentation below, "facet face" is reference only once

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/ugopen_doc...

 

       for facet_body in workPart.FacetedBodies:
            self.theLw.WriteLine("Facet Journal Identifier is " + str(facet_body.JournalIdentifier))
            
            #Get the facet Tag
            facet_tag=facet_body.Tag
            
            #this method does not work for some reason
            #faces_list=facet_body.GetFaces()
            
       ########end of loop###############3
        #create instance of your facet
        uf_facet=NXOpen.UF.Facet()

        
        #Get number of facets, use tag from NXOpen.Facet.FacetedBody attribute
        num_facets=uf_facet.AskNFacetsInModel(facet_tag)
       
        
        #loop through all the facets, 0 to num_facets
        for i in range(0, num_facets):
            #returns id the of the face, an int
            #arguments are model id for facet_tag and facet id for i
            
            face_id=uf_facet.AskFaceIdOfFacet(facet_tag, i)
            
             #what is the right argument to pass? tried facet_tag, face_id and the iterator i
            surface_data=uf_facet.AskSurfaceDataForFace(facetface?????)

 

6 REPLIES

Re: parameter for facet surface data method?

Genius
Genius

The GetFaces method in the first for loop should return an array/list of face tags but I get an "error return without exception set" error

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

Re: parameter for facet surface data method?

Siemens Phenom Siemens Phenom
Siemens Phenom

I have attached a small .VB test case that worked for me.  I made a block and blended four edges.  When I ran the attached, the ouput looked like this:

 

Found 1 FacetedBody objects
Faces for this body: 10
Radius: 0
Radius: 10
Radius: 10
Radius: 10
Radius: 0
Radius: 0
Radius: 0
Radius: 0
Radius: 0
Radius: 10

 

I saw an interesting note in the Open C docs in the UF_FACET chapter that said "note that face tags are stored only if "store_face_tags" is set to "true" when faceting a solid".

 

 

Re: parameter for facet surface data method?

Genius
Genius

Thanks @SteveLabout, I will try it out. Would you be able to post a link to that specific documentation? The python documentation doesn't have that note.

Re: parameter for facet surface data method?

Siemens Phenom Siemens Phenom
Siemens Phenom

I'm not sure how to get a link that will go right to it, but you can navigate to it in the Programming Tools docs.

 

Open up the Open C Reference Guide.  Select the uf_facet chapter from the long list on the left.

 

That note appears under both UF_FACET_ask_face_id_of_solid_face() and UF_FACET_ask_solid_face_of_facet().

 

The code I posted isn't calling either of those, but it seems like it might be an essential tidbit.

 

By the way, any time you are using a wrapper function - anything you call from the UFSession - we always suggest checking the Open C doc for the original function.  The majority of the info related to the function appears only in this guide - it is not carried over to the .Net, Python of Java docs.

Re: parameter for facet surface data method?

Genius
Genius

thanks again, 

 

 

i think i found the note that you are referring to. the "facet_face" parameter in the ask_surface_data_for_face function is only referenced once so not sure what it could be.

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/ugopen_doc...

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/ugopen++/i...

 

Re: parameter for facet surface data method?

Genius
Genius

@SteveLabout Thank you again for posting that code. I tried to recreate it in Python but I get an "error return without exception set" message when trying to call the thisFctBody.GetFaces() function

 

It should return an array/list.

 

 

import NXOpen
import NXOpen.BlockStyler
import NXOpen.Features
import NXOpen.UF
import NXOpen.GeometricAnalysis
import NXOpen.Facet


class facet_data:
    # Constructor for NX Styler class
    # ------------------------------------------------------------------------------
    def __init__(self):
        
        # class members
        self.theSession = None
        self.theUI = None
        self.theLw= None
        self.theDialogName = ""
        self.theDialog = None
        #Get the UF session
        self.theUfSession = None

        
        
     

        try:
            self.theSession = NXOpen.Session.GetSession()
            self.theUI = NXOpen.UI.GetUI()
            self.theLw = self.theSession.ListingWindow #create print window
            self.theUfSession = NXOpen.UF.UFSession.GetUFSession() 
            
        except Exception as ex:
            # ---- Enter your exception handling code here -----
            raise ex

    def gather_data(self):
        self.theLw.Open()
        self.theLw.WriteLine("Bring up console")
        
       
        global facet_tag, dispPart, workPart, faces_list, num_facets
        
        
        dispPart= self.theSession.Parts.Display
        workPart = self.theSession.Parts.Work
      
        for thisFctBody in dispPart.FacetedBodies: 
#Tag
facet_tag=thisFctBody.Tag

#this does not work, gives a "error return without exception set"
fctFaces=thisFctBody.GetFaces()

#this works and it is in the same method class thisFctBody.GetParameters() #from NXOpen.Facet.FacetedBody class for facet_body in workPart.FacetedBodies: #Tag facet_tag=facet_body.Tag self.theLw.WriteLine("Facet tag is " + str(facet_tag)) self.theLw.WriteLine("Number of Facets is " + str(facet_body.NumberOfFaces))

#this does not work, should return a list faces_list=facet_body.GetFaces() self.theLw.WriteLine("") self.theLw.WriteLine("") def main(): try: #create instance of class myfacet = facet_data() myfacet.gather_data() except Exception as ex: # ---- Enter your exception handling code here ----- NXOpen.UI.GetUI().NXMessageBox.Show("Block Styler", NXOpen.NXMessageBox.DialogType.Error, str(ex)) if __name__ == "__main__": main()