Hi guys, I was trying to use ResetLabel
for a group of COGO points with labels that were moved away. To achieve this, I created this Python node, where the input consists of the points’ handles as strings.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AeccDbMgd')
# Importar referencias
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.DatabaseServices import *
# Entrada: Lista de handles (strings) de los puntos COGO
handles = IN[0]
result = []
adoc = Application.DocumentManager.MdiActiveDocument
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
try:
for handle_str in handles:
# Convertir el string a un objeto Handle
handle = Handle(handle_str)
# Obtener el ObjectId usando el Handle
obj_id = db.GetObjectId(False, handle, 0)
if not obj_id.IsNull:
cogo_point = t.GetObject(obj_id, OpenMode.ForWrite)
if isinstance(cogo_point, CogoPoint):
cogo_point.ResetLabelLocation()
result.append(f"Handle {handle_str}: Éxito")
else:
result.append(f"Handle {handle_str}: No es un COGO Point")
else:
result.append(f"Handle {handle_str}: No encontrado")
t.Commit()
except Exception as e:
result.append(f"Error: {str(e)}")
t.Abort()
OUT = result
Could someone help me with this?
BTW, I was trying to use the ResetLabel
node from the Camber package, but I couldn’t figure out what the input for that node was. I tried many things, but nothing worked.
Thanks, guys!