Results 1 to 3 of 3

Thread: Getting Global Parameter Value

  1. #1
    All AUGI, all the time dduarte's Avatar
    Join Date
    2005-03
    Location
    Greater Los Angeles
    Posts
    546
    Login to Give a bone
    0

    Default Getting Global Parameter Value

    I have a Yes/No Parameter in Global Parameters that I am trying to get the value of.

    Code:
    ElementId gpId = GlobalParametersManager.FindByName(doc, "My Parameter);
    GlobalParameter gpGlobal = doc.GetElement(gpId) as GlobalParameter;
    ParameterValue gpValue = gpGlobal.GetValue();
    TaskDialog.Show("Value", gpValue.ToString());
    In revit 2018-2021

    Any suggestions? Thanks
    David

  2. #2
    All AUGI, all the time dduarte's Avatar
    Join Date
    2005-03
    Location
    Greater Los Angeles
    Posts
    546
    Login to Give a bone
    0

    Default Re: Getting Global Parameter Value

    simplistic, but seems to work

    Code:
    ElementId gpId = GlobalParametersManager.FindByName(doc, "My Parameter");
    GlobalParameter gpParam = doc.GetElement(gpId) as GlobalParameter;
    var gpValue = gpParam.GetValue();
    var gpIpv = gpValue as IntegerParameterValue;
    int gpInteger = gpIpv.Value;
    Last edited by dduarte; 2020-05-05 at 10:14 PM.
    David

  3. #3
    Woo! Hoo! my 1st post
    Join Date
    2020-05
    Posts
    1
    Login to Give a bone
    0

    Default Re: Getting Global Parameter Value

    Here is the solution:
    A: List<GlobalParameter> globalParameters = new List<GlobalParameter>();
    // Here get all global parameter element Id from model.
    List<ElementId> ele = GlobalParametersManager.GetAllGlobalParameters(doc).ToList();

    foreach (ElementId item in ele)
    {
    // Get global parameter from element Id.
    var parameterSet = doc.GetElement(item) as GlobalParameter;
    // Check if parameter Type if type is YesNo then add in separate list.
    if (parameterSet.GetDefinition().ParameterType == ParameterType.YesNo)
    {
    globalParameters.Add(parameterSet);
    }
    }
    // Get one by one global parameter value
    foreach (GlobalParameter parameter in globalParameters)
    {
    var pValue = parameter.GetValue();
    var gpIpv = pValue as IntegerParameterValue;
    int gpInteger = gpIpv.Value;
    }

    Thank You!

Similar Threads

  1. 2018: link Visibility, Linear Parameter, or Point Parameter to CTAB value
    By dgregory85 in forum Dynamic Blocks - Technical
    Replies: 0
    Last Post: 2018-09-20, 03:58 PM
  2. 2017: Family parameter value to acquire host parameter value
    By ray_bongalon in forum Revit Architecture - General
    Replies: 7
    Last Post: 2017-06-13, 11:13 AM
  3. Parameter Working Range (Maximum and Minimum Parameter Value)
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2017-03-30, 07:52 PM
  4. Replies: 0
    Last Post: 2013-07-26, 11:11 AM
  5. Global variable/parameter/attribute library?
    By trailbarge in forum AutoCAD General
    Replies: 4
    Last Post: 2009-08-31, 06:49 PM

Tags for this Thread

Posting Permissions

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