0

I would like to extract an unusual file property that a software package (OrcaFlex) adds when it creates a file. In Windows Explorer, when I hover my cursor over the file listing such as SomeSimulation.sim in the first screenshot below, a popup window appears with properties including 'Model state'. Here I learned these are called infotips. I want to retrieve the Model state value (the string "Time domain dynamics complete") using Perl or any other command line language. How do I do that? I am using Windows 7 and James' comment helped me see that I will have to use this, perhaps like this.

file listing

4
1

I'm one of the authors of OrcaFlex. With absolutely no warranty the following Python code will hack out what you need.

import struct

def readModelStateText(fileName):
    with open(fileName, 'rb') as f:
        content = f.read(0x4000) # hope that the text appears this early in the file
    signature = b'\xff\xfa\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
    index = content.find(signature)
    if index == -1:
        return '<model state not found>'
    index += len(signature) + 2 # skip over block length
    stringLength = struct.unpack('<H', content[index:index + 2])[0]
    index += 2
    return content[index:index + stringLength].decode('utf-8')

This hunts for a specific block in the file with knowledge of the block header signature. It is plausible (very unlikely I suspect) that the code will find the body of an earlier block that matches the signature. And there are other ways that this code might fail.

I'm just offering it because it is possibly useful, but with a hefty caveat emptor.

2
  • I no longer have OrcaFlex access so can't confirm, but appreciate the answer! – KAE Jun 26 '17 at 18:42
  • 1
    I do have OrcaFlex access ;-) and it works well!! It came up because another user asked for the same functionality and referred to this question. So I thought I may as well answer here too. – David Heffernan Jun 26 '17 at 18:52
0

My smart coworker noticed that the string "Time domain dynamics complete" is actually in the binary file early on. So I used grep without interacting with Windows which is a relief,

head -10 SomeSimulation.sim | grep "Time domain dynamics complete"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.