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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Replace format with vartiable format using JLink

dgarcia
11-Garnet

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
1 ACCEPTED SOLUTION

Accepted Solutions
rghadge
15-Moonstone
(To:dgarcia)

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
rghadge
15-Moonstone
(To:dgarcia)

@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
11-Garnet
(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

rghadge
15-Moonstone
(To:dgarcia)

@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
11-Garnet
(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

rghadge
15-Moonstone
(To:dgarcia)

@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
11-Garnet
(To:rghadge)

I have done so, thank you!

rghadge
15-Moonstone
(To:dgarcia)

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.

Top Tags