Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to change line style via API. Just like linework command's funcationality.

3 REPLIES 3
Reply
Message 1 of 4
2632647767
1407 Views, 3 Replies

How to change line style via API. Just like linework command's funcationality.

 

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!!!

3 REPLIES 3
Message 2 of 4
BIM.Frankliang
in reply to: 2632647767

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 🙂

 

名片.png

 

 

 

Message 3 of 4

Does this also incorporate invisible line style?

Message 4 of 4
lionel.kai
in reply to: 2632647767

I posted an Idea for this requested functionality here:

 

API access to Linework tool (get and set edge/line overrides) - Autodesk Community


Lionel J. Camara
BIM Manager at KAI Hawaii, Inc. - Structural and Forensic Engineers
Autodesk Certified Professional

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community