NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create programmatically a new step type in TestStand (to myTypes.ini)

I need to create a new step type to myTypes.ini file programmatically. I have tried to do it with following steps:

- Get reference to engine
- Load type palette files
- creating new step type (engine.NewSteptype() )
- Inserting new type using TypeUsageList.InsertType method. Problem with this is the first parameter. It excpects it to be in a form of PropertyObject, but engine.NewStepType returns it as a StepType object. If I try to use StepType.AsPropertyObject it returns an error.

How to convert StepType object to a PropertyObject?
0 Kudos
Message 1 of 3
(3,435 Views)
Hi Orbis,

I am assuming that you are coding in VB. Here is a small sample of how to do what you are doing:

Dim mEngine As Engine
Dim typeList() As PropertyObjectFile
Dim propObjFile As PropertyObjectFile
Dim typeUseage As TypeUsageList
Dim stepObj As StepType

Set mEngine = Engine1
mEngine.LoadTypePaletteFiles
Set typeList = mEngine.GetTypePaletteFileList
Set typeUseage = typeList(0).TypeUsageList
Set stepObj = mEngine.NewStepType
stepObj.AsPropertyObject.Name = "TestMe"
typeUseage.InsertType stepObj.AsPropertyObject, 0, TypeCategory_StepTypes
typeList(0).IncChangeCount
typeList(0).SaveFileIfModified True

Hope this helps. Let me know if you have any questions.

Bob
0 Kudos
Message 2 of 3
(3,434 Views)
And here it is in C++:

TS::IEnginePtr mEngine;
SAFEARRAY * typeList;

TS::TypeUsageListPtr typeUseage;
TS::StepTypePtr stepObj;

mEngine = engine;
mEngine->LoadTypePaletteFiles();
typeList=mEngine->GetTypePaletteFileList();

TS::PropertyObjectFilePtr *rgelems;

SafeArrayAccessData(typeList,(void**)&rgelems);

typeUseage = rgelems[0]->TypeUsageList;
stepObj=mEngine->NewStepType();
TS::PropertyObject *property = stepObj->AsPropertyObject();
property->PutName("TestMe");
typeUseage->InsertType(property, 0, TS::TypeCategory_StepTypes);
rgelems[0]->IncChangeCount();
rgelems[0]->SaveFileIfModified(true);

SafeArrayUnaccessData(typeList);
0 Kudos
Message 3 of 3
(3,435 Views)