cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Creo 9 problem retrieving parameter value.

joojaa
10-Marble

Creo 9 problem retrieving parameter value.

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);

 

 

ACCEPTED SOLUTION

Accepted Solutions
MartinHanak
24-Ruby III
(To:joojaa)

Hi,

please ask PTC Support.


Martin Hanák

View solution in original post

3 REPLIES 3
MartinHanak
24-Ruby III
(To:joojaa)

Hi,

please ask PTC Support.


Martin Hanák

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.

lhoogeveen
17-Peridot
(To:joojaa)

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

 

 

Announcements


Top Tags