Skip to main content
1-Visitor
Nov 23, 2016 5:49 AM UTC
Question

Change Drawing Sheet format Using VB.NET (Sheet Setup)

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

10 replies

1-Visitor
Nov 23, 2016 8:52 AM UTC

Is the format model in the working directory/workspace or on a search path? There is no more information in the error msg?

Translate
1-Visitor
Jan 2, 2017 10:05 AM UTC

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:

drafrm-err.png

Translate
1-Visitor
Jan 3, 2017 12:34 PM UTC

According to VB API documentation the file name should be of the form "<name>.<extension>".

The problem is probably that you have full path.

Translate
1-Visitor
Jan 4, 2017 9:51 AM UTC

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:

drafrm-err-1.png

Translate
1-Visitor
Jan 4, 2017 10:02 AM UTC

Is the file "a4_format_portrait.frm" in the working directory?

Translate