Message 1 of 10
Not applicable
05-10-2018
06:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to use a trick of transactions. I remove everything from the wall and check the intersection of the edge of the wall and the line from the side of the room. But I have an error when working with
ICollection <ElementId> generatingElementIds = wall.GetGeneratingElementIds (edges [0]);
An unhandled exception of type 'System.AccessViolationException' occurred in RevitDBAPI.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
What am I doing wrong?
SetComparisonResult intersectionPoint = SetComparisonResult.Disjoint;
using (Transaction ff=new Transaction(doc,"Get intersections"))
{
ff.Start();
using (SubTransaction deleteTransaction = new SubTransaction(doc))
{
deleteTransaction.Start();
if (idsFamilyInstance.Count > 0)
{
ICollection<Autodesk.Revit.DB.ElementId> deletedIdSet = new List<ElementId>();
deletedIdSet = doc.Delete(idsFamilyInstance);
if (0 == deletedIdSet.Count)
{
throw new Exception("Deleting the selected elements in Revit failed.");
}
}
doc.Regenerate();
Options optionswall = new Options();
optionswall.ComputeReferences = true;
GeometryElement geometryElement = wall.get_Geometry(optionswall);
foreach (GeometryObject geometry in geometryElement)
{
Solid geomSolidwall = geometry as Solid;
// Get the faces
foreach (Face face in geomSolidwall.Faces)
{
// doc.Regenerate();
intersectionPoint = face.Intersect(line);
if (intersectionPoint != SetComparisonResult.Disjoint)
{
break;
}
}
}
deleteTransaction.RollBack();
doc.Regenerate();
}
ff.Commit();
}
if (intersectionPoint != SetComparisonResult.Disjoint)
{
ICollection<ElementId> generatingElementIds =
wall.GetGeneratingElementIds(edges[0]);
foreach (ElementId generatingElementId in generatingElementIds)
{
Element wallfromgenerating = doc.GetElement(generatingElementId);
if (wallfromgenerating is FamilyInstance)
{
}
}
Solved! Go to Solution.