how to replace one dimension type (say bad) w/ another (say good) and delete/purge bad one

how to replace one dimension type (say bad) w/ another (say good) and delete/purge bad one

Ning_Zhou
Advocate Advocate
231 Views
0 Replies
Message 1 of 1

how to replace one dimension type (say bad) w/ another (say good) and delete/purge bad one

Ning_Zhou
Advocate
Advocate

i want to change non-standard dimension types to standard one and delete/purge non-standard ones, below is my attempt, "ChangeTypeId" will throw exception, any insight?

IEnumerable<DimensionType> dts = new FilteredElementCollector(doc).OfClass(typeof(DimensionType)).Cast<DimensionType>();
DimensionType good = dts.Where(q => q.Name.Equals("good")).First();
List<DimensionType> bads = dts.Where(q => q.Name.Contains("bad")).ToList();
foreach (DimensionType bad in bads)
using (Transaction t = new Transaction(doc))
{
t.Start("myTransaction");
bad.ChangeTypeId(good.Id); // 'This Element cannot have type assigned.'
t.Commit();
}

 

edit: figured out via Dimension instead of DimensionType, still wonder if doable via DimensionType directly?

0 Likes
232 Views
0 Replies
Replies (0)