Reputation: 93
After banging my head for awhile trying to figure out how to change - using the Revit API - the linestyle of an existing detail line to another given the name of the linestyle, I finally figured it out.
No loops and no if statements like other proposed solutions.
#Purpose: Change linestyle of the selected detail line to
# another given the name of a linestyle.
#This code assumes you are using the Interactive Revit Python Shell dialog.
#I am also assuming that Revit Python Wrapper is installed and imported into RPS.
#I also assume that at least one line element is preselected before starting RPS.
#This was tested with Revit 2019.
SubCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines).SubCategories.Item["(AUE)_A_(05) Centerline"]
LineElement = selection[0] #"selection" is a varible supplied by RPS
#Using the Revit Python Wrapper for the Transaction.
#A try..except clause might be a good idea..
with rpw.db.Transaction ("T"):
LineElement.LineStyle = SubCat.GetGraphicsStyle (GraphicsStyleType.Projection)
Upvotes: 2
Views: 378