How to set smooth line with anti - aliasing for Current View ?

How to set smooth line with anti - aliasing for Current View ?

Anonymous
Not applicable
1,046 Views
2 Replies
Message 1 of 3

How to set smooth line with anti - aliasing for Current View ?

Anonymous
Not applicable

Hi everyone,

 

I am trying to set the smooth line with anti - aliasing  for the active view by following code: 

 

                                viewForPreview.AreAnnotationCategoriesHidden = true;
                                viewForPreview.AreImportCategoriesHidden = true;
                                viewForPreview.DetailLevel = ViewDetailLevel.Fine;
                                viewForPreview.DisplayStyle = DisplayStyle.Realistic;

                                ViewDisplayModel displayModel = viewForPreview.GetViewDisplayModel();
                                displayModel.EnableSilhouettes = false;  
                                displayModel.SmoothEdges = true;
                                displayModel.ShowHiddenLines = ShowHiddenLinesValues.ByDiscipline;
                                viewForPreview.SetViewDisplayModel(displayModel);

But when I run the code, there was an error : " the silhouette line style id is not a valid line style to apply to the view" : 

Capture.PNG

If you have any experience with this problem, please help me. 

Thank you so much for your help.

 

Best Regards,

 

Ninh Truong

0 Likes
1,047 Views
2 Replies
Replies (2)
Message 2 of 3

Moustafa_K
Advisor
Advisor

hi,

you need to first set the linestyle of the Silhouette Edges, so that enabling the Silhouette have a proper line style to display

var lstyles = new FilteredElementCollector(doc).OfClass(typeof(GraphicsStyle));
var lstyl = lstyles.Where(o => o.Name.Contains(mylinestylename)).FirstOrDefault();
displayModel.SilhouetteEdgesGStyleId = lstyl;

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
Message 3 of 3

michael-coffey
Advocate
Advocate

I'm having this same issue.  @Moustafa_K You said that "you have to set a line style to enable them" but you can cleary see in the sample code that Silhouettes are being set to false:

displayModel.EnableSilhouettes = false;

  Why would the line style need to be set?

In Revit Lookup, the line style returns a value of "< null >".  Setting null returns a different error that states that it can't be set to null.  Using ElementId.InvalidElement doesn't work either.  Has anyone figured out a workaround?

0 Likes