Skip to content

Commit 7327ca6

Browse files
committed
update python sample to use pythonnet3
1 parent 38f5741 commit 7327ca6

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

doc/distrib/NodeHelpFiles/en-US/PythonNodeModels.PythonNode.dyn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
{
5050
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
5151
"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",
52-
"Engine": "CPython3",
53-
"EngineName": "CPython3",
52+
"Engine": "PythonNet3",
53+
"EngineName": "PythonNet3",
5454
"VariableInputPorts": true,
5555
"Id": "42d5ff37f86e44f4bad38cc80a511874",
5656
"NodeType": "PythonScriptNode",

doc/distrib/NodeHelpFiles/en-US/PythonNodeModels.PythonStringNode.dyn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@
244244
},
245245
{
246246
"ConcreteType": "PythonNodeModels.PythonStringNode, PythonNodeModels",
247-
"EngineName": "CPython3",
248-
"Engine": "CPython3",
247+
"EngineName": "PythonNet3",
248+
"Engine": "PythonNet3",
249249
"VariableInputPorts": true,
250250
"Id": "45073da27bc84c689246c0a66bf70784",
251251
"NodeType": "ExtensionNode",

doc/distrib/Samples/en-US/Core/Core_Math.dyn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@
20152015
{
20162016
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
20172017
"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",
2018-
"Engine": "CPython3",
2018+
"Engine": "PythonNet3",
20192019
"VariableInputPorts": true,
20202020
"Id": "7024be7096c74f46a832ce5749bba59a",
20212021
"NodeType": "PythonScriptNode",

doc/distrib/Samples/en-US/Core/Core_Python.dyn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
1414
"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)",
15-
"Engine": "CPython3",
15+
"Engine": "PythonNet3",
1616
"VariableInputPorts": true,
1717
"Id": "7183a2fe9a6a4eebb2233525a80ab2f2",
1818
"NodeType": "PythonScriptNode",
@@ -308,7 +308,7 @@
308308
{
309309
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
310310
"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]",
311-
"Engine": "CPython3",
311+
"Engine": "PythonNet3",
312312
"VariableInputPorts": true,
313313
"Id": "9094d23b33384e5caf7b7d08e547cc25",
314314
"NodeType": "PythonScriptNode",

0 commit comments

Comments
 (0)