I am trying to update layer transparency values through Dynamo in Civil 3D 2020. I also was updating other values like color or line type and did not experience any problems.
According to docs (https://help.autodesk.com/view/OARX/2020/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_Colors_Transparency_Transparency_byte), transparency can be created with byte value.
When I am using Transparency(b’50’ or bytes(50)) I get a warning “TypeError: expected Byte, got bytes”.
When insert normal int value like Transparency(50) I get “Cannot convert numeric value 50 to TransparencyMethod. The value must be zero.” I don’t get any error with zero, but obviously the point is to introduce my own values, not zero.
def set_layer_transparency(layer, layerTransparency):
global adoc
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
_layerTable = t.GetObject(db.LayerTableId, OpenMode.ForRead)
if _layerTable.Has(layer.Name):
_layerTableRecord = t.GetObject(_layerTable[layer.Name], OpenMode.ForWrite)
# Amend layer transparency
_layerTableRecord.Transparency = Transparency(b'50')
t.Commit()
return _layerTableRecord