Connection between Python and Dynamo

i’m mainly on C# and Revit, not expert on Python (yet) so pls forgive my naive questions, i encountered similar issues just recently that output from Python cannot be used in Dynamo input even though data type looks the same, see attached.
image
not like C#, seems Python lacks debugging method, i usually put any stuff in OUT for checking purpose which is not efficient at all, any tips in debugging?
thanks.

You’re feeding the node a Revit bounding box, whereas it expects a dynamo one. Even tho the two are semantically the same, they are entirely different object types.

Similarly, Dynamo’s all elements of categories node expects a “wrapped” category type

thanks Dimitar, i did try “wrapped” stuff but didn’t work, perhaps my code is wrong?


Hi @Ning_Zhou

Here is one of the example how you can wrap:

thanks KulKul for the tip, yet to figure out boundingbox issue and what’s wrong w/ ToDSType?

hi KulKul, do you know how to convert BuiltInCategory from Python to Dynamo i.e. “bics = System.Enum.GetValues(BuiltInCategory)” which has more categories than “cats = doc.Settings.Categories”, and i don’t quite understand yet, thanks

hi Dimitar, is there any documentation on (un)wrap stuff i.e. how to use ToDSType and ToRevitType? seems i still cannot figure out how to convert Python’s BoundingBox to Dynamo one, thanks.

Hi @Ning_Zhou.

Have a look at this:

https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration

thanks Martin for the link.
well, seems ToDSType not working for bounding box?
image

That’s because you’re calling Dynamo’s Revit Element wrapper method. If you are looking to return ProtoGeometry try ToProtoType() instead.

thanks Thomas, i tried ToProtoType(), same error message

You’re using wrong quotation marks :slight_smile: or at least the formatting is wrong on them :slight_smile:
Look at line 23 and maybe others before that

great eye, thanks Jonathan!

i have an old issue which i posted before: seems OOTB Element.BoundingBox doesn’t work for 3D section box via OOTB Select Model Element, so i tried via Python, seems nothing works