Can anyone please give me the directions of nodes that can rename a Design Check either in Alignment and Profile toolspace? Once it’s created with an expression, it is impossible to rename it without creating another one and setting it in each set of Design Check using the native interface.
Here’s some quick code for you to try. I haven’t tested very thoroughly, so use at your own risk.
IN = old design check set name
IN = new design check set name
import sys import clr clr.AddReference('AcMgd') clr.AddReference('AcDbMgd') clr.AddReference('AeccDbMgd') from Autodesk.AutoCAD.ApplicationServices import * from Autodesk.AutoCAD.DatabaseServices import * from Autodesk.Civil.ApplicationServices import * from Autodesk.Civil.DatabaseServices import * adoc = Application.DocumentManager.MdiActiveDocument cdoc = CivilApplication.ActiveDocument def set_design_check_set_name(oldName, newName): global adoc global cdoc if not oldName or not newName: return with adoc.LockDocument(): with adoc.Database as db: with db.TransactionManager.StartTransaction() as t: # Change this to ProfileDesignCheckSets if you want to rename a profile design check oid = cdoc.Styles.AlignmentDesignCheckSets[oldName] checkSet = t.GetObject(oid, OpenMode.ForWrite) checkSet.Name = newName t.Commit() return checkSet OUT = set_design_check_set_name(IN, IN)
It’s up to me, thanks.
Is that right to input IN and IN as strings, right?
Are you using Civil 3D 2022?
Actually nevermind, I just realized that this isn’t what you were looking for. The code above is to rename a design check set, not a single design check. As far as I know it’s not possible to rename a design check via the API because the name property is readonly.
Yes, that’s it. True (and sad) story.
Should I leave this opened here?
@mzjensen a solution I’ve been thinking of is this one:
IN = old design check
IN = new design check
read IN expression
read IN description
create IN with IN expression and description
loop inside sets
if contains IN, add IN
Do you think it’s possible?
Yeah, I think that could work!
Great. I still don’t have this level of knowledge with python, but I’m going to try.