How to find if an object is a Lands Design object?

Hi,
How can I find all objects that are lands generated?
I am making some tools where the lands objects (like row etc) is messing up.


In another script I use rs.ObjectDescription(obj) to see if it is tagged as “Terrain”,
but I don’t want to check for all possible names as this might change in the future.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import rhinoscriptsyntax as rs
import Rhino

objects = rs.GetObjects("Select objects", preselect=True)

if objects:
    for object in objects:
        obj = sc.doc.Objects.Find(object)
        print obj.Id
        p = obj.GetRenderMeshParameters()
        obrefs = Rhino.DocObjects.RhinoObject.GetRenderMeshes([obj], True, True)
        print rs.ObjectDescription(obj)
        
        ### If object is terrain use only the first object in the list which is the top surface
        if rs.ObjectDescription(obj)=="terrain":
            mesh = obrefs[0].Mesh()
            if mesh:
                tempMesh = sc.doc.Objects.AddMesh( mesh)

There is a .NET SDK in Lands that could help you. It is still WIP but it has functions to know if an object is a Lands Object, and to edit some of its general aspects. It also has a lot of functions to edit Terrain objects. However it hasn’t any way to determine if an object has been tagged as terrain.
To play with it, you can take a look to the “Lands.Script.dll” located into the Rhino System folder:
C:\Program Files\Rhino 7\System

You can use it this way:

using Lands;

if (Lands.Script.IsLandsObject(objectId))
{
    ...
}

Thanks, can you please consider tagging it with something readable from vanilla Rhino too?
Using UserText with a hidden entry is an easy option.

Since I use Python, do you know how I can use it?
I tried this but it fails.

import rhinoscriptsyntax as rs
import ctypes
#Check if Lands is installed
LandsInstalled = False
# Load DLL into memory.
try:
    Lands = ctypes.WinDLL ("C:\Program Files\Rhino 7\System\Lands.Script.dll")
    LandsInstalled = True
except:
    print "could not use dll"
    pass

objectId = rs.GetObject("")
if LandsInstalled:
    if (Lands.Script.IsLandsObject(objectId)):
        print "Landsobject"

Hi @Holo,

You can do it like this:

import clr
clr.AddReference("Lands.Script")
import Lands.Script as la

la.IsTerrain()
2 Likes
Ok, should this work then?
import rhinoscriptsyntax as rs
import clr
#Check if Lands is installed
LandsInstalled = False
# Load DLL into memory.
try:
    clr.AddReference("Lands.Script")
    import Lands.Script as la
    LandsInstalled = True
except:
    print "could not use dll"
    pass
objectId = rs.GetObject("")
if LandsInstalled:
    if la.IsTerrain(objectId):
        print "Landsobject"

I don’t get it to work.

Please note that you are calling IsTerrain() instead of IsLandsObject().
If this is not the problem (you want to identify a pure Lands Terrain), what’s not working?

1 Like

When I try this:

import rhinoscriptsyntax as rs
import clr
clr.AddReference("Lands.Script")
import Lands.Script as la

objectId = rs.GetObject("")
if objectId:
    print la.IsLandsObject(objectId)

I get this error:

Message: Could not add reference to assembly Lands.Script

Traceback:
line 3, in , “C:\Users\mail\AppData\Local\Temp\TempScript.py”

It should work. What Rhino version are you using? The Lands .NET SDK is only available for Rhino 7 and Rhino 6 (Rhino 8 support will be available in Lands Design 6, coming very soon).

In case you use Rhino 7 (or 6), make sure that you have the Lands.Script.dll file in the following folder:

C:\Program Files\Rhino 7\System

Hi, thanks. Yes, Rhino 7, and it is in that folder.
Strange stuff.