Conventions¶
Workflow¶
Workflow script is a sequence of operations which process a predefined Input and generate a specific result Output.
All generic workflow scripts should be placed in Tools.
All project specific scripts should be placed in their corresponding Code folder per project.
Template:
1 2 3 4 5 6 7 8 9 10 11 | import armacode
def main(x, y):
"""
Docstring
"""
result = x + y
return result
if __name__ == "__main__":
main()
|
Note
All workflow should be defined in a main() function and call it safely using if __name__ == "__main__":
Command¶
A python script can be used as a Rhino Command.
Workflow that are stable has been fully tested and working as intended should be turned into a command for easy execution.
Command python files are named with a suffix _cmd.py. All commands are stored in the Plug-in folder.
Create a command:
- Open Python script editor using
EditPythonScript - File > New > Command
- Select the AR-MA plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import armacode
import rhinoscriptsyntax as rs
import Rhino
__commandname__ = "CommandName"
# RunCommand is the called when the user enters the command name in Rhino.
# The command name is defined by the filname minus "_cmd.py"
def RunCommand( is_interactive=True ):
print "Hello", __commandname__
# get a point
point = rhinoscript.userinterface.GetPoint()
if( point != None ):
rhinoscript.geometry.AddPoint(point)
# you can optionally return a value from this function
# to signify command result. Return values that make
# sense are
# 0 == success
# 1 == cancel
# If this function does not return a value, success is assumed
return 0
if __name__ == "__main__":
RunCommand()
|