How to rename a constraint?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

How to rename a constraint?

Post by Roy_043 »

I am trying to rename a constraint in a sketch. The code below does not work somehow. How can this be done? Note that my test sketch has only 1 DistanceX constraint.

Code: Select all

for constr in App.ActiveDocument.Sketch.Constraints:
    if constr.Type == "DistanceX":
        constr.Name = "Width"
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: How to rename a constraint?

Post by Chris_G »

Code: Select all

sketch.renameConstraint(constraint_idx, u'new_name')
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to rename a constraint?

Post by Roy_043 »

Thanks.
Post Reply