<gh_stars>0
import os
import shutil
from tixi import tixiwrapper

def load_external_libs():
    try:
        global tixi_h
        tixi_h = tixiwrapper.Tixi()
        print("TIXI version: ", tixi_h.version)
    except Exception as e:
        print("Could not load TIXI! Error message is: {}".format(e))

def your_function():
    #read OEM mass
    OEM = tixi_h.getDoubleElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/massDescription/mass')

    #OEM xpath
    OEM_path = '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/massDescription/mass'

    #new OEM mass
    OEM_new=2*OEM

    #update OEM mass
    tixi_h.updateDoubleElement(OEM_path, OEM_new, '%g')

def main():

    workingDir = os.getcwd()
    
    #Input/Output definition
    cpacsIn = os.path.join(workingDir, 'ToolInput', 'cpacs_in.xml')
    cpacsOut = os.path.join(workingDir, 'ToolOutput', 'cpacs_out.xml')
    
    #Load Tixi
    load_external_libs()

    #Open cpacs file
    print('Start reading CPACS file...')
    try:
        tixi_h.open(cpacsIn)
    except:
        print('TIXI could not read input file.')

    your_function()

    tixi_h.save(cpacsOut)
    tixi_h.close()  


if __name__ == '__main__':
    main()
import os
import shutil
from tixi import tixiwrapper

def load_external_libs():
    try:
        global tixi_h
        tixi_h = tixiwrapper.Tixi()
        print("TIXI version: ", tixi_h.version)
    except Exception as e:
        print("Could not load TIXI! Error message is: {}".format(e))

def your_function():
    #read OEM mass
    OEM = tixi_h.getDoubleElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/massDescription/mass')

    #OEM xpath
    OEM_path = '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/massDescription/mass'

    #new OEM mass
    OEM_new=2*OEM

    #update OEM mass
    tixi_h.updateDoubleElement(OEM_path, OEM_new, '%g')

def main():

    workingDir = os.getcwd()
    
    #Input/Output definition
    cpacsIn = os.path.join(workingDir, 'ToolInput', 'cpacs_in.xml')
    cpacsOut = os.path.join(workingDir, 'ToolOutput', 'cpacs_out.xml')
    
    #Load Tixi
    load_external_libs()

    #Open cpacs file
    print('Start reading CPACS file...')
    try:
        tixi_h.open(cpacsIn)
    except:
        print('TIXI could not read input file.')

    your_function()

    tixi_h.save(cpacsOut)
    tixi_h.close()  


if __name__ == '__main__':
    main()
#read OEM mass #OEM xpath #new OEM mass #update OEM mass #Input/Output definition #Load Tixi #Open cpacs file