DefinitionGroup Set Name and Iceland Blue Lagoon

By Jaime Rosales

After a short week, Friday is here, and I want to take the opportunity for wishing all  of you a very relaxing first weekend of September, enjoy your activities and recharge those batteries for next week. I had an amazing trip for my honeymoon and still have my batteries fully recharged, how can I not, just check it out where I got mine like that.

Blue Lagoon, Iceland.

IMG_2708

Back to Revit.

Will keep this post short since it’s Friday. Here is a snippet of code that I got from one of our Revit Engineers regarding the DefinitionGroup setting of its name. Unfortunately what one of our customers needed was to rename the name on the DefinitionGroup but since it’s a read-only property, that couldn’t be approached. 

Here I share the code for you to try it. Enjoy!

public static DefinitionGroup GetOrCreateSharedParamsGroup  (DefinitionFile defFile, string grpName){  try // generic  {   DefinitionGroup defGrp = defFile.Groups.get_Item(grpName);   if (null == defGrp) defGrp = defFile.Groups.Create(grpName);   return defGrp;  }  catch (Exception ex)  {   MessageBox.Show(string.Format("ERROR: Failed to get or            create Shared Params Group: {0}", ex.Message));   return null;  }}

Thank you for reading. Have a great weekend.


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading