Match string values for text, but output number for numbers?

Hi,

What I want is to define the position of offsets from curves by using attributes. That way, I can use the curves as centre, but also as the edge for the alignment.

Therefore, I have created an alignment attribute that contains “Exterior”, “Interior” or a distance relative from the centre (to make it off-centre). I have several offset distances for each of the street elements (pavement, street, etc.), but in this example, I only feed in the two outlines as a simpler example.

I want to use a script component to do the matching and created the following script:

import rhinoscriptsyntax as rs
if Offsets == "Exterior":
    Result = Offsets+Width/2

if Offsets == "E":
    Result = Offsets+Width/2

if Offsets == "Interior":
    Result = Offsets-Width/2

if Offsets == "I":
    Result = Offsets-Width/2

if type(Offsets) == float:
    Result = Offsets + Alignment

print Result

I also tried to do it in two steps and calculate the offsets in a next step:

import rhinoscriptsyntax as rs

Al = []
Dist = (Width/2)

if Alignment == "Exterior":
    Al.append(Dist)

elif Alignment == "Interior":
    Al.append(-Dist)

elif Alignment.isnumeric() is True:
    Al.append(Alignment)

Result = Al
print Al

But it’s not working either way. Could anyone lend me a hand on this?

Offset centrelines by attribute and alignment.gh (21.5 KB)
Offset centrelines by attribute and alignment.3dm (6.0 MB)

Nevermind I replaced the occurances of the Exterior or Interior strings with the numeric value I need using replace text.