<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Detect Cut between two elements in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11224655#M18582</link>
    <description>&lt;P&gt;I'm struggling to detect cut between two FamilyInstance elements.&lt;BR /&gt;The situation is the following we have a discomposed wall made of plates and studs. I want to check if all the studs are creating a nutch inside the plates. The nutch is created with the "Cut" function. There is a void at each ends of studs.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tempsnip.png" style="width: 300px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1077964i1CEC5A463420CED0/image-size/small?v=v2&amp;amp;px=200" role="button" title="tempsnip.png" alt="tempsnip.png" /&gt;&lt;/span&gt;&lt;BR /&gt;So far I've tried 3 methods :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;BooleanOperationsUtils.ExecuteBooleanOperation(studSolid, plateSolid, BooleanOperationsType.Intersect);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is giving me a Solid with a volume even if there is visualy no intersection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;InstanceVoidCutUtils.InstanceVoidCutExists(topPlate, verticalStud);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is always return true in my case. Even if I move the stud far from the plate.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;SolidSolidCutUtils.CutExistsBetweenElements(verticalStud, topPlate, out bool firstCutsSecond);&lt;/LI-CODE&gt;&lt;P&gt;Which seems to work randomly. It may return false on specific pair (always the same) but return true on other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Please check the .rvt sample below (view : {3D}) it contains a plate and two vertical studs. The lefts stud gives me true in the solidsolidcututils method and the right one gives me false.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2022 13:20:58 GMT</pubDate>
    <dc:creator>maxime.touchard7RAK6</dc:creator>
    <dc:date>2022-06-09T13:20:58Z</dc:date>
    <item>
      <title>Detect Cut between two elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11224655#M18582</link>
      <description>&lt;P&gt;I'm struggling to detect cut between two FamilyInstance elements.&lt;BR /&gt;The situation is the following we have a discomposed wall made of plates and studs. I want to check if all the studs are creating a nutch inside the plates. The nutch is created with the "Cut" function. There is a void at each ends of studs.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tempsnip.png" style="width: 300px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1077964i1CEC5A463420CED0/image-size/small?v=v2&amp;amp;px=200" role="button" title="tempsnip.png" alt="tempsnip.png" /&gt;&lt;/span&gt;&lt;BR /&gt;So far I've tried 3 methods :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;BooleanOperationsUtils.ExecuteBooleanOperation(studSolid, plateSolid, BooleanOperationsType.Intersect);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is giving me a Solid with a volume even if there is visualy no intersection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;InstanceVoidCutUtils.InstanceVoidCutExists(topPlate, verticalStud);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is always return true in my case. Even if I move the stud far from the plate.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;SolidSolidCutUtils.CutExistsBetweenElements(verticalStud, topPlate, out bool firstCutsSecond);&lt;/LI-CODE&gt;&lt;P&gt;Which seems to work randomly. It may return false on specific pair (always the same) but return true on other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Please check the .rvt sample below (view : {3D}) it contains a plate and two vertical studs. The lefts stud gives me true in the solidsolidcututils method and the right one gives me false.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 13:20:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11224655#M18582</guid>
      <dc:creator>maxime.touchard7RAK6</dc:creator>
      <dc:date>2022-06-09T13:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Cut between two elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11225028#M18583</link>
      <description>&lt;P&gt;Interesting results. Congratulations on trying several different approaches. Don't worry, there are only a couple of hundred or so other options for you to try out. One of them is sure to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apparently, the void cut reports its existence regardless of whether it actually makes any difference to the model or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A good aspect is that you can successfully query both of those family instances for their solid geometry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if a non-zero intersection exists, then one or the other volume should change if the other instance is eliminated, shouldn't it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you could try the TTT temporary transaction trick: in a temporary transaction that is later rolled back and never committed, retrieve the volume of the solid (all solids) of instance A before and after temporarily deleting instance B. if the two volumes differ, there was a non-zero cut, and you can determine its volume by the difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And so on and so forth. I hope you get the idea. This trick has been used successfully in hundreds of different situations, many of them discussed here in the forum; a few are mentioned in The Building Coder topic group on transactions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 15:10:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11225028#M18583</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-06-09T15:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Cut between two elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11226698#M18584</link>
      <description>&lt;P&gt;Great Idea !&lt;BR /&gt;Unfortunatly It doesn't seem to work in my case.&lt;BR /&gt;If I do understand the trick I have to regenerage the document to make the volume to update.&lt;BR /&gt;And it pops a lot of warnings / errors when I do so. It could be ok if I had a few studs but I have hundreds...&lt;BR /&gt;Here is my code :&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;double beforePlateVolume = plate.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED).AsDouble();
double afterPlateVolume = beforePlateVolume;
using (Transaction tr = new Transaction(doc, "-delete vertical stud-"))
{
    tr.Start();
    doc.Delete(stud.Id);
    //doc.Regenerate();
    afterPlateVolume = plate.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED).AsDouble();
    DebugUtil.log("volumes : " + beforePlateVolume + " || " + afterPlateVolume); // same volume if no regenerate
    tr.RollBack();
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 10 Jun 2022 09:24:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11226698#M18584</guid>
      <dc:creator>maxime.touchard7RAK6</dc:creator>
      <dc:date>2022-06-10T09:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Cut between two elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11226830#M18585</link>
      <description>&lt;P&gt;Yes, you need to regenerate to update the volume in the parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I would suggest not using the parameter but querying the element for its geometry solid and checking that instead. It probably also requires a regen, though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can implement a warning swallower to suppress the warnings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension.html#2" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you create hundreds of separate transactions, you will need hundreds of time T.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about packaging all your intersection tests into one single transaction? Maybe that will perform in one single time T.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember, the transaction possibly costs a hundred times as much as the operation you perform.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the regeneration maybe costs thousands of times as much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe add some benchmarking to see which operation is really consuming the time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 10:31:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11226830#M18585</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-06-10T10:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Cut between two elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11230233#M18586</link>
      <description>&lt;P&gt;There are 2 ways to find an answer to your problem, not involving a transaction or regeneration.&lt;BR /&gt;The first works in conjunction with the&amp;nbsp;InstanceVoidCutUtils.InstanceVoidCutExists(topPlate, verticalStud) method. Use the document warnings to find elements that are cut/joined but don't intersect. You'd have to determine which warning is valid for the studs/plates, as there are several warnings that give information regarding a disjoined state.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Warning_NotIntersecting.PNG" style="width: 300px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1078900iBEF3B9CB43590AAC/image-size/small?v=v2&amp;amp;px=200" role="button" title="Warning_NotIntersecting.PNG" alt="Warning_NotIntersecting.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;bool disjointWarning = false;
foreach (FailureMessage message in  doc.GetWarnings())
{
	if(message.GetFailureDefinitionId().Guid  != BuiltInFailures.CutFailures.CannotCutGeometryWarn.Guid) continue;
	if(message.GetFailingElements().Contains(topplate.Id) &amp;amp;&amp;amp; message.GetFailingElements().Contains(verticalStud.Id)) disjointWarning = true;
	break;
}
// other possible warnings
//			BuiltInFailures.CutFailures.CannotCutGeometry;
//			BuiltInFailures.JoinElementsFailures.JoiningDisjoint;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second solution is to use the Element.&lt;SPAN&gt;GetGeneratingElementIds&lt;/SPAN&gt;(face) method on all the faces of the plates, and find if the Id of the stud is contained in that list, meaning the stud is intersecting the plate.&lt;/P&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;&lt;EM&gt;Return Value&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;EM&gt;The id(s) of the element(s) that generated (or may have generated) the given geometry object. Empty if no generating elements are found. If the set contains just one id, it is the id of the element that generated the geometry object.&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;     private List&amp;lt;ElementId&amp;gt; GetGeneratingElementIds(Element e)
     {
     	IEnumerable&amp;lt;ElementId&amp;gt; res = new List&amp;lt;ElementId&amp;gt;();
        Options opt = new Options();
	opt.ComputeReferences = false;
	opt.IncludeNonVisibleObjects = false;
	bool IsGetGeometryInstance = !((e is FamilyInstance) &amp;amp;&amp;amp; !ExporterIFCUtils.UsesInstanceGeometry(e as FamilyInstance)) ;
	GeometryElement geoElem = e.get_Geometry(opt);
        // get references
        foreach (var geo in geoElem)
        {
            GeometryInstance geoIns = geo as GeometryInstance;
            if (geoIns != null)
            {
                GeometryElement geoElem2 =  IsGetGeometryInstance == true ? geoIns.GetInstanceGeometry() : geoIns.GetSymbolGeometry();
                foreach(GeometryObject geoObj2 in geoElem2)
                {
                	Solid s2 = geoObj2 as Solid;
                	if(s2==null) continue;
                	foreach(Face f in s2.Faces) res = res.Union(e.GetGeneratingElementIds(f));
                }
                continue;
         }
       	Solid s = geo as Solid;
       	if(s==null) continue;
       	foreach(Face f in s.Faces) res = res.Union(e.GetGeneratingElementIds(f));
       }
       return res.ToList();
    }
//"main code"
	bool cutting = GetGeneratingElementIds(topplate).Contains(verticalStud.Id);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2022 22:11:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11230233#M18586</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2022-06-12T22:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Cut between two elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11415315#M18587</link>
      <description>&lt;P&gt;Hi guys,&lt;BR /&gt;Thanks for all your help.&lt;BR /&gt;For the record here is the solution i'm using :&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;InstanceVoidCutUtils.GetCuttingVoidInstances(bottomPlate).Any(i =&amp;gt; i.IntegerValue == verticalStud.Id.IntegerValue)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 09:01:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/detect-cut-between-two-elements/m-p/11415315#M18587</guid>
      <dc:creator>maxime.touchard7RAK6</dc:creator>
      <dc:date>2022-09-12T09:01:44Z</dc:date>
    </item>
  </channel>
</rss>

