Message 1 of 8
Set value of Parameter, EditFamily fails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
whilst wanting to set the value of a Parameter, I get the following error on calling the appropriate family document:
// Get Family document for family
Document familyDoc = document.EditFamily(family);
exc.Message "The document is currently modifiable! Close the transaction before calling EditFamily." String
I read Jeremy's post entitled:
http://thebuildingcoder.typepad.com/blog/2012/05/edit-family-requires-no-transaction.html
But what is the upshot? Do I need to close the transactions, then run the one specifically for EditFamily?
Which command?
Thanks!
Transactions were set to: [TransactionAttribute(TransactionMode.Manual)]
Here is the test code:
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { init(); //Get application and document objects UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; FilteredElementCollector coll = new FilteredElementCollector(doc); try { //Define a Reference object to accept the pick result. Reference pickedRef = null; //Pick a group Selection sel = uiApp.ActiveUIDocument.Selection; pickedRef = sel.PickObject(ObjectType.Element, "Please select a group"); Element elem = doc.GetElement(pickedRef); Transaction trans = new Transaction(doc, "Set FamilyParameter"); trans.Start(); EditFamilyTypes_(doc, elem as FamilyInstance, "HT_STL_G_COMPONENT BORED TUNNEL TYPE", "HT_STL_G_ADAPTIVE BORED TUNNEL", 2.0); trans.Commit(); MessageBox.Show("Execute completed"); } catch (Exception exc) { Debug.WriteLine(exc); } return Result.Succeeded; }
public void EditFamilyTypes_(Document document, FamilyInstance familyInstance, string parmname, string symbolName, double newval) { if (null != familyInstance.Symbol) { // Get family associated with this Family family = familyInstance.Symbol.Family; // Get Family document for family Document familyDoc = document.EditFamily(family); if (null != familyDoc) { FamilyManager familyManager = familyDoc.FamilyManager; // look for parmname parameter and set to newval m FamilyParameter familyParam = familyManager.get_Parameter(parmname); if (null != familyParam) { familyManager.Set(familyParam, newval); } } } }