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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

how to CREATE part or parameter using vba

pkuu
2-Guest

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
4-Participant
(To:pkuu)

Hi Pete,

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

Regards,

Tom

pkuu
2-Guest
(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
4-Participant
(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

Top Tags