Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal opening draft

Status
Not open for further replies.

Lars1978

Mechanical
Dec 30, 2015
327
0
0
NL
Hi All,

I'm looking for a journal which opens the draft of a model. I'm working native with master model drafts.
This draft is in the same directory and has the "_dwg1" addition to his name.

Can anyone help me with this journal, I wont be the first to have this question [bigglasses]

Lars


Lars
Solid Edge
Inventor
NX10.0.3.5 native
 
Replies continue below

Recommended for you

Hi,
Try this code.

Code:
// NX 9.0.3.4
//
using System;
using NXOpen;

public class NXJournal
{
  public static void Main(string[] args)
  {
    Session theSession = Session.GetSession();
    Part workPart = theSession.Parts.Work;
    Part displayPart = theSession.Parts.Display;
  
    string partPath = workPart.FullPath;

     string partFolderPath = System.IO.Path.GetDirectoryName(partPath);

     string partName = System.IO.Path.GetFileNameWithoutExtension(partPath);

     string draftFileName = System.IO.Path.Combine(partFolderPath, partName + "_dwg1.prt");

            if (System.IO.File.Exists(draftFileName))
            {
                PartLoadStatus status;
                theSession.Parts.OpenDisplay(draftFileName, out status);
                status.Dispose();
            }
            else
            {
                NXOpen.UI.GetUI().NXMessageBox.Show("Part not found", NXMessageBox.DialogType.Error, draftFileName + " does not exist");
            }
    
  }
  public static int GetUnloadOption(string dummy) { return (int)Session.LibraryUnloadOption.Immediately; }
}

Thanks,
Selvaraj Chellamuthu
NX Automation Engineer
NX 9 | Teamcenter 10
 
SelvarajC,

Thank you for your quick reaction.

When I paste this code into a journal I get al kind of errors. Can you please send the journal file ?

Thnx.

Lars


Lars
Solid Edge
Inventor
NX10.0.3.5 native
 
Hi,
Copy this code and paste it in empty text file and save the file with .cs extension.
If you get any error upload the error message snaps.

Thanks,
Selvaraj Chellamuthu
NX Automation Engineer
NX 9 | Teamcenter 10
 
Status
Not open for further replies.
Back
Top