History;
I’m struggling here with changing the LineStyle of a line that is already drawn. I’m assuming I need to draw the line and than modify the linestyle of the 1 that is drawn.
I found this in the Revit API Documentary - LineStyle
I’m assuming I use the C# and than convert that into what I believe Python will be (Newbie Question - Is there a python dictionary similar to this Revit API C#? or do i just always take a calculated guess on the conversion? I’ve been searching all over the forums/google and haven’t stumbled across a full list yet)
So based on that I believe i’m supposed to use
Element.LineStyle(get, set.12404)
Not a pyRevit solution (then again this isn’t a pyRevit forum), but you could do this in Dynamo with all out of the box nodes (the design script in code blocks is just to illustrate the before and after):
You are awesome, That managed to work with a few minor tweaks. I feel its very complicated tho, is that normal? or is there a simplier way of doing it.
I need to work out how to loop it now, So it does multiple lines next challenge for me…
Thank you heaps
# pyRevit
import clr
import math
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app = __revit__.Application
view = doc.ActiveView
#----
__doc__ = '0.18 Continuous Line'
#Transaction1
t = Transaction(doc, "Draw Line")
t.Start()
#Pick Points
p1 = uidoc.Selection.PickPoint("Click to specify instance location.")
p2 = uidoc.Selection.PickPoint("Click to specify instance location.")
#Commands
Line = Line.CreateBound(p1, p2)
NewLine = doc.Create.NewDetailCurve(view,Line)
#Linestyle
gsCat = Category.GetCategory(doc, BuiltInCategory.OST_Lines).GetGraphicsStyle(GraphicsStyleType.Projection).GraphicsStyleCategory.SubCategories
lineStyles = [i.GetGraphicsStyle(GraphicsStyleType.Projection) for i in gsCat]
lStyle = []
try:
lStyle.append(next(i for i in lineStyles if "Medium Lines"==i.Name))
except StopIteration:
pass
NewLine.LineStyle=lStyle[0]
t.Commit()