Get highest surface by z axis to change its layer

Hey guys,

I have a set of floors that are beeing generated from a file that I have created. However, so far the highest floor had to become the roof manually. I would like to develop a gh snippet which automatically checks the floors by their height, takes the one at the top and changes its layer.

Do you guys have an idea on how to do that? I fear this must be done in Python

Would appreciate any help.


floortoroof.gh (10.0 KB)

floortoroof.3dm (4.0 MB)

Best
Max

I don’t use Human. If you want a HUman based solution, we can add the tag in the topic description.

You can bake a copy of the surface to a new layer with EleFront but deleting needs to be done manually or with Python, as you mentioned.

floortoroof_mrtn_elefront.gh (16.7 KB)

Hey Martin,

a Human based solution would be okay as well, as long as it works on its own.

Best Max

Can’t assist you with Human but I’m sure someone else will chime in soon.

I dont have Human, but if you replace Martins Python script with this:

import scriptcontext
import Rhino as rh

li = rh.RhinoDoc.ActiveDoc.Layers.Find("roof",0)

scriptcontext.doc = rh.RhinoDoc.ActiveDoc

if delete: 
    doc_ob = scriptcontext.doc.Objects.Find(roof)
    att = doc_ob.Attributes
    att.LayerIndex = li
    rhino_ob = scriptcontext.doc.Objects.Add(doc_ob.Geometry, att)
    scriptcontext.doc.Objects.Delete(doc_ob)

scriptcontext.doc = ghdoc

it should work.

1 Like

Here is a solution purely based on Elefront (no C#, no Python)
As long as the GH is opened, any surface add/deletion/move will be taken into account and the highest floor automatically moved to roof layer, the others to floors layer. No bake needed.

ChangeLayer.gh (11.5 KB)

Thank you guys!

I checked out all your solutions. They all seem to work quite well. I also found an additional solution prior to baking the floors in the first place. So the problem is solved :). Now they get sorted and after that baked for the first time.