Python Geometry.Translate

Hello everyone,

I am trying to use the function “Geometry.Translate” with a Python node following the logic that I describe in the next screenshot:

I think it is clear with the texts that I wrote in the screenshot showing the aim of the workflow.

Thank you and regards,

What have you attempted so far in python? You would just have a for loop adding to the original point and returning the new point at each iteration.

You could also probably do this with nodes using one of the iterative sum processes.

Hi @Nick_Boyts ,

Thank you so much for your reply.

I tried to insert a while loop and a for loop within the while loop but with no success. I made a counter and while the counter < length of the sublist, keep iterating.

I have to say that I am noob level and I started with Python a couple of weeks ago so I am still trying to get familiar with the easiest codes…

Thanks again.

Can you show us? It’s hard to give suggestions without seeing exactly what you’ve done so far.

@Nick_Boyts This is what I did so far…

You can see above that I develop my codes in this compiler and then I copy and paste them into Dynamo Python nodes.

I know it is not aligned with the screenshot that I attached but I wanted to try with an easier approach and depending on the outcome that I get, move forward or keep trying until I get it done.

Morning @Nick_Boyts ,

I could get it done working for one single coordinate (xCoord) as the following image shows. The xCoordinateTranslation is following the logic that I posted in the first comment of the thread:

Now, I need to expand the script in order to be able to work not only for xTranslation but also for yTranslation and zTranslation. To do so, I thought about use “zip” in line 16 and add more variables but I did not get the outcome that I expected :frowning:

I ended up getting it :slight_smile:

It won’t probably be the cleaner method and syntax but as I am a noob…

1 Like

Nice job!

You don’t have to worry about enumerating these lists in a for loop so you can simplify it a bit.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
points = IN[0]
x_list = IN[1]
y_list = IN[2]
z_list = IN[3]
out = []

for point,xs,ys,zs in zip(points,x_list,y_list,z_list):
    subOut = []
    for x,y,z in zip(xs,ys,zs):
        point = Point.ByCoordinates(point.X + x, point.Y + y, point.Z + z)

OUT = out

You could also do an iterative sum to build the values ahead of time and use nodes to get the same output.