cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Replace format with vartiable format using JLink

dgarcia
12-Amethyst

Replace format with vartiable format using JLink

I am using Creo Parametric Release 7.0 and Datecode7.0.4.0

I need to replace the drawing format of sheet 2 of my drawing with Custom Size, 1x1 mm, format. Using JLink
ACCEPTED SOLUTION

Accepted Solutions

Use below available J-Link functions (OTK Java):

  1. wfcModel.FormatSizeData.GetWidth()
  2. wfcModel.FormatSizeData.SetWidth()
  3. wfcModel.FormatSizeData.GetHeight()
  4. wfcModel.FormatSizeData.SetHeight()

Note: Above functions will need OTK Java licenses to use in Creo Parametric. For J-Link users, macros can be used as a workaround.

View solution in original post

7 REPLIES 7

@dgarcia,

  1. Use J-Link function pfcSheet.SheetOwner.SetCurrentSheetNumber() to set current drawing sheet.
  2. Use J-Link function pfcSheet.SheetOwner.SetSheetFormat() to set new or replace existing drawing format with new format.
dgarcia
12-Amethyst
(To:rghadge)

Thanks for the help, but I'm stuck with the function:

voidSetSheetFormat(int SheetNumber, DrawingFormat Format, /*optional*/ Integer FormatSheetNumber, /*optional*/ Model DrawingModel)

How do I define parameter Format ? I need a variable sheet, and there is no format defined for that. And null does not work

@dgarcia,

 

Below sample code changes the format of sheet# 1 in session and uses an existing .frm stored in the working directory
ModelDescriptor desc = null;
session.GetCurrentWindow().Activate();
desc = pfcModel.ModelDescriptor_CreateFromFileName("a0_iso.frm");
desc.SetPath (""); //frm file is stored in the working directory, set your own format folder path here
DrawingFormat format = (DrawingFormat) session.RetrieveModelWithOpts(desc, pfcSession.RetrieveModelOptions_Create());
cur_drw.SetSheetFormat(1, format, null, null); //applies to the first sheet

Note:
The Method SetSheetFormat() is designed only to insert a new format sheet in a drawing sheet This method is not designed to replace or remove existing drawing tables that are copied in to drawing from previous format.
Users should identify and remove the old drawing tables using pfcTable.CheckIfIsFromFormat() and DeleteTable() Example Code Snippet: Tables tables = drw.ListTables(); System.out.println("tables info" + tables.toString()); for (int i = 0; i < tables.getarraysize(); i++) { Table table = tables.get(i); System.out.println("table" + table); if (table.CheckIfIsFromFormat(drwSheetNum) == true) { drw.DeleteTable(table, Boolean.FALSE); } }

dgarcia
12-Amethyst
(To:rghadge)

Thank you again but this does not solve my problem.

I want to assign a Variable format with size 1x1, without using any ".frm" for that

I tried:

DrawingFormat drawingFormat = null;
drawing.SetSheetFormat(2, drawingFormat, null, null);  // this fails

I changed the format manually to variable and read it:

DrawingFormat drawingFormat = drawing.GetSheetFormat(2);

Interestingly the value of drawingFormat is null

And I tried to set the value of width and height to 1:

drawing.GetSheetData(2).SetHeight(1);
drawing.GetSheetData(3).SetWidth(1);

But it does not work (documentation says GetSheetData is deprecated)

If I don't find a way to do this JLink I will try to do it with mapkeys

@dgarcia

I would suggest to log a case with PTC Technical Support explaining your use case and share details of what you tried. So that, it can further investigated.

dgarcia
12-Amethyst
(To:rghadge)

I have done so, thank you!

Use below available J-Link functions (OTK Java):

  1. wfcModel.FormatSizeData.GetWidth()
  2. wfcModel.FormatSizeData.SetWidth()
  3. wfcModel.FormatSizeData.GetHeight()
  4. wfcModel.FormatSizeData.SetHeight()

Note: Above functions will need OTK Java licenses to use in Creo Parametric. For J-Link users, macros can be used as a workaround.

Announcements
NEW Creo+ Topics: PTC Control Center and Creo+ Portal


Top Tags