Why system.array

Hello, I’ve a question about arrays.

I’ve been looking in the Dynamo primer - Python.
Why is system.array necessary?

Thanks in advance!

Where specifically? Can you post a screenshot?

chapter 10.5 Python and Revit

I don’t think it’s exactly necessary. Here you’re creating a .NET array, although I think just providing the individual points would work just as well. e.g. OUT = CurveByPoints.ByReferencePoints([startRefPt, endRefPt]). I will check this momentarily to see if this is actually valid.

Attempting to use a native python list raises a TypeError, so it is indeed necessary to use a .NET array.

I’m a beginner Python programmer.
Can you tell me why it is necessary to use here the array?

Honestly, I don’t know too much of the technical details of IronPython specifically to say why. The method expects a strongly typed Array as its argument. Some basic types are implicitly converted (Python string -> .NET String, Python int -> .NET Int32, etc.), but my suspicion is that the same cannot be done for a Python list to a .NET Array. This is probably better answered by someone with more experience specifically in regards to IronPython.


Per the section of the primer that image comes from:

Revit’s API is written for .net, which means that Python lists have to be converted to use some methods directly, with this being one such example. This is one of many conversions which you’ll find are required as you get further into Python & Revit interaction.

1 Like

Thank you!
I really appreciate it.

Thank you!
I really appreciate it :wink: