Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.
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
Thank you for your reply.
I can get parameter value from model, but can't update
it. I am doing this in visual studio 2008 since I can't
get it to work in excel, my guess is because vba does not
have CType function. Still trying to get around that
one. When I run it I don't get any error reports, but
parameter value remains unchanged...
any help is appreciated
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim mdl As pfcls.IpfcModel
Dim powner As pfcls.IpfcParameterOwner
Dim pro As pfcls.IpfcParameter
Dim pro_v As pfcls.IpfcParamValue
Dim X As String
asynconn =
CreateObject("pfcls.pfcAsyncConnection")
conn = asynconn.Connect("", "", ".", 5)
session = conn.Session
mdl = session.CurrentModel
X = Val(TextBox1.Text)
powner = CType(mdl, pfcls.IpfcParameterOwner)
pro = powner.GetParam("A")
pro_v = CType(pro, pfcls.IpfcBaseParameter).Value
pro.SetScaledValue(pro_v, Nothing)
conn.Disconnect(2)
having the same issue here.. I wonder if you have found a
replacement function for the 'CType' to use in vba excel.
For assembly operations in ProE wf4.
Following are lines from working code to modify parameter value.
Code:
Dim param As IpfcParameter
Dim prmVal As IpfcParamValue
param = model.GetParam("A")
prmVal = (New CMpfcModelItem).CreateDoubleParamValue(5.0)
CType(param, IpfcBaseParameter).Value = prmVal
I'm a bit of a newbe in Vb programming. Looking for script on how to update a Creo Parameter on part currently in session. In my Example I've created a Creo part called Blokkie.prt and it carries a Paramter called MATERIALNUMBER.
I've written a VB Application in Visual studio whice reteives a Material number in a combobox. I need to program Submit button to update Creo Parameter called "MATERIALNUMBER" in part blokkie.prt. If not tomuch trouble would you be able to post this script for the Submit Button. Need to be able update the "MATERIALNUMBER" Parameter from string variable in my VB UI.
I've been trying to figure this outbut with no luck. You seem to be a good guy to talk to?
Got an example in the VB API examples installed with Creo that I chaged a bit.It works!Stoked!Started out with Excel VB script and trying to move onto using Visual studio.
For interest sake here is the Submit Button code I use with the Sub Code.I use the createParametersFromStrings and createParametersFromStrings functions(also included):
Private Sub BSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BSubmit.Click
Hi thanks for the Reply. I sorted ut my issue. IT was to do with the issue of converting the parameter value to a string. I did not understand why the parameter value was not transeferable to textbox.text. I needed to convert the parameter value to string by using aclass on the vb api examples called PDUtils
Basically this is how I had to covert value to string:
Hi Guys, I struggled for a while with this. Here's some code that some of the ptc tech's provided. I altered it for my purpose. It works in both excel VBA or visual studio. Basically it will look at what current model is in session and then read a parameter value and then write back a new value to it. I hope this helps!
Sub Main2()
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim oModel As pfcls.IpfcModel
'Make an asynchronous connection with Pro/ENGINEER
Set conn = asynconn.Connect("", "", ".", 5)
'Get the current session
Set session = conn.session
'Retrieve the currently open model into the oModel handle
Set oModel = session.CurrentModel
'Show the name of the Pro/E Model in a messagebox
MsgBox "Model name = " & oModel.Filename
'
Dim A As IpfcBaseParameter
Dim Av As IpfcParamValue
Dim A_value As Double
Dim A_value_new As Double
Dim new_paramowner As pfcls.IpfcParameterOwner
'Read Parameter EZ value
Set new_paramowner = oModel
Set A = new_paramowner.GetParam("EZ")
Set Av = A.Value
A_value = Av.DoubleValue
'Show the original value of the parameter
MsgBox "EZ = " & A_value
'Set new value to Parameter EZ
Av.DoubleValue = 20
A.Value = Av
oModel.Save
'Show the final value of the parameter
MsgBox "EZ = " & A.Value.DoubleValue
'Disconnect with Pro/ENGINEER
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set oModel = Nothing
I know but I figured someone else could benefit from it. I tried all other solutions in this forum and nothing worked for me. I guess it always better to have alternate solutions available on the net for others to try.
been a while , and Ezaidi , I have indeed benefitted from the code to retrieve parametervalues. I now try to do go a little deeper in the vb api for proe, but it can be hard.
You wouldn't happen to know the code to perform the exact same action, but then to retrieve Dimension Values...
Great work Arno! I'm sure this will be useful for us as well in our automation. I did not yet get to the point of driving dimensions but I know that we will need it in the future.Thank you for your good work!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.