Error in Revit 2023: unsupported operand types

Hi everyone,
Can anyone explain me why I’m getting for the section of my code below, the following error in python Cpython3 engine under REVIT 2023?

Remark:
My code works perfectly in ironpython 2 under REVIT 2022 !!?

# get rotated curves
circ_count = int(math.ceil(v_path.Length /H_s))

out_cir_curvs = []
for i in range(0, circ_count):
    temp = []
    for j in out_cir_crv:
        #e0 = 0.05/0.3048
        e= i * H_s
        circ_offset = Transform.CreateTranslation(out_V_crv.Direction.Normalize()*e)
        j = j.CreateTransformed(circ_offset)
        e1 = v_path.Length - e
        if e1 >= H_s:
            temp.append(j)
    out_cir_curvs.append(temp)

Thanks.

Looks like the variable H_s is a Revit XYZ object though I cannot confirm as it is t defined in what you have shown. The actual error is at line 60, not 61, if that is correct.

Iron Python 2 allowed use of operators directly, but CPython does not (nor do I think Iron Python 3 does either). The list of these operators is here: XYZ Members

As such you will have to use the multiply method directly, which can be seen here: Multiply Method

Something like e = H_s.Multiply(i) should work out well enough.

1 Like

It’s a Pythonnet 2.5.x bug (unsupport .Net operators), need to use Methods instead

Ironpython2, Ironpython3 and PythonNet3 do not have this problem

2 Likes

Try circ_offset = Transform.CreateTranslation(out_V_crv.Direction.Normalize().Multiply(e))
Normailize returns an XYZ so as Jacob mentioned you can use the Multiply method

1 Like

This hasn’t been my experience; or rather even worse the operators don’t work as you’d expect (multiplying by the wrong value), but glad to hear you’ve gotten it working. :slight_smile:

Thanks @jacob.small @c.poupin @Mike.Buttery for your replys

I used the same code that Mike did and it works now

I got the same error later related to vectors substraction in this part of the code and I made the correction as indicated below and it works.

h_vect = (h_line.GetEndPoint(1).Subtract(h_line.GetEndPoint(0))).Normalize()
    out_circ_vect.append(h_vect)

Thanks for All.

1 Like

so far I haven’t encountered any problems

2 Likes

@c.poupin

So If I use IronPython 3, my original code works properly?

How can I use IronPython 3 under Revit 2023 or you suggest me to keep Cpython 3 ? …I dont know what’s the diference between them and which of them is suitable for me!!

Thanks.

@REDO10 CPython3 or IronPython3 there will necessarily be updates to be made

1 Like