Building this structure to construct in real life. I am trying to find the axis that most of the layers share in order to use a thread as guide. I manually name every surface layer 01, 02…etc,
First question: Already done, but maybe good to know for next time. Is there anyway to grab a bunch of surfaces and “automatically” assign them to different layers and finally get them in order. I am not sure, but I have the feeling that grasshoper could be a huge help for this.
Second question: I draw a line that intersects the majority of the surfaces. Then applied the command intersect and got my points. I would like to know if those points could be related to the surface that was intersected. For example: The point coming from the line and surface 01, needs to be in the layer surface 01…the point that comes from intersection line and surface 02 needs to be name as surface 02 layer…and so on…
Still no idea of grasshoper, but I imagine this job was made for that.
Edit: Also I would like to choose for ex. 30 layers and change their color at once…I realise…I can not do that…mmmm any idea?
Grasshopper has no plugin-less layer support so you would either need a plugin or script the functionality with rhinocommon. Since the code comes from rhinocommon it could be a simple rhinopython script also. It is definitely possible to automate all of your ideas. Which way would you prefer do you have some experience in one of the things?
Is it the same if I post a sample file and then I apply it to the original one.
The reason is cause this documentation belongs to another person and I would like not to share since It is not mine. I am helping a client.
I work on designing and building model airplanes, and I can see similarities between that and the TS’ project. I also had a requirement for a series of layers with sequential numbering, all with the same layer color, so I developed the script below, which may be helpful. My guess is that sooner or later you will need a prefix added to the layer name/number, and store them under a parent layer like “main assembly”, “sub assy 1” or similar.
The script requires you to select a layer with a name ending on a number, say “MA1” or “1SA14” , and will then create x layers with the same prefix and sequential numbers, like MA2, MA3, MA4, or 1SA15, 1SA16, etc… (thanks to @Helvetosaur for dissecting the layer name and isolating the ending number). Maybe it is of some help.
Max.
# Introduce a new block of sequentially numbered layers. Max Zuijdendorp. April 2015
import rhinoscriptsyntax as rs
blocksize=rs.GetInteger("Quantity of layers to be added",10)
#colorchange=rs.GetColor(layercolor)
more=6
while (more==6):
object = rs.GetObject("Select Polysurface or Surface to use for base layer (Enter for selection list)", filter=24, preselect=False, select=False)
if object:
layername=rs.ObjectLayer(object)
else:
layername=rs.GetLayer("Select layer as base layer")
layercolor=rs.LayerColor(layername)
parentbaselayer=rs.ParentLayer(layername)
x=1
while(x<=blocksize):
#Split layer name in letters and number
namepart=layername.split("::")
layername=namepart[-1]
numbers=""
letters=""
for element in layername:
if element.isalpha(): letters+=element
elif element.isdigit(): numbers+=element
# increment number
if not (numbers==""):
numbers=str(int(numbers)+x)
newname=letters + numbers
if(rs.IsLayer(parentbaselayer+"::"+newname)):
rs.MessageBox("Existing layer name encountered - script aborted")
break
x=x+1
#Add new layer with incremented number
rs.AddLayer(newname,color=layercolor,parent=parentbaselayer)
else:
rs.MessageBox("Not a numbered layer")
break
more=rs.MessageBox("Do you want to add more layers?",buttons=4)
Thanks so much. I feel a little bit a shame cause I do not know how to apply this code. If you just can point out a at least a title to search it rhino’s help doc.
As I understood It can be coded or grasshoper will be the other option.
Copy the script and save it here: Users/(insert user name)/Library/Application Support/McNeel/Rhinoceros/scripts/(insert script name)>.py
(note “Library” may be a hidden folder)
Now type the command _RunPythonScript, find the file and run it.
It is only a first step in what you are after though, all it does is creating e heap of layers, all with the same layer color as the one you select at the start. No re-assigning objects to those or sorting layers by number.
One simple question. As I understood this will create consecutive layers after picking a “reference” layer.
My question is if this script also assign my surfaces in different layers…if I run the script while I grab 10 different surfaces? Or this is just for the sake of saving time by manually typing layer 01…layer02…layer03…?
With your experience level it will get a bit confusing and frustrating, especially as you work through workflows that aren’t ideal or optimized. It typically takes several iterations to actually get the correct sorting and whatnot as you spiral towards your ultimate goal.
In addition to layers there can be custom attributes assigned that sort, create planes and give limitless options.
Just that, and saving having to change the color x times. And it will keep them under the same parent layer as the one you picked.
(and as you probably know, “layer xx” is the default name, so you would not have to type that. But for any other alphanumerical prefix my script comes in handy)