Different logic for joining

How would I compare the sizes of two surfaces/polysurfaces with a script?

I want to know which one is bigger before joining them, then assigning the output to the larger of the two input object’s layer… Instead of whatever logic it uses by default.

I find 90% of my joining is adding some little tit like a stair to a huge surface like a floor. Then after joining naturally it decides the whole floor should be changed to the layer I sketched the little addon piece.

Hi Ryan - you can compare areas, or if the difference is clearly pretty large, get bounding boxes and compare the diagonals’ length (points 0 and 6 in a bounding box, assuming you are getting the BB from a RhinoScript or an rs function in Python.

-Pascal

I guess what I probably need is a snippet from some other script that does this. Any obvious candidates come to mind I could download and look at?

In RhinoScript, something like this:

Sub Main()
Dim Id1,Id2
Id1 = Rhino.GetObject("Select a surface or polysurface.", 8+16, True, True)
If IsNull(Id1) Then Exit Sub

Id2 = Rhino.GetObject("Select another surface or polysurface.", 8+16, False)
If IsNull(Id2)Then Exit Sub

Rhino.UnselectAllObjects()

If Rhino.SurfaceArea(Id1)(0) > Rhino.SurfaceArea(Id2)(0) Then
	Rhino.SelectObject(Id1)
Else
	Rhino.SelectObject(Id2)
End If

Dim BB1, BB2
BB1 = Rhino.BoundingBox(Id1)
BB2 = Rhino.BoundingBox(Id2)
If Rhino.Distance(BB1(0),BB1(6)) > Rhino.Distance(BB2(0), BB2(6)) Then
	Rhino.AddLine BB1(0),BB1(6)
Else
	Rhino.AddLine BB2(0),BB2(6)
End If

End Sub

-Pascal

Always select the floor (or the object on the layer you would like the result to stay on) first. --Mitch