Auto-name&numbering of objects


(Willem Derks) #1

Hi,

Per email I was requested for a script to auto-name object with numbering:

I would like now to know if it is possible to have a script how create the name of following a number order, as example kn01, kn02, kn03, kn04….
The problem is, all the lines in my project should have a name with an associated number
I would like to select a couple of lines and the script give the names.

Does anyone have such script laying around?
I’m on a tight schedule and cannot help right now.

Cheers
-Willem


(Dale Fugier) #2

Here is a simple one:


(Steve Baer) #3

Just because it is Friday and we need more python samples, here’s a python version of Dale’s sample :blush:

""" August 2013
Shamelessly stolen from Dale's AutoNameObjects.rvb
"""
import rhinoscriptsyntax as rs

def AutoNameObjects():
    msg = "Select objects to automatically name"
    objects = rs.GetObjects(msg, rs.filter.allobjects, True, True)
    if not objects: return
    
    prefix = rs.GetString("Object name prefix")
    if not prefix: return
    
    width = len(str(len(objects)+1))
    for i, obj in enumerate(objects):
        name = prefix + str(i+1).rjust(width, '0')
        rs.ObjectName(obj, name)


AutoNameObjects()

#4

Anyway to modify one of these scripts to give the same name to duplicate objects regardless of there location and I would only need it to work on closed polysurfaces.

Brian


#5

It’s almost impossible to tell if one object is an exact duplicate of another if it has been displaced… One could check a number of criteria - same volume, surface area, number of sub-surfaces etc. but it might not be guaranteed 100% if something tiny has changed.

–Mitch


#6

Tiny as in 1/16" difference would be fine…Tiny as in 1/8" would not. I work in stone

Mitch I downloaded your scripts and if I run remapobjs to world (3 point) on each one then seldup picks them up…? I’m sure that doesn’t help much.

Brian