Please, Need Help With Basic Python


#1

I’m new to python and coding in general. so I was following the exercise given in the dynamo primer shown here http://dynamoprimer.com/09_Custom-Nodes/9-4_Python.html so when I copy and paste the entire code it worked fine, but when I copy the code letter for letter, space for space and indentation for indentation, It wouldn’t work. I also noticed when I typed some “.fuctions” such as clr.AddReference(‘ProtoGeometry’) there is no suggestions/auto complete for “.AddReference” the same thing happens to “.Rotate” or “solid.ContextCoordinateSystem” here is a side by side comparison, the one on the left is a copy&paste given by dynamo Primer script, the one on the Right is the one I wrote word for word. For some reason when I copy and paste the code from the left to the script on the right it suddenly works. But the one I typed up my self(right one) return as null. Any help would be appreciated.


#2

Can you upload your dynamo def with the problem python script? it’s likely an issue where a space was used instead of a tab or something, but it’s hard to diagnose from a screenshot.


#3

Yes, I also recommend posting actual code - and knowing how bad this website is for posting code - I ask people to post to Stack Overflow and provide a link. This way we can share code back and forth much easier. Thanks!


#4

Line 34 in left code and 35 in right code do not match, one has “solids.Transform” and the other has “solid.Transform”.

 

It should be “solid.Transform” because Solids has not got any elements at this stage.