Paneling Tools - Index Numbers without Brackets?

When using PtSerializeObjectsName, is there any way to have index numbers without brackets? We like to have the part number (Object Name) engraved on our CNC parts and have an automated setup to do that, but the brackets are unnecessary for our purposes.

What we get now: set Prefex as A-A-, we get A-A-(1), A-A-(2),…, A-A-(n)
What we would ideally have: A-A-1, A-A-2,…, A-A-n

I’d go in and fix it manually, but we’re talking assemblies with hundreds of parts!

If there’s no way within Paneling Tools…I ended up taking the opportunity to learn a little bit of Python and went through renaming the parts that way. No more brackets! Our CNC programmers and operators can breathe a very small sigh of relief!

I can probably improve on it - be kind, it’s been a long time since I did programming (C and Java, at that), and I don’t actually know Python yet, so I’m just cribbing syntax from examples as I go! :stuck_out_tongue:

import rhinoscriptsyntax as rs
from Rhino import *
from Rhino.DocObjects import *
from Rhino.Commands import *
from scriptcontext import doc

select objects to remove brackets from
obj_ids = rs.GetObjects(“Select objects to remove brackets”)

count = -1
for rhino_obj in obj_ids:
count +=1
obj_name = rs.ObjectName(obj_ids[count])

left_bkt_index = obj_name.find('(')
if left_bkt_index == -1:
    continue #continue here if ( isn't found in the string
obj_prefix = obj_name[0:left_bkt_index]
obj_number = obj_name[left_bkt_index+1:-1]

object_new_name = obj_prefix + obj_number

Nice job.
I have a RhinoScript that I wrote to change names and clean up that I can dig and post as well.

1 Like

That’d be awesome, Rajaa!

I did notice one issue with the code I slapped together - if I make it into a command using aliases, and hit Escape before the command is finished (so before I select objects, etc), it comes up with the error:

"Message: iteration over non-sequence of type NoneType

line 30, in (our file path)"

Is there a way to have it terminate cleanly if I try to Escape out of it?