See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Modify instance parameter of many Adaptive Component Curtain Panels

  1. #1
    AUGI Addict
    Join Date
    2009-03
    Location
    Somerville, MA
    Posts
    1,060
    Login to Give a bone
    0

    Default Modify instance parameter of many Adaptive Component Curtain Panels

    I keep meaning to learn the Revit API... I use scripting all the time for Rhino, but haven't gotten into it. So two questions:

    1. How difficult would it be to modify the instance parameter of ~13,000 Adaptive Component Curtain Panels? Currently, each AC panel has a "Panel ID" parameter, a 6-digit number. I want to remove the 100,000th place number and make it a 5-digit number. Would this be a reasonable first Add-In to do if I already know VB.net (to some extent)?

    2. And/or would somebody be willing to create this Add-In and/or help me create it?

  2. #2
    Member
    Join Date
    2013-09
    Location
    Boston
    Posts
    9
    Login to Give a bone
    1

    Default Re: Modify instance parameter of many Adaptive Component Curtain Panels

    Hi,

    Here's a macro that does what I think you are looking for. It finds every Generic Model instance whose family is "Diagnostic Tripod-3 point". It then gets the value of the "Panel ID" parameter, converts it to a string, gets a substring starting at the 2nd character, and converts this string back into an integer.

    If you are interested in learning more about the API, you might enjoy my class at bit.ly/revitapi at my blog at http://boostyourbim.wordpress.com/

    Regards
    Harry

    public void StripParamFirstDigit()
    {
    Document doc = this.ActiveUIDocument.Document;

    using (Transaction t = new Transaction(doc,"Set Parameter Value"))
    {
    t.Start();
    foreach (FamilyInstance fi in new FilteredElementCollector(doc)
    .OfClass(typeof(FamilyInstance))
    .OfCategory(BuiltInCategory.OST_GenericModel)
    .Cast<FamilyInstance>()
    .Where(q => q.Name == "Diagnostic Tripod-3 point"))
    {
    Parameter p = fi.get_Parameter("Panel ID");
    int curVal = p.AsInteger();
    int newVal = Convert.ToInt32(curVal.ToString().Substring(1));
    p.Set(newVal);
    }
    t.Commit();
    }
    }

  3. #3
    AUGI Addict
    Join Date
    2009-03
    Location
    Somerville, MA
    Posts
    1,060
    Login to Give a bone
    0

    Default Re: Modify instance parameter of many Adaptive Component Curtain Panels

    Thank you boostyourbim!

    I'll give this a try and see how it goes. I just started (for the third time) with Autodesk's "My First Plug-In" series and I'm very slowly working my way through it. I'll also look into your blog and class. Thank you.

    If you don't mind, I do have three questions:
    1. I am using the Curtain Panel category instead of Generic Model. Looking in the Revit API at the BuiltInCategory Enumeration, I find "OST_CurtainWallPanels". Is that how I should reference Curtain Panels?
    2. To change the family I want to look at, do I change "Diagnostic Tripod-3 point" to "Panel 3pt AC" or whatever else I've named it?
    3. I've tried creating and running this macro and two things happened. First, I get two Warnings as soon as SharpDevelop opens: "There was a mismatch between the processor architecture of the project building built "MSIL..." Second, when I run it, it does nothing. Here is everything from the SharpDevelop window (I had to add the "using..." :

    using System;
    using Autodesk.Revit.UI;
    using Autodesk.Revit.DB;
    using Autodesk.Revit.UI.Selection;
    using System.Collections.Generic;
    using System.Linq;

    namespace RenumberPanelIDs
    {
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.UI.Macros.AddInId("DD536125-D810-4EF2-B9AF-DC21C01369BC")]
    public partial class ThisApplication
    {
    private void Module_Startup(object sender, EventArgs e)
    {

    }

    private void Module_Shutdown(object sender, EventArgs e)
    {

    }

    #region Revit Macros generated code
    private void InternalStartup()
    {
    this.Startup += new System.EventHandler(Module_Startup);
    this.Shutdown += new System.EventHandler(Module_Shutdown);
    }
    #endregion

    public void StripParamFirstDigit()
    {
    Document doc = this.ActiveUIDocument.Document;

    using (Transaction t = new Transaction(doc,"Set Parameter Value"))
    {
    t.Start();
    foreach (FamilyInstance fi in new FilteredElementCollector(doc)
    .OfClass(typeof(FamilyInstance))
    .OfCategory(BuiltInCategory.OST_CurtainWallPanels)
    .Cast<FamilyInstance>()
    .Where(q => q.Name == "Panel 3pt AC"))
    {
    Parameter p = fi.get_Parameter("Panel ID");
    int curVal = p.AsInteger();
    int newVal = Convert.ToInt32(curVal.ToString().Substring(1));
    p.Set(newVal);
    }
    t.Commit();
    }

    TaskDialog.Show("Panel ID", "Your Panel IDs have been truncated");
    }
    }
    }

  4. #4
    Member
    Join Date
    2013-09
    Location
    Boston
    Posts
    9
    Login to Give a bone
    1

    Default Re: Modify instance parameter of many Adaptive Component Curtain Panels

    1. I am using the Curtain Panel category instead of Generic Model. Looking in the Revit API at the BuiltInCategory Enumeration, I find "OST_CurtainWallPanels". Is that how I should reference Curtain Panels?

    Yes

    2. To change the family I want to look at, do I change "Diagnostic Tripod-3 point" to "Panel 3pt AC" or whatever else I've named it?

    Yes

    3. I've tried creating and running this macro and two things happened. First, I get two Warnings as soon as SharpDevelop opens: "There was a mismatch between the processor architecture of the project building built "MSIL..." Second, when I run it, it does nothing.

    a) Ignore those "mismatch" warnings

    b) You could start by adding a TaskDialog in the foreach loop to see if the execution ever gets there. Also, this post has some suggestions about how to see what is happening when a macro runs
    http://boostyourbim.wordpress.com/20...ort-or-a-link/


    Quote Originally Posted by damon.sidel View Post
    Thank you boostyourbim!

    I'll give this a try and see how it goes. I just started (for the third time) with Autodesk's "My First Plug-In" series and I'm very slowly working my way through it. I'll also look into your blog and class. Thank you.

    If you don't mind, I do have three questions:
    1. I am using the Curtain Panel category instead of Generic Model. Looking in the Revit API at the BuiltInCategory Enumeration, I find "OST_CurtainWallPanels". Is that how I should reference Curtain Panels?
    2. To change the family I want to look at, do I change "Diagnostic Tripod-3 point" to "Panel 3pt AC" or whatever else I've named it?
    3. I've tried creating and running this macro and two things happened. First, I get two Warnings as soon as SharpDevelop opens: "There was a mismatch between the processor architecture of the project building built "MSIL..." Second, when I run it, it does nothing. Here is everything from the SharpDevelop window (I had to add the "using..." :

    using System;
    using Autodesk.Revit.UI;
    using Autodesk.Revit.DB;
    using Autodesk.Revit.UI.Selection;
    using System.Collections.Generic;
    using System.Linq;

    namespace RenumberPanelIDs
    {
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.UI.Macros.AddInId("DD536125-D810-4EF2-B9AF-DC21C01369BC")]
    public partial class ThisApplication
    {
    private void Module_Startup(object sender, EventArgs e)
    {

    }

    private void Module_Shutdown(object sender, EventArgs e)
    {

    }

    #region Revit Macros generated code
    private void InternalStartup()
    {
    this.Startup += new System.EventHandler(Module_Startup);
    this.Shutdown += new System.EventHandler(Module_Shutdown);
    }
    #endregion

    public void StripParamFirstDigit()
    {
    Document doc = this.ActiveUIDocument.Document;

    using (Transaction t = new Transaction(doc,"Set Parameter Value"))
    {
    t.Start();
    foreach (FamilyInstance fi in new FilteredElementCollector(doc)
    .OfClass(typeof(FamilyInstance))
    .OfCategory(BuiltInCategory.OST_CurtainWallPanels)
    .Cast<FamilyInstance>()
    .Where(q => q.Name == "Panel 3pt AC"))
    {
    Parameter p = fi.get_Parameter("Panel ID");
    int curVal = p.AsInteger();
    int newVal = Convert.ToInt32(curVal.ToString().Substring(1));
    p.Set(newVal);
    }
    t.Commit();
    }

    TaskDialog.Show("Panel ID", "Your Panel IDs have been truncated");
    }
    }
    }

  5. #5
    AUGI Addict
    Join Date
    2009-03
    Location
    Somerville, MA
    Posts
    1,060
    Login to Give a bone
    0

    Default Re: Modify instance parameter of many Adaptive Component Curtain Panels

    I took a hiatus from trying to get this working--got too busy--but now I'm back and have some more questions. Thank you, boostyourBIM, for your responses. I really appreciate it. To make sure I was even getting information from my curtain panel correctly, I tried something very simple:

    UIDocument uidoc = this.ActiveUIDocument;
    Document doc = uidoc.Document;

    Element panel = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select curtain wall panel"));
    Parameter param = panel.get_Parameter("Panel ID");

    int curVal = param.AsInteger();
    String newVal = curVal.ToString();

    TaskDialog.Show("Panel ID", newVal);

    When I selected a curtain panel (adaptive component) with the Panel ID parameter set to 703352.000000, the contents of the task dialog simply read 0. What do you think is happening?

  6. #6
    Member
    Join Date
    2013-09
    Location
    Boston
    Posts
    9
    Login to Give a bone
    0

    Default Re: Modify instance parameter of many Adaptive Component Curtain Panels

    What type of parameter is Panel ID in your model - integer or number? If it is "number", the you need to get the value with AsDouble() instead of AsInteger().

  7. #7
    AUGI Addict
    Join Date
    2009-03
    Location
    Somerville, MA
    Posts
    1,060
    Login to Give a bone
    0

    Default Re: Modify instance parameter of many Adaptive Component Curtain Panels

    Quote Originally Posted by boostyourbim417413 View Post
    If it is "number", the you need to get the value with AsDouble() instead of AsInteger().
    It is indeed of type "number" and changing it to AsDouble() gets the correct value. Thanks again for your help!

    I have now successfully modified the macro and run it on my ~13,000 curtain panel grid shell and it works like a charm.

    HERE IT IS:

    using System;
    using Autodesk.Revit.UI;
    using Autodesk.Revit.DB;
    using Autodesk.Revit.UI.Selection;
    using System.Collections.Generic;
    using System.Linq;

    namespace RenumberPanelIDs
    {
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.UI.Macros.AddInId("DD536125-D810-4EF2-B9AF-DC21C01369BC")]
    public partial class ThisApplication
    {
    private void Module_Startup(object sender, EventArgs e)
    {

    }

    private void Module_Shutdown(object sender, EventArgs e)
    {

    }

    #region Revit Macros generated code
    private void InternalStartup()
    {
    this.Startup += new System.EventHandler(Module_Startup);
    this.Shutdown += new System.EventHandler(Module_Shutdown);
    }
    #endregion

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

    using (Transaction t = new Transaction(doc,"Set Parameter Value"))
    {
    t.Start();

    foreach (FamilyInstance fi in new FilteredElementCollector(doc)
    .OfClass(typeof(FamilyInstance))
    .OfCategory(BuiltInCategory.OST_CurtainWallPanels)
    .Cast<FamilyInstance>()
    .Where(q => q.Name == "Metal" || q.Name == "Glass - Vision" || q.Name == "Glass - Low-Iron" || q.Name == "Glass - Frit" || q.Name == "Perforated Metal"))
    {
    Parameter p = fi.get_Parameter("Panel ID");
    double curVal = p.AsDouble();
    //TaskDialog.Show("Panel ID", "Panel ID is " + curVal.ToString());
    if (curVal > 100)
    {
    double newVal = Convert.ToDouble(curVal.ToString().Substring(1));
    //TaskDialog.Show("Panel ID", "Panel ID is " + newVal.ToString());
    p.Set(newVal);
    }
    }
    t.Commit();
    }

    TaskDialog.Show("Panel ID", "Renumbered all your friggin' panels, OK? OK.");


    }
    }
    }
    Last edited by damon.sidel; 2014-04-03 at 12:43 PM. Reason: Added Macro code

Similar Threads

  1. Replies: 0
    Last Post: 2015-08-07, 03:55 PM
  2. Replies: 0
    Last Post: 2015-08-07, 03:48 PM
  3. 2011: Adaptive Component - Curtain Panel Sub Categories
    By amstaples in forum Revit Architecture - General
    Replies: 0
    Last Post: 2012-02-17, 03:47 PM
  4. Problem adding Parameter in Adaptive Component
    By wfrst2008 in forum Revit Architecture - Families
    Replies: 2
    Last Post: 2011-11-10, 12:01 AM
  5. Adaptive Component Angle Parameter error
    By some-1-2 in forum Revit - Conceptual Design Tools
    Replies: 0
    Last Post: 2010-09-19, 06:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •