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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

how to CREATE part or parameter using vba

pkuu
2-Explorer

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 3
TomasLoun
12-Amethyst
(To:pkuu)

Hi Pete,

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

Regards,

Tom

pkuu
2-Explorer
(To:pkuu)

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

TomasLoun
12-Amethyst
(To:pkuu)

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

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags