Tuesday, November 19, 2013

Setting an Image's Visibility to Off in a Family

I am revamping several of our engineer's stamps for Revit 2014 and didn't want to go through the old process of converting their signature from an image to CAD and then importing to Revit. So I decided to just use the images and went to set the Visibility to a parameter and found it wasn't available (I already knew this from way back, but forgot about it).

Image in Family with no Parameter for Visibility

















Looking over the small list of parameters, it hit me. Why not make the Width and Height equal to 0 when I don't want to see the signature, thus setting it to not visible.

So I setup 3 parameters called Show Signature, Sig_W, and Sig_H. I then linked the Image's Width to Sig_W and Height to Sig_H. Lastly I created a formula for Sig_W and Sig_H to adjust the image size off of the parameter Show Signature's value.

New Parameters and Formulas


















Linking the Width and Height to the New Parameters

Monday, November 18, 2013

Quick Macro that creates 5 Dependent Views for the Current View

I had a user that needed to create 5 dependent views for 5 areas in a building across several views and disciplines. To save him time, I created this quick macro that will create 5 dependent views for the active view. This will save a lot of right-clicking on each view.

Code:


        public void CreateDependentViews()
        {
            UIDocument uidoc = this.ActiveUIDocument;
            Document doc = uidoc.Document;

            using(Transaction t = new Transaction(doc, "Duplicate View 5x"))
            {
                t.Start();
              
                int i = 0;
              
                while (i < 5)
                {
                    uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
                    i++;
                }               
                t.Commit();                   
            }           
        }


I expanded it a bit more and did some renaming based on Areas just to enhance it a bit.

Code:

        public void CreateDependentViews()
        {
            UIDocument uidoc = this.ActiveUIDocument;
            Document doc = uidoc.Document;

            using(Transaction t = new Transaction(doc, "Duplicate View 5x"))
            {
                t.Start();
               
                int i = 0;
               
                while (i < 5)
                {
                    ElementId dupViewId = uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
                    View dupView = doc.GetElement(dupViewId) as View;
                    char c = (char) (i + 65);
                    dupView.Name = uidoc.ActiveView.Name + " - AREA " + c.ToString();
                   
                    i++;
                }
               
                t.Commit();                   
            }           
        }