Convert VB Expression to Python

216
0
10-09-2019 05:34 PM
RobertWesterberg
New Contributor

Hi Everyone,

I had an expression written in VB before upgrading to Pro. It seems that Pro does not support VB. I am having to convert the below to Python 3 in a new model but I just can't get it to work...

I want to grab a value in a field (PIPE_COND_SCORE) and multiply it by a value in a variable (PIPE_COND_WEIGHT) and insert the resulting value into a new field called TOTAL_SCORE.

The old VB is below and this was working in Desktop 10.3, for the sake of testing I have only added the first variable to the new model at this stage):

([PIPE_COND_SCORE] * %PIPE_COND_WEIGHT%) + ([PLACE_DATE_SCORE] * %PLACE_DATE_WEIGHT%) + ([WATERWAY_SCORE] * %WATERWAYS_WEIGHT%) + ([PRIORITY_AREA_SCORE] * %PRIORITY_AREA_WEIGHT%) + ([RCODE_SCORE] * %RDCODES_WEIGHT%) + ([BUILD_FOOT_SCORE] * %BUILD_FOOT_WEIGHT%) + ([ROAD_CENTRELINE] * %ROAD_CL_WEIGHT%) + ([PATH_CENTRELINE] * %PATH_CL_WEIGHT%) + ([PIPE_DIA_SCORE] * %PIPE_DIA_WEIGHT%) + ([COA_BUILDING_SCORE] * %COA_BUILD_WEIGHT%) + ([KNOWN_MAINT_SCORE] * %KNOWN_MAINT_WEIGHT%) 

From my research the expression should look something like this (using just the PIPE_COND_SCORE as example):

!PIPE_COND_SCORE! * %PIPE_COND_WEIGHT%

The above expression seems to call up the field correctly. The issue seems to be the calling up of the variable.

Any help would be greatly appreciated.

Thanks

Rob

0 Kudos
0 Replies