Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
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);
Solved! Go to Solution.
Hi,
please ask PTC Support.
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.
Here's some VBA code using the Creo VB API that handles the different parameter types and uses GetScaledValue.
Notes:
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