NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set FileWritingFormat -> python

Solved!
Go to solution

Hello Community,

 

I am using TestStand 2017 and the ActiveX API for

programming in Python. 

The goal is to load a sequence file and change its format (mostly binary) to xml. so far, I have found the following:

 

engine =win32com.client.Dispatch("TestStand.Engine")

seqFile = engine.GetSequenceFile("file.seq")

xmlFile = seqFile.AsPropertyObjectFile.FileWritingFormat(3)

 

The following error occur:

 

AttributeError: 'function' object has no attribute 'FileWritingFormat'.

 

The 'FileWritingFormat' method can be used in the TestStand GUI, but why doesn't it work when using the ActiveX?
Thank you in advance 🙏

0 Kudos
Message 1 of 6
(1,117 Views)
Solution
Accepted by topic author Leonard_007

You want to set a property, so this should be an assignment rather than a method call

 

I guess 

 

seqFile.AsPropertyObjectFile.FileWritingFormat = 3

 

should do what you want to

Message 2 of 6
(1,090 Views)

Hello Oli,

 

thank you very much, that works fine. However, a ' PropertyObjects were not released' error occurs. I have executed the following to close the engine after the API:

engine.UnloadAllModules()

engine.ReleaseSequenceFileEx(seq_file, 0x0)

seq_file = None

engine.ShutDown(True)# someone suggested to not use, it doesn’t make any difference

 

I found a solution on this page, however only the cumbersome way via the GUI works for me. There under Debug-Options you can uncheck 'Report Object Leaks ... '. Then everything works. But, it is only the dialog window is not shown, the error still remains.

 

Thanks again. 🙏

0 Kudos
Message 3 of 6
(1,062 Views)

Simply put: 

 

each object created has to be released again. In my experience, it's best to have the release sequence just opposite to the sequence in which you instantiate objects.

 

I am usually working with the API in TestSatnd itself, so I don't really know what it exactly looks like in Python.

 

Is it possible you are opening further object refences?

 

I am shutting down the engine every time, since I consider this a good practice

0 Kudos
Message 4 of 6
(1,052 Views)

Good morning, Oli,

thank you for the hint. The code flow in Python is very similar to the one in TestStand. Apparently, you have to execute following when closing:

 

Engine.ReleaseSequenceFileEx(sequence_file, 0x4)

Engine.UnloadAllModules()

sequence_file = None

Engine.ShutDown(True)

 

Then the release leak error doesn't come anymore 🙂

Message 5 of 6
(996 Views)

Good Job! Thanks for sharing your findings 😊

0 Kudos
Message 6 of 6
(987 Views)