Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal Questions

Status
Not open for further replies.

adl12

Mechanical
Mar 28, 2012
6
I have a few journals that I would like to make more useful, but I am running into dead ends. I am guessing that several of these are not possible, but it is worth asking. I am using NX 7.5

1. Switching between applications (Drafting/Modeling)
2. Update Parts List in drawing. It seems that anything todo with tables is not recorded.
3. After exporting a PDF, open it in Adobe so I dont have to go find it in Teamcenter.

Thanks
 
Replies continue below

Recommended for you

[ol][li]Switching between applications: limited ability to do so has been added to NX 8, not possible in 7.5 or below. I have written journals that use drafting and/or modeling functions and they work no matter what application the journal is started from (so long as I have the proper license to use the functionality). I have not done much programming with CAM or other application functionality, so I can't confirm that is true across the board.[/li][li]Use UF functions, here is some sample code:
Code:
[COLOR=blue]Option[/color] [COLOR=blue]Strict[/color] [COLOR=blue]Off[/color]  
[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  
[COLOR=blue]Imports[/color] NXOpen.UF  

[COLOR=blue]Module[/color] Module1  

    [COLOR=blue]Sub[/color] Main()  

        [COLOR=blue]Dim[/color] theSession [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
        [COLOR=blue]Dim[/color] ufs [COLOR=blue]As[/color] UFSession [COLOR=blue]=[/color] UFSession.GetUFSession()  
        [COLOR=blue]Dim[/color] lw [COLOR=blue]As[/color] ListingWindow [COLOR=blue]=[/color] theSession.ListingWindow  
        lw.Open()  

 [COLOR=green]'update all parts lists[/color]
 [COLOR=green]'ufs.Plist.UpdateAllPlists()[/color]

 [COLOR=green]'alternate method, useful if there are multiple parts lists but you only want to update certain ones[/color]
        [COLOR=blue]Dim[/color] myPListTags() [COLOR=blue]As[/color] Tag [COLOR=blue]=[/color] [COLOR=blue]Nothing[/color]  
        [COLOR=blue]Dim[/color] numberOfPlists [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  
 [COLOR=green]'return array of tags of all parts lists in file[/color]
        ufs.Plist.AskTags(myPListTags, numberOfPlists)  
        lw.WriteLine("Number [COLOR=blue]of[/color] Parts Lists: " [COLOR=blue]&[/color] numberOfPlists)  
        [COLOR=blue]For[/color] [COLOR=blue]Each[/color] listTag [COLOR=blue]As[/color] Tag [COLOR=blue]In[/color] myPListTags  
            lw.WriteLine("  Tag: " [COLOR=blue]&[/color] listTag.ToString)  
            ufs.Plist.Update(listTag)  
        [COLOR=blue]Next[/color]  

        lw.Close()  

    End [COLOR=blue]Sub[/color]  


    [COLOR=blue]Public[/color] [COLOR=blue]Function[/color] GetUnloadOption(ByVal dummy [COLOR=blue]As[/color] [COLOR=blue]String[/color]) [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  

 [COLOR=green]'Unloads the image when the NX session terminates[/color]
        GetUnloadOption [COLOR=blue]=[/color] NXOpen.Session.LibraryUnloadOption.AtTermination  

    End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]
[/li][li]Here is some sample code for pdf files on disk (I'm not sure what happens if the pdf is stored in a teamcenter dataset, I don't currently have TC to test with):
Code:
[COLOR=blue]Option[/color] [COLOR=blue]Strict[/color] [COLOR=blue]Off[/color]  
[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  

[COLOR=blue]Module[/color] Module1  

    [COLOR=blue]Sub[/color] Main()  

        [COLOR=blue]Dim[/color] theSession [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
        [COLOR=blue]Dim[/color] lw [COLOR=blue]As[/color] ListingWindow [COLOR=blue]=[/color] theSession.ListingWindow  
        lw.Open()  

 [COLOR=green]'change following variable to point to a valid pdf file on your system[/color]
        [COLOR=blue]Dim[/color] pdfToOpen [COLOR=blue]As[/color] [COLOR=blue]String[/color] [COLOR=blue]=[/color] "C:\temp\test.pdf"  
        [COLOR=blue]Try[/color]  
            Diagnostics.Process.Start(pdfToOpen)  
        [COLOR=blue]Catch[/color] ex [COLOR=blue]As[/color] ApplicationException  
            lw.WriteLine(ex.ToString [COLOR=blue]&[/color] " : " [COLOR=blue]&[/color] ex.Message)  
        End [COLOR=blue]Try[/color]  

        lw.Close()  

    End [COLOR=blue]Sub[/color]  



    [COLOR=blue]Public[/color] [COLOR=blue]Function[/color] GetUnloadOption(ByVal dummy [COLOR=blue]As[/color] [COLOR=blue]String[/color]) [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  

 [COLOR=green]'Unloads the image when the NX session terminates[/color]
        GetUnloadOption [COLOR=blue]=[/color] NXOpen.Session.LibraryUnloadOption.AtTermination  

    End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]
[/li][/ol]

 
Thanks!
Those were both very helpful. Unfortunately I can't figure out how to get it to find the Teamcenter path when opening PDFs.
I know our manifestations use the format
@DB/12345678/A/manifestation/12345678_A_dwg and that works with
theSession.Parts.OpenBaseDisplay(), but I have tried every possible combination and I can't get Diagnostics.Process.Start()
to find a PDF in teamcenter.
I tried using PDM.FileManagement.ExportFiles(.. to export the pdf to a temp folder then open it, but I am not smart enough to get ExportFiles working.
 
Hi guys,
yep anything with tables is not recorded. So I've got question how to sort table by journal? Or how I can get all functions assigned to "ufs.Plist"? I know NXOpen API Reference... but where exactly?
 
NXOpen.UF Namespace -> UFPlist Class
If you find something useful by using the search function, you can then press the "Locate" button and it will expand the contents list to show you where it is located within the help structure.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor