Hi
I have 2D objects that are added to a specific layer and then I create 3D solids but they need to be put in a different layer for example
2D object is on layer T-------EZT------ and I want to put the 3Dsolids on layer T-------EJT------
But I can’t make the python script to work for me.
Someone of you might have an answer what I can do?
I tried to write Python code to online IDE from my mobile phone. I know it is not exactly what you are looking for but I hope it can help you Rename string - Replit
layers = [“EZT”, “EZF”, “AAA”]
out =
old_char = “Z”
new_char = “J”
for i in layers:
if old_char in i:
new = i.replace(old_char, new_char)
out.append(new)
else:
out.append(“EJE”)
# Load the Python Standard and DesignScript Libraries
import sys
import clr
# The inputs to this node will be stored as a list in the IN variables.
Lay_in = IN[0]
#**This was the interesting part!!**
Lay_out=["None"]*len(Lay_in)
for i in range(0, len(Lay_in)):
if Lay_in[i] == "T-------EJT------":
Lay_out[i] = "T-------EZT------"
elif Lay_in[i] == "T-------EJF------":
Lay_out[i] = "T-------EZF------"
elif Lay_in[i] == "T-------EJO------":
Lay_out[i] = "T-------EZO------"
elif Lay_in[i] == "T-------EJR------":
Lay_out[i] = "T-------EZR------"
else:
Lay_out[i] = "T-------EZE------"
# Assign your output to the OUT variable.
OUT = Lay_out
Sorry @Alien
My bad, i switched layer codes in my script and missed that when I uploaded the pictures and the code, that’s the reason they differ.
In my script they work just fine but I will try to use the example from @Drbohlav to make the script less project specific