Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello! I'm writing a plugin to move elements from one level to another.
private void TransferringElements(object sender, RoutedEventArgs e)
{
var newLevel = new FilteredElementCollector(_doc)
.OfClass(typeof(Level)).FirstOrDefault(x => x.Name == importLevelName) as Level;
using (Transaction transaction = new Transaction(_doc, "Transaction"))
{
transaction.Start();
foreach (ElementId elementID in ElementsByLevel[exportLevelName])
{
Element element = _doc.GetElement(elementID);
BuiltInParameter[] levelExportParametrs = CommandChangeLevel.GetParametersForMovingItems(element);
// The required parameter is taken from the Dictionary depending on the element type
var levelNameParameter = element.get_Parameter(levelExportParametrs[0]);
if (levelNameParameter?.HasValue == true && levelNameParameter.IsReadOnly == false)
{
levelNameParameter.Set(newLevel.Id);
}
}
transaction.Commit();
}
}
I'm facing some problems:
1. "Object not Cutting anything". How can I fix this situation?
2. How can I get the SuperComponent value of an element?
Solved! Go to Solution.