Hexagon Geospatial
MENU

Who Me Too'd this topic

Discuss topics with other Hexagon Geospatial Product pioneers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Contributor
Posts: 72
Registered: ‎11-02-2015
Accepted Solution
Load an exisiting Model and change port values within Python

Hi there,

 

I spent some time to find a solution but finally I failed with a quite simple task:

 

The goal is to load an existing model within Python and adjust at least the filenames for one Raster Input and one Raster output operator.

 

Loading the model works fine:

 

 

from imagine import modeler
# Load a saved model
modelFile = 'e:/tmp/test.gmdx'
m = modeler.Solution.Load(modelFile)

But I have found no way to set the values for Filename port the Raster Input and the Raster Outpur operator directly nor by adding two "Port Input" operators.

 

 

Reading the values is described in the online help and also works fine here:

 

from imagine import modeler
# Load a saved model
modelFile = 'e:/tmp/test.gmdx'
m = modeler.Solution.Load(modelFile)
for p in m.GetPorts():
    print(p.name + ' = ' + str(p.data))

But I have no idea how to set the data value for the specific port. Any help is more than welcome

 

 

Cheers

Fritz

 

P.S. the used model should be attached to this post

 

 

 

Geography is what geographers do...
Who Me Too'd this topic