Skip to main content
20-Turquoise
January 15, 2013
Question

How do I plot a drawing to a postscript file using jlink?

  • January 15, 2013
  • 2 replies
  • 1249 views
Wildfire 5.0 M170

I am looking for some example jlink code that will print/plot a drawing to a postscript file.
The following 2 links show examples for creating a pdf export:but I can't seem to find anything for creating a postscript file.

ModelDescriptor descr = pfcModel.ModelDescriptor_Create(ModelType.MDL_DRAWING, partNumber, null);
Model dwg = session.RetrieveModel(descr);
Window window = session.CreateModelWindow(dwg);
dwg.Display();//This part works because the drawing is opened and displayed
PrinterInstructions pi = pfcExport.PrinterInstructions_Create();
PrintPrinterOption po = pfcExport.PrintPrinterOption_Create();
po.SetFileName(partNumber);
po.SetPrinterType("postscript");
po.SetPenTable("stdps.pnt");
po.SetSaveToFile(true);
po.SetSendToPrinter(false);
pi.SetPrinterOption(po);
dwg.Export(partNumber, pi);//ProEngineer crashes when executing this statement


The "abc" drawing is opened and displayed however the Pro/Engineer session crashes when executing dwg.Export(). If I comment that out the session does not crash.

I have no idea if what I am trying is even close to what is correct. Does anybody have any hints to get me started?

Thanks

--

This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

2 replies

10-Marble
January 16, 2013
Try to use full path for both SetFileName() and SetPenTable() methods.
There might be useful information in any exception thrown from the application as well.

/Bjarne
20-Turquoise
February 15, 2013
Updates on this question. I opened a case with PTC which resulted in 2 new articles in their
Knowledge Base and some key word additions to 2 existing articles so they are more likely to be
found when searching. These are good articles with that also contain the most important items: code
examples

The list of articles follows. The last 2 are new and the first 2 were already created when I was
having this issue.

  * CS78845 <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS78845>
      o How to display retrieved models in a new window through JLink for Creo Parametric
        <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS78845>
  * CS95315 <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS95315>
      o While printing drawing models, calling Model.Export() on a drawing in inactive window fails
        with exception "pfcExceptions::XToolkitBadInputs" in JLink for Creo Parametric
        <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS95315>
  * CS115415 <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS115415>
      o Model.Export() randomly throws XToolkitGeneralError exception on every other drawing when
        used in a loop to plot multiple drawing files through a synchronous *JLink* application for
        Creo Parametric. <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS115415>
  * CS111626 <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS111626>
      o Example code to plot drawing files to *POSTSCRIPT* through *JLink* for Creo Parametric
        <">https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS111626>