Skip to main content
Jan 17, 2017 3:58 PM UTC
Question

how to CREATE part or parameter using vba

my code doesn work

Private Sub CommandButton8_Click()

Dim asynconn As New pfcls.CCpfcAsyncConnection

Dim conn As pfcls.IpfcAsyncConnection

Dim session As pfcls.IpfcBaseSession

'Make an asynchronous connection with Pro/ENGINEER

Set conn = asynconn.Connect("", "", ".", 5)

'Get the current session

Set session = conn.session

Dim cmodel As IpfcModel

Dim modelDesc As IpfcModelDescriptor

Dim CModelDscr As New CCpfcModelDescriptor

Dim componentModel As IpfcSolid

Set modelDesc = CModelDscr.CreateFromFileName("partmodel.prt")

Set componentModel = session.GetModelFromDescr(modelDesc)

conn.Disconnect (1)

End Sub

3 replies

Jan 18, 2017 9:34 AM UTC

Hi Pete,

could you please describe it more? What does not work? Is there any error message?

Regards,

Tom

pkuuAuthor
Jan 18, 2017 8:17 PM UTC

Hi Tomas

i want do new part using any template, take it active and create new parameter.

My code doesnt create partmodel.prt insession. Error message doesnt see after run this code. But code row

Set componentModel = session.RetrieveModelFromDescr(modelDesc) gave error message

run-time error -2147352567(80020009)

    pfcExceptions::XToolkitGeneralError

Jan 19, 2017 8:05 AM UTC

It is strange. The connection to the Creo is ok? You have there only 5 s timeout which is too short I think.

I would recommend to extend it to 20s or to leave it empty - asynconn.Connect(Nothing, Nothing, Nothing, Nothing)

Then I would try to call another function - change working directory or something to check if the connection is working correctly and finally to retrieve another model, check the model is in the working directory or on a search path