<?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 Betreff: Projected Loop - API Delete in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10360941#M125068</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564136"&gt;@Ralf_Krieg&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for trying, but unfortunately that doesn't work.&amp;nbsp; We have similar code in our C# code that worked great in 2019, but stopped working in 2020/2021.&amp;nbsp; Code will let you set the reference to false, but fails when you try to delete it.&amp;nbsp; Appears to be some NOT publicly visible link to the browser node when a face is projected.&amp;nbsp; &amp;nbsp; Unfortunately, when the projected face is no longer available the associated edge loop just kind of disappears for visibility to the API.&amp;nbsp; Interestingly, when I started testing by selecting the browser node and checking what was available under the selection states the selected item is Nothing.&amp;nbsp; I'll submit an error report to ADSK once I get some time to produce a stripped down sample.&amp;nbsp; Was hoping maybe someone else had already ran into this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;William Graham&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jun 2021 12:35:13 GMT</pubDate>
    <dc:creator>wgraham</dc:creator>
    <dc:date>2021-06-03T12:35:13Z</dc:date>
    <item>
      <title>Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10359304#M125051</link>
      <description>&lt;P&gt;Is there any way to programmatically remove a projected loop that was become sick?&amp;nbsp; From the UI you can right click on the loop and select delete.&amp;nbsp; Unfortunately, I can't find a way to remove this from the API.&amp;nbsp; Essentially want to be able to search all sketches and identify/delete any broken references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Projected Loop.png" style="width: 823px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/925899i3260070FE53CEA34/image-size/large?v=v2&amp;amp;px=999" role="button" title="Projected Loop.png" alt="Projected Loop.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:57:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10359304#M125051</guid>
      <dc:creator>wgraham</dc:creator>
      <dc:date>2021-06-02T20:57:54Z</dc:date>
    </item>
    <item>
      <title>Betreff: Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10360371#M125065</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure, but sick sketch entites seems to be a combination of Reference property is set to true but ReferencedEntity property is nothing. This iLogic should do.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dim oPartDoc As PartDocument = ThisDoc.Document 

Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oPartDoc, "CleanSickSketchEntities")

Try
	
ThisApplication.ScreenUpdating=False
Dim oSketch As PlanarSketch
Dim oSketchEnt As SketchEntity
For Each oSketch In oPartDoc.ComponentDefinition.Sketches
    oSketch.Edit
    For Each oSketchEnt In oSketch.SketchEntities
        If oSketchEnt.Reference = True Then
            If oSketchEnt.ReferencedEntity Is Nothing Then
                If Not oSketchEnt.Type = kSketchPointObject Then
                    'delete sick entity
					oSketchEnt.Delete
					'unlink sick entity to normal sketch ent
					'oSketchEnt.Reference=False
                End If
            End If
        End If
    Next
    oSketch.ExitEdit
Next

Catch
Finally
	ThisApplication.ScreenUpdating = True
	oTrans.End
End Try&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 08:05:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10360371#M125065</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2021-06-03T08:05:16Z</dc:date>
    </item>
    <item>
      <title>Betreff: Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10360941#M125068</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564136"&gt;@Ralf_Krieg&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for trying, but unfortunately that doesn't work.&amp;nbsp; We have similar code in our C# code that worked great in 2019, but stopped working in 2020/2021.&amp;nbsp; Code will let you set the reference to false, but fails when you try to delete it.&amp;nbsp; Appears to be some NOT publicly visible link to the browser node when a face is projected.&amp;nbsp; &amp;nbsp; Unfortunately, when the projected face is no longer available the associated edge loop just kind of disappears for visibility to the API.&amp;nbsp; Interestingly, when I started testing by selecting the browser node and checking what was available under the selection states the selected item is Nothing.&amp;nbsp; I'll submit an error report to ADSK once I get some time to produce a stripped down sample.&amp;nbsp; Was hoping maybe someone else had already ran into this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;William Graham&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 12:35:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10360941#M125068</guid>
      <dc:creator>wgraham</dc:creator>
      <dc:date>2021-06-03T12:35:13Z</dc:date>
    </item>
    <item>
      <title>Betreff: Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10361390#M125079</link>
      <description>&lt;P&gt;I tried this before too.&amp;nbsp; After checking that the 'Reference' boolean is True, and that the 'ReferencedEntity' was nothing, I then entered into Edit mode for the sketch, then used a Try...Catch block of code around my 'Delete' method, to avoid the expected errors.&amp;nbsp; When I put a MsgBox in the Catch portion, it would show that MsgBox some times, but the 'sick' projected geometry was gone when the rule finished, so it did do it's job for me.&amp;nbsp; I didn't bother trying to set the 'Reference' property to False, because the geometry object is already in an error state.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
For Each oSketch As PlanarSketch In oPDef.Sketches
	For Each oSE As SketchEntity In oSketch.SketchEntities
		If oSE.Reference Then
			If oSE.ReferencedEntity Is Nothing Then
				oSketch.Edit
				Try
					oSE.Delete
				Catch
					'MsgBox("Couldn't delete it.", , "")
				End Try
				oSketch.ExitEdit
			End If
		End If
	Next
Next&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN style="background-color: green; color: white;"&gt;&lt;STRONG&gt;ACCEPT SOLUTION&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;SPAN&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;If you want and have time, I would appreciate your Vote(s) for &lt;A href="https://forums.autodesk.com/t5/forums/recentpostspage/post-type/message/interaction-style/idea/user-id/7812054/" target="_blank"&gt;My IDEAS &lt;SPAN&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B166FEBB95D67CFA84899D32D8E17FC1/emoticons/1f4a1.png" alt=":light_bulb:" title=":light_bulb:" /&gt;&lt;/SPAN&gt;&lt;/A&gt;or you can Explore &lt;A href="https://knowledge.autodesk.com/profile/LTSUSR7HXMSAE/articles" target="_blank"&gt;My CONTRIBUTIONS &lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 14:57:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10361390#M125079</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-06-03T14:57:10Z</dc:date>
    </item>
    <item>
      <title>Betreff: Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10361448#M125082</link>
      <description>&lt;P&gt;I found a way using CommandManager to replicate the UI command "DeleteConstraints".&amp;nbsp; Sketch Enties that are part of a sick Projected Loop can't be deleted until their constraints are deleted.&amp;nbsp; You need to do this all at once though because if you delete constraints from part of the loop, the rest of the sketch entities in that loop are no longer sick and won't get picked up/Deleted by the rule.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this out:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oPartDoc As PartDocument = ThisDoc.Document 
Dim deleteConstraintsCMD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("SketchDeleteConstraintsCtxCmd")
Dim sickCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim selSet As SelectSet = oPartDoc.SelectSet

Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oPartDoc, "Delete Sick Sketch Entities")
On Error GoTo ERRR
For Each oSketch As PlanarSketch In oPartDoc.ComponentDefinition.Sketches
	selSet.Clear
    oSketch.Edit
    For Each oSketchEnt As SketchEntity In oSketch.SketchEntities
        If oSketchEnt.Reference = True Then
            If oSketchEnt.ReferencedEntity Is Nothing Then
                If Not oSketchEnt.Type = kSketchPointObject Then
					'Collect all sick entities
                    sickCollection.Add(oSketchEnt)
                End If
            End If
        End If
    Next
	'Select All Sick Entities
	selSet.SelectMultiple(sickCollection)
	'Delete All constraints on selected entities
	deleteConstraintsCMD.Execute
	'Loop through and delete all previously sick entities
	For Each Item In sickCollection
		Item.Delete
	Next
    oSketch.ExitEdit
Next
oTrans.End
Exit Sub
ERRR :
	oTrans.Abort
	Logger.Trace("Failure")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you have any questions, or if this is not working as intended.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 15:15:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10361448#M125082</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2021-06-03T15:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10361538#M125085</link>
      <description>&lt;P&gt;Thanks for all the suggestions.&amp;nbsp; After further testing, seeing a hard crash (both 2021 &amp;amp; 2022) even attempting to look at the ReferencedEntity property.&amp;nbsp; It has been submitted to ADSK as a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;William Graham.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 15:50:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10361538#M125085</guid>
      <dc:creator>wgraham</dc:creator>
      <dc:date>2021-06-03T15:50:59Z</dc:date>
    </item>
    <item>
      <title>Betreff: Projected Loop - API Delete</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10552287#M127785</link>
      <description>&lt;P&gt;This is not good programming.&amp;nbsp; Is there a way to check the feature is not valid before the delete throws and error.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 15:22:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/projected-loop-api-delete/m-p/10552287#M127785</guid>
      <dc:creator>chuck.yocum</dc:creator>
      <dc:date>2021-08-17T15:22:46Z</dc:date>
    </item>
  </channel>
</rss>

