- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Salute,
IUpdater is triggered and run with no errors but model changes are undone for no obvious reason
Heeelp, I'm pulling my hair out since morning.
I'm creating an application that searches the document for Rooms and then uses each Room boundary to create a new floor this is done on my check list.
I'm creating an IUpdater so that if the user moves a wall it changes the rooms boundary and therefore uses the new room boundary to create a new floor and delete the old one, what happens is when i try to move a wall the iupdater is triggered and the code runs with no errors but then i find the wall back to its original location I don't really know why and I can't connect any dots!!!
here's my code for the iupdater execute method:
try
{
foreach (ElementId elemId in data.GetModifiedElementIds())
{
List<Floor> floorsByRoomsList = new List<Floor>();
Room r = doc.GetElement(elemId) as Room;
if (r != null)
{
SpatialElementBoundaryOptions sb = new SpatialElementBoundaryOptions();
sb.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreBoundary;
IList<IList<BoundarySegment>> loops = r.GetBoundarySegments(sb);
List<Floor> floorsInDoc = new List<Floor>();
floorsInDoc = GetAllFloors(doc);
foreach(Floor existFloor in floorsInDoc)
{
string floorMark = existFloor.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).AsString();
if (floorMark == r.Id.ToString())
{
Floor newFloor = null;
Opening newOpening = null;
if (loops.Count == 1)
{
#region the new floor properties
CurveArray floorprofile = Data.ObtainCurveArray(r);
FloorType fl = existFloor.FloorType;
Level level = r.Level;
bool bl;
if (existFloor.GetAnalyticalModel() == null)
bl = false;
else
bl = true;
#endregion
newFloor = doc.Create.NewFloor(floorprofile, fl, level, bl);
floorsByRoomsList.Add(newFloor);
}
else if (loops.Count > 1)
{
#region the new floor & opening properties
CurveArray floorprofile = Data.ObtainCurveArray(r);
FloorType fl = existFloor.FloorType;
Level level = r.Level;
bool bl;
if (existFloor.GetAnalyticalModel() == null)
bl = false;
else
bl = true;
CurveArray openingProfile = Data.ObtainOpeningCurveArray(r);
bool blO = true;
#endregion
newFloor = doc.Create.NewFloor(floorprofile, fl, level, bl);
floorsByRoomsList.Add(newFloor);
newOpening = doc.Create.NewOpening(newFloor, openingProfile, blO);
}
} // if the floor is not located inside room and its name is not equal to room id
else
{
continue;
}
}
} // if the modified element is not a room
else
{
continue;
}
foreach (Floor fl in floorsByRoomsList)
fl.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).Set(r.Id.ToString());
}
}
Solved! Go to Solution.