Subcategories such as Fascias not binding parameters

Subcategories such as Fascias not binding parameters

mohd.fadel
Enthusiast Enthusiast
251 Views
2 Replies
Message 1 of 3

Subcategories such as Fascias not binding parameters

mohd.fadel
Enthusiast
Enthusiast

Hello,

 

I'm trying to bind a shared parameter to certain subcategories such as Roof Soffits and Fascias. I can see the categories being added to the categoryset, however, the parameters are not being bonded to these subcategories. Here is a snippet of what i'm trying to achieve:

 

 

 

 

 

Categories categories = doc.Settings.Categories;
            CategorySet catSet = app.Create.NewCategorySet();
            foreach (Category c in categories)
            {
                if (c.AllowsBoundParameters)
                {
                    catSet.Insert(c);

                    CategoryNameMap subcats = c.SubCategories;
                    foreach (Category c1 in subcats)
                    {
                        if (c1.AllowsBoundParameters)
                        {
                            catSet.Insert(c1);
                        }
                    }
                }
            }

if (defGroup.Name == "Test")
                {
                    var v = (from ExternalDefinition d in defGroup.Definitions select d);

                    using (Transaction t = new Transaction(doc))
                    {
                        t.Start("Add Shared Parameters");
                        foreach (ExternalDefinition eD in v)
                        {
                            InstanceBinding newIB = app.Create.NewInstanceBinding(catSet);
                            doc.ParameterBindings.Insert(eD, newIB, BuiltInParameterGroup.PG_GENERAL);
                        }
                        t.Commit();
                    }
                }

 

 

 

 

 

Any help is much appreciated.

 

Regards,

 

M.

0 Likes
Accepted solutions (1)
252 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

Have you tried binding OST_Fascia on it's own without iteration of it?

 

You also have to allow for when the binding may already exist i.e. when to use ReInsert.

 

Also detail if you see the binding being added (by iteration of ExternalDefinitions) but nothing happens.

0 Likes
Message 3 of 3

mohd.fadel
Enthusiast
Enthusiast

Hello friend,

 

"You also have to allow for when the binding may already exist i.e. when to use ReInsert"

 

That did the trick.

 

Thank you for your help!!

 

M.

0 Likes