Dear Revit API team,
Users can change element's geometry's edge line style by Revit's linework command。 it is good to have this command. However there are too much work to change line style for a normal project, because there are many views needing this work. It takes long time for designers to change tremendous lines' style by using linework command.
Designers spend much time by using linework command. They are not willing to use Revit to produce the shopping drawing, for the work efficiency is very low. More than 5 big design firms want addins that can help them to improve the work efficiency to change line style.
In a word, changing line style is an important factor for Revit's adoption in design companies.
if Revit provide the API to change the specified geometry's edge line style, then we can develop addins for designers. Then addins can change edges' line type for many lines in short time. That will save a lot of time for users. Revit will get more popular in design companies.
for example, give a edge's reference and the line style id, that the API can change the line style for the given line in a specified view.
Once again, this API is very very important。 we wish to have the API as soon as possible. Please log this wish to the SPR. Thanks much!!!
Hi,
Change Line style can be supported in Revit 2018, you could try codes below:
var linePatternElements = new FilteredElementCollector(doc).OfClass(typeof(LinePatternElement)).ToList();
var categories = doc.Settings.Categories;
var lineCat = categories.get_Item(BuiltInCategory.OST_Lines);
var subcats = lineCat.SubCategories;
Category matchedItem = subcats.get_Item(LineStyleName); matchedItem.SetLineWeight(LineWidth,GraphicsStyleType.Projection); matchedItem.LineColor = new Color(red, green, blue); var linePatternElem = linePatternElements.FirstOrDefault(x => x.Name == LineStyleName); if (linePatternElem != null) { matchedItem.SetLinePatternId(linePatternElem.Id,GraphicsStyleType.Projection); }
if you want to change Line Pattern, you can use:
var lpElement = matchedItem as LinePatternElement; var oldPattern = lpElement.GetLinePattern(); var lineSegs = new List<LinePatternSegment>(); foreach (var seg in mydata) { var segType = (LinePatternSegmentType)Enum.Parse(typeof(LinePatternSegmentType), seg.Key); var segValue = Convert.ToDouble(seg.Value); lineSegs.Add(new LinePatternSegment(segType, segValue)); } try { oldPattern.SetSegments(lineSegs); lpElement.SetLinePattern(oldPattern); } catch{ }
Note that codes must run in Transaction 🙂
I posted an Idea for this requested functionality here:
API access to Linework tool (get and set edge/line overrides) - Autodesk Community