Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hi Guys,
I need to change Drawing Sheet format Using VB.NET, I tried with below coding and I am getting error while “session.retrievemodel(desc)” run.
Dim Desc as IpfcModelDescriptor
Dim Sheetdt as IpfcSheetData
Dim Sheetfrmt as IpfcDrawingFormat
Dim Session as IpfcBaseSession
Desc = (New CCpfcModelDescriptor).CreateFromFileName(“a4_format.frm”)
Sheetfrmt = session.Retrievemodel(Desc)
Error Msg:
At pfcls.IpfcBaseSession.RetrieveModel(IpfcModelDescriptor_MdlDescr).
Please help me to solve and further process.
Thanks
Is the format model in the working directory/workspace or on a search path? There is no more information in the error msg?
Hi Tomas,
Sorry for delay reply.
I was moved to another project, and i started a creo project now.
I have attached my coding for your reference, as per your instruction i mention the frm file path and tried but i am getting below error while assign the "fdescr = (New CCpfcModelDescriptor)."
Please help me to solve.
Coding:
If Not lmoddoc Is Nothing Then
Dim x As Integer
Dim sheets As Integer
Dim sheetdata As IpfcSheetData
Dim sheetformat As IpfcDrawingFormat
Dim drwonr As IpfcSheetOwner
Dim fdescr As IpfcModelDescriptor
Dim drw As pfcls.IpfcDrawing
Dim drwl As IpfcLayout
Dim bsession As IpfcBaseSession
Dim drawing As IpfcDrawing
lmoddoc.Display()
session.CurrentWindow.Activate()
model = session.CurrentModel
drawing = CType(model, IpfcDrawing)
fdescr = (New CCpfcModelDescriptor).CreateFromFileName("C:\Program Files\PTC\Creo 2.0\Common Files\F000\creo_standards\formats\a4_format.frm")
Dim fmt As IpfcDrawingFormat
fmt = session.RetrieveModel(fdescr)
drwonr = CType(drawing, IpfcSheetOwner)
drwonr.SetSheetFormat(1, fmt, 1, Nothing)
End If
Error:
According to VB API documentation the file name should be of the form "<name>.<extension>".
The problem is probably that you have full path.
Hi Tomas,
Thanks for help, and i applied with your info(without full path), Its working. But if i try to retrievemodel it show error
Code:
Dim fdescr As IpfcModelDescriptor = (New CCpfcModelDescriptor).CreateFromFileName("a4_format_portrait.frm")
model = session.GetModelFromDescr(fdescr)
Dim fmt As IpfcDrawingFormat
fmt = session.RetrieveModel(fdescr)
drwonr = CType(drawing, IpfcSheetOwner)
drwonr.SetSheetFormat(1, fmt, 1, Nothing)
Hi Balaji,
what error it shows? Is the model in the working directory or on a search path?
Regards,
Tom
Hi Tomas,
Thanks for help, and i applied with your info(without full path), Its working. But if i try to retrievemodel it show error(fmt = session.RetrieveModel(fdescr))
Code:
Dim fdescr As IpfcModelDescriptor = (New CCpfcModelDescriptor).CreateFromFileName("a4_format_portrait.frm")
model = session.GetModelFromDescr(fdescr)
Dim fmt As IpfcDrawingFormat
fmt = session.RetrieveModel(fdescr)
drwonr = CType(drawing, IpfcSheetOwner)
drwonr.SetSheetFormat(1, fmt, 1, Nothing)
Please confirm whether my code is correct or wrong when i try to retrievemodel
Error:
Is the file "a4_format_portrait.frm" in the working directory?
Hi Tomas,
Model is in working directory only i given. But i got above error(image).
Thnks
I am sorry, but I don't know now, the general error is strange. Other models (parts, drawings) are retrieved correctly?
Hi Tomas,
"a4_format_portrait.frm" is loaded in my current working directory only.
My scope is i want to change the drawing sheet format (A4 to A3 and A3 to A4) or if it is possible to update current drawing sheet width and height, its very useful.
If you have any idea, please share with me.
Thnks