Imported Categories override in View

Hi,

I’m setting DWG line widths using object styles (thanks @Thomas_Mahon unfortunately the views are ignoring those settings, so i need to use visibility graphics…

However I can’t see an API method for this, would anyone be able to assist? Visibility is there and colour, but not line weight?

https://www.revitapidocs.com/2020/e2f50049-832c-9b72-70b1-2a0a96e16a60.htm

Actually, maybe it’s here…
https://www.revitapidocs.com/2020/1a43c153-cbaf-f89b-d298-93c6ff7d0ae0.htm

Cheers,

Mark

hmm… this only sets the object style, not the view :frowning:

importInstance = UnwrapElement(IN[0])
layerName = IN[1]
lineWeight = IN[2]
lineColour = Color(0,0,0)
	
subCategories = importInstance.Category.SubCategories
    
if subCategories.Contains(layerName):    
    TransactionManager.Instance.EnsureInTransaction(doc)
    subCategories.get_Item(layerName).SetLineWeight(lineWeight, GraphicsStyleType.Projection)
    TransactionManager.Instance.TransactionTaskDone()
    OUT = 'success'
else:
      OUT = 'fail'

Hi @Mark.Ackerley

May be create view template and apply it to views.

Hi Kulkul,

Thanks unfortunately the problem is having several hundred layers which need their width to be set… Just for 1 view would be fine.

Is it an API limitation do you think?

Cheers,

Mark

Edit: If Revit would just recognise the object style setting, none of this would be a problem!

Hi Mark,

If I understood correctly you can use the OOTB View.SetCategoryOverrides node.

Neat Alban, will try it now :slight_smile:

EDIT: Yes! thanks a lot :smiley:

Just incase you’re interested… The goal was to align lineweights in dwgs with the company colour table…It was a bit tricky, because I needed to extract the sub category colours which related to the dwg links I’m interested in…

#thanks to Konrad and Luke J

import clr
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# toProtoType etc.
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

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

nameEquals = IN[0]

gStyles = FilteredElementCollector(doc).OfClass(GraphicsStyle).ToElements()


#we need to get the name of the gStyle so we can filter to get the dwgs.... all the dwgs names will end in dwg
gStyleDwgCategoryList = []
for i in gStyles:
    if "dwg" in i.GraphicsStyleCategory.Name: 
        gStyleDwgCategoryList.append(i.GraphicsStyleCategory)

gStyleCategoryList = []
gStyleCategoryListName = []
#gStyleCategoryListColour = []

i = 0
while i < len(nameEquals):
    gStyleCategorySubList = []
    gStyleCategorySubListName = []
    gStyleCategorySubListColour = []
    for gSCat in gStyleDwgCategoryList:  
        if nameEquals[i] in gSCat.Name:
            gStyleCategorySubList.append(gSCat)
            gStyleCategorySubListName.append(gSCat.Name)
#            gStyleCategorySubListColour.append(gSCat.LineColor)            
    i = i + 1    
    gStyleCategoryList.append(gStyleCategorySubList)
    gStyleCategoryListName.append(gStyleCategorySubListName)
#    gStyleCategoryListColour.append(gStyleCategorySubListColour)

gStyleName = []
gStyleColour = []
for gSubL in gStyleCategoryList:
    gStyleSubCategories = []
    for gL in gSubL:
         gStyleSubCategories.append(gL.SubCategories)
         gStyleSubCategoriesList = [[] for i in range(0, len(gStyleSubCategories))]
         gStyleSubCategoriesListClr = [[] for i in range(0, len(gStyleSubCategories))]

    for index, item in enumerate(gStyleSubCategories):
        for i in item:
            gStyleSubCategoriesList[index].append(i.Name)

    for index, item in enumerate(gStyleSubCategories):
        for i in item:
            gStyleSubCategoriesListClr[index].append(i.LineColor)

    gStyleName.append(gStyleSubCategoriesList)
    gStyleColour.append(gStyleSubCategoriesListClr)

OUT =  gStyleCategoryListName, gStyleName, gStyleColour

AutoCAD Color Index RGB Equivalents.html.xlsx (25.2 KB) CAD to Revit Lineweights.xlsx (11.8 KB) Set CAD Layers Sheets.dyn (151.2 KB)

cad colours