Skip to main content
Hi,

 

I am trying to do something which I'm sure is pretty basic but struggling

 

I've got a public parameter (cellres) which refers to the cell resolution of an output ratser and I'm trying to use this to calculate the number of rows/colums, based on the maximum extents (max_X/max_Y).

 

I'm struggling to write the python or TCL - essentially I just want to do (max_X / cellres)?

 

It appears to be just concatenating the two parameters rather than returning a value

 

Thanks

 

Ed
Hi Ed,

 

 

Could you please show us the script that you have defined in the scripted parameter?

 

 

Takashi
Hi Takashi

 

I tried using a TCL expression and used expr(1220000/$FME_MacroValues(cellres))

 

I've never used TCL before so I suspect I'm doing something entirely wrong

 

Thanks,

 

Ed
Try this expression:

 

return expr 1220000/$FME_MacroValues(cellres)]

 

 

or, if you want to get a decimal number always:

 

return uexpr 1220000.0/$FME_MacroValues(cellres)]

 

 

See here to learn more about Tcl commands. (https://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm)
and Tcl Tutorial is here. (https://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html)
Thanks Takashi, extremely helpful as always 🙂
For reference, here is the same using Python:

 

 

return 1220000.0 / float(FME_MacroValuese'cellres'])

 

 

Just make sure that cellres <> 0 (goes for TCL too, I assume).

 

 

David

Reply