Announcement

Collapse
No announcement yet.

Transparency deprecated in 2015, recommended alternative not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Transparency deprecated in 2015, recommended alternative not working

    Hi,

    I've been changing the transparency of a model in Revit 2014 using the ".SurfaceTransparency" property. Works like a charm, but the property is deprecated in Revit 2015 and the IDE is recommending to use the new Get/Set ViewDisplayModel methods. So, I tried below code to set the transparency on the view;

    Code:
    var m = myView.GetViewDisplayModel();
    m.Transparency = value;
    myView.SetViewDisplayModel(m);
    This results in an ArgumentException: with the message "The silhouette line style id is not a valid line style to apply to the view."

    Dumping the ViewDisplayModel results in below values;

    Code:
    {Autodesk.Revit.DB.ViewDisplayModel}
        EnableSilhouettes: false
        IsValidObject: true
        ShowHiddenLines: ByDiscipline
        SilhouetteEdgesGStyleId: {-1}
        SmoothEdges: false
        Transparency: 75
    I can imagine "-1" being an invalid ID but I don't care about the line. I only want to change the transparency.

    If anyone can point out my mistake, I'd be happy

    #2
    Here is a small macro that will set just the transparency of the active view to 50%:

    Code:
    public void ViewTrans()
    {
    	Document doc = ActiveUIDocument.Document;
    		
    	using(Transaction t = new Transaction(doc, "View Transparency 50"))
    	{
    		t.Start();
    
                    View active = doc.ActiveView;
    		ViewDisplayModel vdm = active.GetViewDisplayModel();
    	
    		vdm.Transparency = 50;
    		active.SetViewDisplayModel(vdm);
    
    		t.Commit();
    	}
    	
    }
    Troy Gates - Director of Design Technology
    KTGY Group, Inc - http://twitter.com/troygates

    Comment


      #3
      Troy, thanks for confirming that my code is correct. Apparently Revit does not accept the entire ViewDisplayModel if there's an invalid SilhouetteEdgesGStyleId. Setting that to a valid value fixes the issue. Disabling de EnableSilhouettes property does not change that.

      I'd say that simply qualifies as a bug.

      Comment


        #4
        I didn't get the error you get, mine works well for just changing the transparency.
        Troy Gates - Director of Design Technology
        KTGY Group, Inc - http://twitter.com/troygates

        Comment


          #5
          Originally posted by troygates View Post
          I didn't get the error you get, mine works well for just changing the transparency.
          Ah, are you implying that one can change transparency, even when the silhouette is already defined as "-1"?

          Let's just forget about this completely

          Comment


            #6
            Does this work in the family document? as i cant set any silhouette lines there

            if i try to set any of the properties or even construct an instance of the vdm i get an error the silhouette display model is not set. And i cant set it in the family doc. If not how does one turn on the edges in shaded mode??

            //Show edges needs a silhouette line style
            ViewDisplayModel vdm = view3D.GetViewDisplayModel();

            view.SetViewDisplayModel(vdm);

            Comment

            Related Topics

            Collapse

            Working...
            X