Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hello,
I'm trying to make a selection, using the example in instalation folder. I'm connected with the running session in CREO, but I'm unable to make the selection.
There is an messagebox appearing the follwing message.
Any help?
Solved! Go to Solution.
What about the parameter? Does it exist in the model?
In your code you get a parameter DESCRICAO_PAR, read the value of this parameter. Then write this value back to parameter. If the model don't have this parameter, then you will get an error.
Dim paramOwner As IpfcParameterOwner
Set paramOwner = session.CurrentModel
Dim parameter As IpfcParameter
Set parameter = paramOwner.GetParam("DESCRICAO_PAR")
Dim modelItem As CMpfcModelItem
Set modelItem = New CMpfcModelItem
Dim paramValue As IpfcParamValue
Set paramValue = modelItem.CreateStringParamValue("TEST")
parameter.SetScaledValue paramValue, Nothing
Hello,
show a piece of your code from Form1.vb near line 54
I've found the problem.
The code at the moment like this:
selopt = (New CCpfcSelectionOptions).Create("part")
selopt.MaxNumSels = 1
sel = session.Select(selopt, Nothing)
pobj = sel.Item(0).SelModel
At the moment is working. Now I'me strugling with parameters. I'm trying to fill a string parameter in CREO, by VB. And I can't do it... I've the way to do for a real number parameter, but not that easy to a string parameter.
Something like this
Dim pv As IpfcParamValue
Dim p As IpfcParameter
Dim s As String
pv = (New CMpfcModelItem).CreateStringParamValue(s))
p = pOwner.GetParam("PARAM_NAME")
If p Is Nothing Then
pOwner.CreateParam("PARAM_NAME", pv)
Else
CType(p, IpfcBaseParameter).Value = pv
End If
Take a look at ...\Common Files\vbapi\vbapi_examples\pfcDimensionAndParameterExamples.vb
Thanks by help.
is returning the following error.
1. Is there "DESCRICAO_PAR" parameter is exist in your model?
2. You can try method IpfcParameter.SetScaledValue()
Still the same error.
The funny thing, is that a real number parameter, i'm able to do it. The string parameter don't...
What about the parameter? Does it exist in the model?
In your code you get a parameter DESCRICAO_PAR, read the value of this parameter. Then write this value back to parameter. If the model don't have this parameter, then you will get an error.
Dim paramOwner As IpfcParameterOwner
Set paramOwner = session.CurrentModel
Dim parameter As IpfcParameter
Set parameter = paramOwner.GetParam("DESCRICAO_PAR")
Dim modelItem As CMpfcModelItem
Set modelItem = New CMpfcModelItem
Dim paramValue As IpfcParamValue
Set paramValue = modelItem.CreateStringParamValue("TEST")
parameter.SetScaledValue paramValue, Nothing
Yes it exists:
Access = Limited
Try change to Full
same error...
Another problem, that the parameter is Restricted. Then not all values are acceptably.
Try to set value, for example, to "CUSTO_STD"
It worked!!!!
Can you explain me the difference?
Found the problem... What a stupid guy I am.... I had restricted values applied for this parameter... And "TEST" wasn't one of the values...
Thank you very much for your very usefull help.
After all of the usefull help, I created this app for CREO.
https://www.youtube.com/watch?v=S_Qeh26Jz1Y
Thanks by your help