Cancel
Showing results for 
Search instead for 
Did you mean: 

NXOpen Python can't found the WorkPart

Experimenter
Experimenter

Hallo, 

i'm trying to extract the model history steps using NXOpen with Python and with the code form @cowski1 .

import NXOpen
import NXOpen.UF

theSession = NXOpen.Session.GetSession()
theLw = theSession.ListingWindow
theUfSession = NXOpen.UF.UFSession.GetUFSession()    
    
def main(): 

    workPart = theSession.Parts.Work
    
    markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "feature info")
    theLw.Open()    
    
    theLw.WriteLine("*** All features ***")
    
    for tempFeat in theSession.Parts.Work.Features:
        theLw.WriteLine(".GetFeatureName: " + tempFeat.GetFeatureName())
        theLw.WriteLine(".Name: " + tempFeat.Name)
        theLw.WriteLine(".IsInternal: " + str(tempFeat.IsInternal))
        theLw.WriteLine(".FeatureType: " + tempFeat.FeatureType)
        theLw.WriteLine("Type: " + str(type(tempFeat)))
        theLw.WriteLine(".Timestamp: " + str(tempFeat.Timestamp))
        theLw.WriteLine(".Suppressed: " + str(tempFeat.Suppressed))
                
        theLw.WriteLine("")
    
    theLw.Close()
    
    
if __name__ == '__main__':
    main()

i've created a simple block with a simple hole but it doesn't work cause there is no Workpart founded, could someone please help me out with that? 

 

Thanks

 

1.PNG2.PNG

 

 

3.PNG

 

2 REPLIES 2

Re: NXOpen Python can't found the WorkPart

Siemens Phenom Siemens Phenom
Siemens Phenom

@wkcshy , it's working fine when run interactively. Tested in NX1202.

Regards,
Samadhan

GTAC | NX Help: NX1102 | NX1202 | NX1847
Please mark post as an "Accepted Solution", if it answers your question/is more helpful!

Re: NXOpen Python can't found the WorkPart

Experimenter
Experimenter

im using NX11with Python3.4 but i've also tried with NX12 with Python3.6 and have the same problem

is there probably something wrong with the envoirment variable? could you have a look at my start up script?