How to Set the Leader Visibility Type for a Label?

Hi,

I’m trying to change the pipe label leader visibility setting by a routine in pyhton, but it’s not working.

I want to switch from “From Label Style” to “Always Hide”

This is my code:

# Load the Python Standard and DesignScript Libraries
import sys #sys is a fundamental Python library - here, we're using it to load in the standard IronPython libraries
import clr #This is .NET's Common Language Runtime. It's an execution environment that is able to execute code from several different languages.

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry') #A Dynamo library for its proxy geometry
#classes. You'll only need this if you're interacting with geometry
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('Civil3DNodes')
clr.AddReference('AutoCADNodes')

import Autodesk #Loads the Autodesk namespace
# Import references from AutoCAD
AAR = Autodesk.AutoCAD.Runtime
AAA = Autodesk.AutoCAD.ApplicationServices #Setting a handle to the currently-open instance of the AutoCAD application
AAD = Autodesk.AutoCAD.DatabaseServices
AAE = Autodesk.AutoCAD.EditorInput
AAG = Autodesk.AutoCAD.Geometry
AADy = Autodesk.AutoCAD.DynamoNodes

AUX = Autodesk.Aec.DatabaseServices

OP = AAD.OpenMode
TS = AAD.Transaction

# Import references from Civil3D
ACA = Autodesk.Civil.ApplicationServices #Setting a handle to the currently-open instance of the Civil3D application
ACD = Autodesk.Civil.DatabaseServices
ACDy = Autodesk.Civil.DynamoNodes

AD = ACA.CivilApplication.ActiveDocument #Finally, setting up handles to the active Civil3D document
AC = Autodesk.Civil

adoc = AAA.Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor


#Inputs:
#IN[0][0] -> Pipe Label

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # E vem ai:
            Object = TS.GetObject(t,IN[0][0].Id,OP.ForWrite)
            Object.UpgradeOpen()
            
            Object.LeaderVisibility.AlwaysHide
                            
            t.Commit()
            
# Assign your output to the OUT variable.
OUT =  Object

Hi @andre.demski,

As written, the LeaderVisibility property is being accessed, but I don’t think you’ve actually set the value. It would need to be set to one of the members in the LeaderVisibilityType enumeration.

2 Likes

Thank you very much! I thought about what you said and tested it that way and it worked!

image

# Load the Python Standard and DesignScript Libraries
import sys #sys is a fundamental Python library - here, we're using it to load in the standard IronPython libraries
import clr #This is .NET's Common Language Runtime. It's an execution environment that is able to execute code from several different languages.

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry') #A Dynamo library for its proxy geometry
#classes. You'll only need this if you're interacting with geometry
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('Civil3DNodes')
clr.AddReference('AutoCADNodes')

import Autodesk #Loads the Autodesk namespace
# Import references from AutoCAD
AAR = Autodesk.AutoCAD.Runtime
AAA = Autodesk.AutoCAD.ApplicationServices #Setting a handle to the currently-open instance of the AutoCAD application
AAD = Autodesk.AutoCAD.DatabaseServices
AAE = Autodesk.AutoCAD.EditorInput
AAG = Autodesk.AutoCAD.Geometry
AADy = Autodesk.AutoCAD.DynamoNodes

AUX = Autodesk.Aec.DatabaseServices

OP = AAD.OpenMode
TS = AAD.Transaction

# Import references from Civil3D
ACA = Autodesk.Civil.ApplicationServices #Setting a handle to the currently-open instance of the Civil3D application
ACD = Autodesk.Civil.DatabaseServices
ACDy = Autodesk.Civil.DynamoNodes

AD = ACA.CivilApplication.ActiveDocument #Finally, setting up handles to the active Civil3D document
AC = Autodesk.Civil

adoc = AAA.Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor


#Inputs:
#IN[0][0] -> Label

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # E vem ai:
            Object = TS.GetObject(t,IN[0][0].Id,OP.ForWrite)
            Object.UpgradeOpen()
            
            Object.LeaderVisibility = Object.LeaderVisibility.AlwaysHide
                            
            t.Commit()
            
# Assign your output to the OUT variable.
OUT =  Object.LeaderVisibility

2 Likes