How to assign Global Parameter to Symbol with no instance?

How to assign Global Parameter to Symbol with no instance?

TheCadmonkeyCouch
Participant Participant
306 Views
1 Reply
Message 1 of 2

How to assign Global Parameter to Symbol with no instance?

TheCadmonkeyCouch
Participant
Participant

I have two external commands that I am trying to combine into one. Each one functions correctly by itself.

When command loads a titleblock family. The other function assigns a set of global parameters to the symbol parameters of the titleblock family that you select in the sheet view.

 

What I am now trying to do is after loading the title block family into the document, assign the global parameters to the symbol parameters before I place an instance of the Title block onto a sheet.

 

Is this possible, or does an instance of the family need to be placed on a sheet first? You can double-click on the Symbol in the project browser within Revit which opens the Type Properties and manually assign them.

 

When I snoop the Symbol in the Project browser I see that the element id is -1, but the symbol parameters have a 7 digit ID number.

 

I am using a filtered element collector and filtering for only TitleBlocks, then looping through each until the name matches my criteria.

 

When I try to get the basic element information functions, (straight from the ADN labs), it errors out as the non instanced Titleblock has no Element ID.

Here is the code snip.

 

 

    ElementClassFilter fiFilter = new ElementClassFilter(typeof(FamilyInstance));

    FilteredElementCollector collector = new FilteredElementCollector(doc);
                
    ElementCategoryFilter tbFilter = new ElementCategoryFilter(BuiltInCategory.OST_TitleBlocks);



    collector.WherePasses(tbFilter);
    //collector.WherePasses(fiFilter);



    foreach (Element e in collector) 
    {

        // if (e.Name == "Paragon 24x36")
        //{

        // (2) Let's see what kind of element we got.
        ShowBasicElementInfo(e);


        ElementId elemTypeId = e.GetTypeId();
        ElementType elemType = (ElementType)doc.GetElement(elemTypeId);

            
      //}
        TaskDialog.Show("Element", e.Name);
    }

    // Modify document within a transaction
    using (Transaction tx = new Transaction(doc))
    {
        tx.Start("Transaction Name");
        tx.Commit();
    }

    return Result.Succeeded;
}
public ElementId GetGlobalParameterByName(Autodesk.Revit.DB.Document document, String name)
{
    return GlobalParametersManager.FindByName(document, name);
}

public void ShowBasicElementInfo(Element element)
{
    // lets see what kind of element we got
    //
    string s = "You Picked: " + "\n";
    s += " Class Name = " + element.GetType().Name + "\n";
    s += " Category = " + element.Category.Name + "\n";
    s += " Element id = " + element.Id.ToString() + "\n" + "\n";

    // and check its type info.
    //
    ElementId elementTypeId = element.GetTypeId();
    ElementType elemType = (ElementType)doc.GetElement(elementTypeId);

    s += "Its ElementType:" + "\n";
    s += " Class Name = " + elemType.GetType().Name + "\n";
    s += " Category = " + elemType.Category.Name + "\n";
    s += " Element type id = " + elemType.Id.ToString();

    // finally show it.

    TaskDialog.Show("Basic Element Info", s);

    Parameter para = elemType.LookupParameter("Not For Construction");

}

 

 

 

I have been searching through the SDK.chm and The Building Coder's site but haven't found how to address a Symbol that is in the Model File but not placed as an instance yet.

 

Thank you for your time.

0 Likes
Accepted solutions (1)
307 Views
1 Reply
Reply (1)
Message 2 of 2

TheCadmonkeyCouch
Participant
Participant
Accepted solution

I have been able to figure this out.

I need to stop looking for an Element Id and just use an if statement to match the symbol name, then use lookup parameter and go from there.

0 Likes