×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Open API, problem with plot

Open API, problem with plot

Open API, problem with plot

(OP)
Hello,
I'm new of the forum and NXOpen/C#, I'm try to write a command utility to plot in pdf a UGS/NX3 drawing, but I hit some problems and due to my poor experience I'm not able to fix it.

My first attempt was to create a CGM to PDF converter, but I realize is not possible to do.

So the second attempt was open a .prt drawing then convert in pdf, but here I got 2 problem

1) I was unable to do Plot.SaveCgm due to this error:
Unhandled Exception: NXOpen.NXException: NX error status: 1105012
at NXOpen.UF.UFPlot.SaveCgm(Tag drawing_sheet, JobOptions& job_options, String job_name, BannerOptions& banner_options, String cgm_file_name)
at cgm2jpg.CGM2IMAGEConverter..ctor(String[] args) in D:\User Profiles\apelle\My Documents\Visual Studio 2005\Projects\cgm2jpg\cgm2jpg\CGM2IMAGECon
verter.cs:line 88
at cgm2jpg.CGM2IMAGEConverter.Main(String[] args) in D:\User Profiles\apelle\My Documents\Visual Studio 2005\Projects\cgm2jpg\cgm2jpg\CGM2IMAGEConv
erter.cs:line 115

2) I use as pre-condition and existing CGM file and then try to print to file with: Plot.PrintFile, no error seems to be riese but no output will write. Here the log of NXPlot
26 Mar, 2008 14:16:17:BPS: SUBMIT_TIME
26 Mar, 2008 14:16:17:BPS: Job 0 Submitted
26 Mar, 2008 14:16:17:BPS: Sending bSec ...
26 Mar, 2008 14:16:17:BPS: Sending bPrintTo ...
26 Mar, 2008 14:16:17:BPS: Sending myModel ...
26 Mar, 2008 14:16:17:BPS: Sending myPlotter ...
26 Mar, 2008 14:16:17:BPS: Sending myProfile ...
26 Mar, 2008 14:16:17:BPS: Sending C:\Temp\3455603_ug_drw.cgm ...
26 Mar, 2008 14:16:17:BPS: QUEUE_TIME
26 Mar, 2008 14:16:17:BPS: Job Ready to Run
26 Mar, 2008 14:16:17:BPS: RUN_TIME
Wed Mar 26 14:16:17 2008

BPSPLOT: 1.0012 Windows NT 4.0COMMAND_LINE :"apelle" "PDFPlotter" "myProfile" "3455603_ug_drw.cgm":
Input FILE - 3455603_ug_drw.cgm (PASS)
Bypass Lic B ---------------------------- B -sdil329736934
Connect Method: CONNECT_EXECUTE
Queue_Name: ()
CMD_EXE: ( "3455603_ug_drw.cgm")
Exec Return A 0 226 Mar, 2008 14:16:17:BPS: DONE_TIME


APPENDING STATS FILE

26 Mar, 2008 14:16:17:BPS: SUBMIT_TIME
26 Mar, 2008 14:16:17:BPS: QUEUE_TIME
26 Mar, 2008 14:16:17:BPS: RUN_TIME
26 Mar, 2008 14:16:17:BPS: DONE_TIME


END OF STATS FILE

26 Mar, 2008 14:16:21:BPS: Downloading logfile.txt ...



Thanks in advance for you support.
Alfredo


My Code:
using System;
using System.Collections.Generic;
using System.Text;
using NXOpen;
using NXOpen.UF;

using System.Runtime.InteropServices;
using NXOpen.Drawings;


namespace cgm2jpg
{
class CGM2IMAGEConverter
{
static Session m_session;
static Random r = new Random();
static UFSession m_openSession;



public CGM2IMAGEConverter(string[] args)
{


m_session = Session.GetSession();


m_openSession = UFSession.GetUFSession();



System.Console.WriteLine("m_session :" + m_session.ToString());
if (m_session == null)
System.Console.WriteLine("m_session NULLA");
else
System.Console.WriteLine("m_session NON NULLA");

System.Console.WriteLine("m_openSession :" + m_openSession.ToString());
if (m_openSession == null)
System.Console.WriteLine("m_openSession NULLA");
else
System.Console.WriteLine("m_openSession NON NULLA");




PartLoadStatus pls;
Part p = m_session.Parts.Open("c:\\temp\\3459923_ug_drw.prt", out pls);


DrawingSheet[] dss = p.DrawingSheets.ToArray();
Console.WriteLine("Sheet number: " + dss.Length);
int i = 1;
foreach (DrawingSheet dw in dss)
{
Console.WriteLine(i++ + ": Altezza: " + dw.Height + " Larghezza: " + dw.Length);
UFPlot.JobOptions jo = new UFPlot.JobOptions();
jo.use_drawing_sheet_colors = false;
jo.use_drawing_sheet_widths = true;
jo.tolerance = 1;
jo.colors = UFPlot.Colors.BlackOnWhite;

NXOpen.UF.UFPlot.BannerOptions bo = new UFPlot.BannerOptions();
bo.show_banner = false;
bo.message = "";

jo.widths = UFPlot.Widths.StandardWidths;



// Console.WriteLine("1 " + dw.Tag);
// Console.WriteLine("2 " + jo);
// Console.WriteLine("3 " + bo);


m_openSession.Plot.SetSessionBannerOptions(ref bo);
m_openSession.Plot.SetSessionJobOptions(ref jo);

int seed = r.Next(1000000000);

string fn_pdf = "C:\\temp\\filename_" + seed + ".pdf";
string fn_cgm = "C:\\temp\\filename_" + seed + ".cgm";


Console.WriteLine(fn_pdf);
Console.WriteLine(fn_cgm);

//m_openSession.Plot.SaveCgm(dw.Tag, ref jo, "To_Cgm: " + fn_cgm, ref bo, fn_cgm);

m_openSession.Plot.PrintFile("C:\\Temp\\3455603_ug_drw.cgm", "PDFPlotter", "ps_profile_0", 1);



//m_openSession.Plot.ConvertFile("c:\\temp\\3455603_ug_drw.cgm", UFPlot.Format.TiffFormat, "c:\\temp\\out.tiff");

//m_openSession.Plot.Print(dw.Tag, ref jo, "TIFF Export File 1", ref bo, "TIFF Export File", "DRETIFF", 1);


}

}




public static void Main(string[] args)
{
CGM2IMAGEConverter convert = new CGM2IMAGEConverter(args);


}

}



}


RE: Open API, problem with plot

(OP)
Attached to prev-post you can find and image of NXPlot Administrator, with my printer configured

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources