Change Imported CAD layer color

Yes, just use List.Map:

Also, I’ve found a hack to get Python to force the line colour update without you having to hide/unhide the reference:

It’s pretty strightforward really; I’ve simply automated the hide/unhide step.

#Copyright 2016. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.co.uk
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.co.uk package: bimorphNodes
#GitHub: https://github.com/ThomasMahon/bimorphNodes/

    import clr

    # Import RevitAPI
    clr.AddReference("RevitAPI")
    import Autodesk
    from Autodesk.Revit.DB import *

    clr.AddReference("RevitAPIUI")
    import Autodesk
    from Autodesk.Revit.UI import *

    # Import DocumentManager and TransactionManager
    clr.AddReference("RevitServices")
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager
    from System.Collections.Generic import *

    doc = DocumentManager.Instance.CurrentDBDocument

    dwgImport = UnwrapElement(IN[0])
    name = IN[1]
    col = IN[2]
    # "Start" the transaction
    TransactionManager.Instance.EnsureInTransaction(doc)

    catSub = dwgImport.Category.SubCategories
    catSub.Item[name].LineColor = Color(col[0], col[1], col[2])

    vId = List[ElementId]( )
    vId.Add(dwgImport.Id)

    v = Autodesk.Revit.UI.UIDocument(doc).ActiveView
    v.HideElements(vId)
    v.UnhideElements(vId)

    TransactionManager.Instance.TransactionTaskDone()
5 Likes