Rename points in Python

Hi,

The Python script below gives me the point names of 3d points in my workspace. However not all have names and by default are named " None" so I want to change these names to “No Name” either by default or in the script. All suggestions welcome as new to Python and just getting into it slowly.

Roger

import rhinoscriptsyntax as rs

objectIds = rs.GetObjects(“Pick measured points”, rs.filter.point)
for id in objectIds:
objectname = rs.ObjectName(id)
objectcoord = rs.PointCoordinates(id)
print objectname,",",objectcoord

Something like this perhaps:

import rhinoscriptsyntax as rs

objectIds = rs.GetObjects("Pick measured points", rs.filter.point)
for id in objectIds:
    objectname = rs.ObjectName(id)
    if not objectname:  rs.ObjectName(id,"No name")

Yeah, I was going to say the same thing. That object component requires a name input.

rs.ObjectName(object_id, name=None)
name (str, optional): the new object name. If omitted, the current name is returned

Hi Helvetosaur,

Just after I posted I read about None, I had thought it was text not a variable so I used the line below with None not in inverted commas and it worked, thank you for your reply it is good to see as many options as possible. My line will only name it in print but your will name the actual point in Rhino so probably the best solution.

if objectname is None: objectname = “No Name”

Kind Regards

Roger Davies

Geo-Spatial Survey Solutions Ltd

Mobile 07713 160041

WWW.geo-spatial.co.uk