Skip to main content
11-Garnet
May 25, 2022
Solved

Creo 9 problem retrieving parameter value.

  • May 25, 2022
  • 2 replies
  • 1896 views

If i run the following code in windows scripting host running in either wsh or csh. This works fine in Creo 7 and 8 but reports: pfcExceptions::XToolkitObsoleteFunc in Creo 9 on the para.Value call. If this truly is obsolete function? If it is obsolete is there a list of what was deprecated? Or is it just a installation problem?

 

Code distilled to smallest possible repeatable unit. Open a part or assembly into creo. Put following into a file with .js extension and run the file in windows scripting host (usually just double clicking of file but other programs might have hijacked the function so...).

 

 

var assCon = WScript.CreateObject('pfcls.pfcAsyncConnection');

var paraName = 'DESCRIPTION';

var conn = assCon.Connect('','','.',1);
var session = conn.session;

var mdl = session.CurrentModel; 
var para = mdl.GetParam(paraName); 
var val = para.Value; 
WScript.Echo(paraName + " = \"" + val.StringValue+"\"");

conn.Disconnect(2);

 

 

Best answer by MartinHanak

Hi,

please ask PTC Support.

2 replies

24-Ruby III
May 25, 2022

Hi,

please ask PTC Support.

joojaa11-GarnetAuthor
11-Garnet
May 25, 2022

I can't somebody has screwed up my support registrations so i can not report issues for creo, i can for mathcad (which i dont manage or use). Its not really super critical for me, ill just skip teaching users how to script in creo context and just teach solidworks instead. Loss for PTC sure but not me personally.

17-Peridot
May 25, 2022

Here's some VBA code using the Creo VB API that handles the different parameter types and uses GetScaledValue.

 

Notes:

  • This uses both IpfcBaseParameter and IpfcParameter to access the different properties of each.
  • There are 4 different types of parameters to account for (String, Integer, Boolean, Double)

 

Dim model as IpfcModel
Dim paramOwner As IpfcParameterOwner
Dim parameter As IpfcParameter
Dim Param As IpfcBaseParameter
Dim CreoParameterValueStr as String
Dim ParamName as String

Set model = session.CurrentModel
Set paramOwner = model
Set parameter = paramOwner.GetParam(ParamName)
If Not parameter Is Nothing Then
 Set Param = paramOwner.GetParam(ParamName)
 If Param.Value.discr = EpfcPARAM_STRING Then
 CreoParameterValueStr = parameter.GetScaledValue.StringValue 'String
 ElseIf Param.Value.discr = EpfcPARAM_INTEGER Then
 CreoParameterValueStr = parameter.GetScaledValue.IntValue 'Integer
 ElseIf Param.Value.discr = EpfcPARAM_BOOLEAN Then
 CreoParameterValueStr = parameter.GetScaledValue.BoolValue 'Boolean
 ElseIf Param.Value.discr = EpfcPARAM_DOUBLE Then
 CreoParameterValueStr = parameter.GetScaledValue.DoubleValue 'Double
 End If
Else
 CreoParameterValueStr = "ERROR: PARAMETER MISSING"
End If