Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"Code": "import clr\nclr.AddReference('ProtoGeometry')\nfrom Autodesk.DesignScript.Geometry import *\nfrom System.Reflection import *\nimport System\nfrom System import Array\nfrom System.Collections.Generic import *\n\n#The inputs to this node will be stored as a list in the IN variables.\nsolid = IN[0]\nseed = IN[1]\nxCount = IN[2]\nyCount = IN[3]\n\nsolids = []\ncrvs = []\n\nedges = solid.Edges\nfor edge in edges:\n\tcrvs.append(edge.CurveGeometry)\n\t\nbbox = BoundingBox.ByGeometry(crvs)\nyDist = bbox.MaxPoint.Y-bbox.MinPoint.Y\nxDist = bbox.MaxPoint.X-bbox.MinPoint.X\n\nxRange = list(range(xCount))\nyRange = list(range(yCount))\n\nfromCoord = solid.ContextCoordinateSystem\n \n#Loop through X and Y\nfor i in xRange:\n\tfor j in yRange:\n\t\t#Rotate and translate the coordinate system\n\t\ttoCoord = fromCoord.Rotate(solid.ContextCoordinateSystem.Origin,Vector.ByCoordinates(0,0,1),(90*(i+j%seed)))\n\t\t#Creating an Array type in .NET\n\t\tarrayObj = Array[System.Object]\n\t\t#Instantiating an object of that type with Length 1 \n\t\tarray1 = arrayObj.CreateInstance(System.Object, 1)\n\t\t#Creating our Vector to put into the array\n\t\tvec = Vector.ByCoordinates((xDist*i),(yDist*j),0)\n\t\t#Adding our vector to the array at index zero\n\t\tarray1[0] = vec\n\t\t#Letting .NET figure out what function to call instead of PythonNET - Note: Problems exist today in PythonNET 2\n\t\ttoCoord = toCoord.GetType().InvokeMember(\"Translate\", BindingFlags.InvokeMethod, None, toCoord, array1)\n\t\t#Transform the solid from the source coordinate system to the target coordinate system and append to the list\n\t\tsolids.append(solid.Transform(fromCoord,toCoord))\n\n\n#Assign your output to the OUT variable.\nOUT = solids\n",
"Engine": "CPython3",
"EngineName": "CPython3",
"Engine": "PythonNet3",
"EngineName": "PythonNet3",
"VariableInputPorts": true,
"Id": "42d5ff37f86e44f4bad38cc80a511874",
"NodeType": "PythonScriptNode",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@
},
{
"ConcreteType": "PythonNodeModels.PythonStringNode, PythonNodeModels",
"EngineName": "CPython3",
"Engine": "CPython3",
"EngineName": "PythonNet3",
"Engine": "PythonNet3",
"VariableInputPorts": true,
"Id": "45073da27bc84c689246c0a66bf70784",
"NodeType": "ExtensionNode",
Expand Down
2 changes: 1 addition & 1 deletion doc/distrib/Samples/en-US/Core/Core_Math.dyn
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"Code": "import clr\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n\r\nimport math\r\n\r\n# The inputs to this node will be stored as a list in the IN variable.\r\namp = IN[0] # single value\r\nx = IN[1] # list\r\ny = IN[2] # list (expect same length as x)\r\nc = IN[3] # single value\r\n\r\n# Declare an empty array of z-values\r\nz = []\r\n\r\n# Solve the equation for each x and y value\r\nfor index in range(len(x)):\r\n\tsum = math.pow(x[index],2) + math.pow(y[index],2) + math.pow(c,2)\r\n\tnum1 = math.sqrt(sum)\r\n\tnum2 = math.sin(num1)\r\n\tzVal = amp * num2 / num1\r\n\t\r\n\t# Append the answer to the list of z values\r\n\tz.append(zVal)\r\n\r\n# Assign the z-values to the OUT variable\r\nOUT = z",
"Engine": "CPython3",
"Engine": "PythonNet3",
"VariableInputPorts": true,
"Id": "7024be7096c74f46a832ce5749bba59a",
"NodeType": "PythonScriptNode",
Expand Down
4 changes: 2 additions & 2 deletions doc/distrib/Samples/en-US/Core/Core_Python.dyn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"Code": "# Python script to find add or subtract a series of numbers. \r\n\r\n# Boiler-plate import statments included out-of-the-box\r\nimport clr\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n\r\n# The inputs to this node will be stored as a list in the IN variable.\r\nsign = IN[0] # -1 for subtract all, 0 for do nothing, 1 for add all\r\nnums = IN[1] # List of numbers to subtract or add\r\n\r\npartials = [] # Empty array to contain partial sums or differences\r\nresult = 0 # Initialize the sum or difference to 0\r\n\r\n# Loop through each item and add it or subtract it from the result.\r\nfor index in range(len(nums)):\r\n\tif sign > 0:\r\n\t\tresult = result + nums[index]\r\n\t\tpartials.append(result)\r\n\telif sign == 0:\r\n\t\tpartials.append(result)\r\n\t\tcontinue\r\n\telse:\r\n\t\tresult = result - nums[index]\r\n\t\tpartials.append(result)\r\n\r\n# Assign the output to the OUT variable\r\n#OUT = results # Use this to output only the result.\r\nOUT = []\r\nOUT.append(result)\r\nOUT.append(partials)",
"Engine": "CPython3",
"Engine": "PythonNet3",
"VariableInputPorts": true,
"Id": "7183a2fe9a6a4eebb2233525a80ab2f2",
"NodeType": "PythonScriptNode",
Expand Down Expand Up @@ -308,7 +308,7 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"Code": "import clr\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n#The inputs to this node will be stored as a list in the IN variable.\r\ndataEnteringNode = IN\r\n\r\np1 = Point.ByCoordinates(0, 0, 0);\r\np2 = Point.ByCoordinates(-10, -10, -10);\r\n\r\nl = Line.ByStartPointEndPoint(p1, p2);\r\n\r\npts = [\r\n\tPoint.ByCoordinates(0, 0, 0),\r\n\tPoint.ByCoordinates(10, 10, 0),\r\n\tPoint.ByCoordinates(20, 0, 0),\r\n\tPoint.ByCoordinates(30, 10, 0),\r\n\tPoint.ByCoordinates(40, 0, 0) ]\r\n\t\r\nspline = NurbsCurve.ByPoints(pts)\r\n\r\nsurf = spline.Extrude(Vector.ByCoordinates(0, 0, 1), 10)\r\n\r\n#Assign your output to the OUT variable\r\nOUT = [l, spline, surf]",
"Engine": "CPython3",
"Engine": "PythonNet3",
"VariableInputPorts": true,
"Id": "9094d23b33384e5caf7b7d08e547cc25",
"NodeType": "PythonScriptNode",
Expand Down
Loading