Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
How can I change parameter value with excel? I connected
excel with ProE using Proe4.0 VB API and now I am trying to
update parameter value with value from excel cell...
thx in advance
Hi
I'm working on the same subject.
I managed to get parameters values from ProE to Excel, but I still can't work it the other way. Here is my code, may it help you...
_________________________________________________
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim MyModel As IpfcModel
Dim mdlname
Dim Powner As pfcls.IpfcParameterOwner
Dim params As IpfcParameters
Dim param As IpfcBaseParameter
Dim paramValue As IpfcParamValue
Dim paramName As IpfcNamedModelItem
Dim NewDesignation As String
'Connexion
Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Set MyModel = session.CurrentModel
'Display file name
mdlname = MyModel.Filename
Range("A1") = mdlname
Set Powner = MyModel
Set params = Powner.ListParams()
'Display parameters name, value and description
For i = 1 To (params.Count - 1)
Set param = params(i)
Set paramValue = param.Value
Set paramName = param
Cells(i, 2) = i
Cells(i, 3) = paramName.Name
If paramValue.discr = 0 Then 'If parameter is string
Cells(i, 4) = paramValue.StringValue
ElseIf paramValue.discr = 3 Then 'if parameter is real value
Cells(i, 4) = paramValue.DoubleValue
End If
Cells(i, 5) = params(i).Description
Next i
'Modify parameter named DESIGNATION
For i = 1 To (params.Count - 1)
Set param = params(i)
Set paramValue = param.Value
Set paramName = param
If paramName.Name = "DESIGNATION" And paramValue.discr = 0 Then
NewDesignation = InputBox("Changer la désignation:")
'Here I miss the right code to update the parameter in ProE.....sorry
End If
Next i
'Déconnexion
conn.Disconnect (2)
Tnx for you reply, this is really old post, forgot about it
I found the way to put excel data into pro/E
here is part of the code you need
Dim bpro As IpfcBaseParameter
This lines assign value from excel and converts it to double (if you use VB instead of VBA use CType to convert to double)
vrijednost = Range("C48").Value
Set Value = CParamvalue.CreateDoubleParamValue(vrijednost)
This lines select parameter A in pro/E model and give it value from Excel
Set bpro = paraOwner.GetParam("A")
bpro.Value = Value
hope it helps
Dear Sir
Can you help me.
I had follow your code but can't code error in excel
Can you more detail how input value from excel to Paramater in Creo or in Relation dim?
Thanks advance your help
--------------------------------------------
Tnx for you reply, this is really old post, forgot about it
I found the way to put excel data into pro/E
here is part of the code you need
Dim bpro As IpfcBaseParameter
This lines assign value from excel and converts it to double (if you use VB instead of VBA use CType to convert to double)
vrijednost = Range("C48").Value
Set Value = CParamvalue.CreateDoubleParamValue(vrijednost)
This lines select parameter A in pro/E model and give it value from Excel
Set bpro = paraOwner.GetParam("A")
bpro.Value = Value
hope it helps
I need to write the value for a string parameter in CREO. But don't know how to do it. For real number parameters, found it. But for string parameters, I can't find the soluiton.
hello sir,
i have written this code but i am not connect with vb to proe and not opening the model through vb.net what chan I do Plz help me i had written this code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim componentFeat As pfcls.IpfcComponentFeat
'MsgBox("Feature number: " & componentFeat.Number)
Dim asyncConnection As IpfcAsyncConnection = Nothing
Dim cAC As CCpfcAsyncConnection
Dim session As IpfcBaseSession
Try
'======================================================================
'First Argument : The path to the Pro/E executable along with command
'line options. -i and -g flags make Pro/ENGINEER run in non-graphic,
'non-interactive mode
'Second Argument: String path to menu and message files.
'======================================================================
cAC = New CCpfcAsyncConnection
asyncConnection = cAC.Start("D:\Program Files\proeWildfire 4.0\bin\proe.exe" + " -g:no_graphics -i:rpc_input", ".")
session = asyncConnection.Session
asyncConnection.Session.ChangeDirectory("D:\Test_Proe")
Dim descModel As IpfcModelDescriptor
Dim model As IpfcModel
descModel = (New CCpfcModelDescriptor).Create(EpfcModelType.EpfcMDL_PART, "D:\ProEExample\test.prt", Nothing)
model = session.RetrieveModel(descModel)
Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
Finally
If Not asyncConnection Is Nothing AndAlso asyncConnection.IsRunning Then
asyncConnection.End()
End If
End Try
End Sub