In an earlier post I showed you a definition that read textfile based coordinates into Revit:
However, it's tedious to repeat the large codeblock over and over, and though I haven't figured out how to repeat the operation automatically based on list length, I've managed to make a definition in a code block that, when called, can be repeated more easily:
So I will try to explain what parts make up a callable defintion. (By callable I mean a seperate standing code block that we can "call" from another codeblock.)
Blue= This is the name that you later will call from another code block.
Green= Green contains all the outer variables that will have to be inputted to execute the definition (The left side of dynamo nodes)
Orange= this is the name of the variable.
Yellow= The colon means that whatever follows will define what kind of variable the "list"-variable will be.
Cyan= this defines the variable "list", in this case "var[][]" means a "list of lists of variables"
Pink= In a code block definition "return" is the output of the definition and must be included
Purple= "{" marks the start of the definition and "}" marks the end
If you want multiple variables you seperate them by commas inside the parentheses
The rest is the "body", that would be the calculations and stuff that will be executed based on the inputs.
So when I call this node in an ordinary code block I would type: Curvebyind(x). (Notice that I don't have to use "list" as i did in the definition)
A variable can be many things but I've listed some of them here, including an error that comes if you put a floating number(3.145) into a function that expects an integer:
PS: If this is way below your level of dynamo expertise, I've left something out or ,even worse, written something entirely wrong, then I hope you get provoked enough to supplement in the comments! :)