<?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 Enumerator Container Modifications in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/enumerator-container-modifications/m-p/11812995#M150016</link>
    <description>&lt;P&gt;I want to modify the following rule (which pulls the drawing curves from a document) so that the enumerator only contains kLineSegmentCurves instead of all curve types by either only adding kLineSegmentCurves or removing everything but after the fact. It currently contains a loop that successfully finds the curves by type. But I'm not sure how to remove them from the collection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCurves&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingCurvesEnumerator&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCurve&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingCurve&lt;/SPAN&gt; 

&lt;SPAN&gt;oCurves&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oModel&lt;/SPAN&gt;)
	&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oCurve&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oModel&lt;/SPAN&gt;)
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oCurve&lt;/SPAN&gt;.&lt;SPAN&gt;CurveType&lt;/SPAN&gt;.&lt;SPAN&gt;ToString&lt;/SPAN&gt; = &lt;SPAN&gt;"kLineSegmentCurve"&lt;/SPAN&gt;
		&lt;SPAN&gt;Else&lt;/SPAN&gt;
			&lt;SPAN&gt;'Remove oCurve from oCurves&lt;/SPAN&gt;
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
	&lt;SPAN&gt;Next&lt;/SPAN&gt;
&lt;SPAN&gt;curveMax&lt;/SPAN&gt; = &lt;SPAN&gt;oCurves&lt;/SPAN&gt;.&lt;SPAN&gt;Count&lt;/SPAN&gt;
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;curveIndex&lt;/SPAN&gt; &amp;gt; &lt;SPAN&gt;curveMax&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
	&lt;SPAN&gt;curveIndex&lt;/SPAN&gt; = &lt;SPAN&gt;curveMax&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;SPAN&gt;oCurve&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oModel&lt;/SPAN&gt;).&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;curveIndex&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 15:25:43 GMT</pubDate>
    <dc:creator>dustinbagley</dc:creator>
    <dc:date>2023-03-10T15:25:43Z</dc:date>
    <item>
      <title>Enumerator Container Modifications</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/enumerator-container-modifications/m-p/11812995#M150016</link>
      <description>&lt;P&gt;I want to modify the following rule (which pulls the drawing curves from a document) so that the enumerator only contains kLineSegmentCurves instead of all curve types by either only adding kLineSegmentCurves or removing everything but after the fact. It currently contains a loop that successfully finds the curves by type. But I'm not sure how to remove them from the collection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCurves&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingCurvesEnumerator&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCurve&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingCurve&lt;/SPAN&gt; 

&lt;SPAN&gt;oCurves&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oModel&lt;/SPAN&gt;)
	&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oCurve&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oModel&lt;/SPAN&gt;)
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oCurve&lt;/SPAN&gt;.&lt;SPAN&gt;CurveType&lt;/SPAN&gt;.&lt;SPAN&gt;ToString&lt;/SPAN&gt; = &lt;SPAN&gt;"kLineSegmentCurve"&lt;/SPAN&gt;
		&lt;SPAN&gt;Else&lt;/SPAN&gt;
			&lt;SPAN&gt;'Remove oCurve from oCurves&lt;/SPAN&gt;
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
	&lt;SPAN&gt;Next&lt;/SPAN&gt;
&lt;SPAN&gt;curveMax&lt;/SPAN&gt; = &lt;SPAN&gt;oCurves&lt;/SPAN&gt;.&lt;SPAN&gt;Count&lt;/SPAN&gt;
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;curveIndex&lt;/SPAN&gt; &amp;gt; &lt;SPAN&gt;curveMax&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
	&lt;SPAN&gt;curveIndex&lt;/SPAN&gt; = &lt;SPAN&gt;curveMax&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;SPAN&gt;oCurve&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oModel&lt;/SPAN&gt;).&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;curveIndex&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 15:25:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/enumerator-container-modifications/m-p/11812995#M150016</guid>
      <dc:creator>dustinbagley</dc:creator>
      <dc:date>2023-03-10T15:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Enumerator Container Modifications</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/enumerator-container-modifications/m-p/11813307#M150021</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/528541"&gt;@dustinbagley&lt;/a&gt;.&amp;nbsp; My main suggestion would be to convert the 'DrawingCurvesEnumerator' object into something else, like a List (or similar), that is easier to use, then use the filter to remove the items from it as needed.&amp;nbsp; A basic way to do this would be to create a variable for the other type of collection first, then use a For Each loop to copy the enumerator's contents into it.&amp;nbsp; My example below shows another possible way too.&amp;nbsp; The main thing going wrong in your code above is that you are collecting the curves in 3 different places.&amp;nbsp; You need to get the curves collection one time to a variable first, then use that variable from there on, instead of collecting the curves again and again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When trying to help you with your code, I had no idea how you defined your 'oView' or 'oModel' variables, so I had to&amp;nbsp;define all of the needed object variables ahead of that point, and set values to them before my code would make any sense.&amp;nbsp; So, the first 4 lines are part of that example built-up.&amp;nbsp; You may be using something completely different to get up to that point, and I have no idea what type of object your 'oModel' variable holds.&amp;nbsp; Also, if that oModel object is not seen in that specific view, it may not return any drawing curves and/or may throw an error.&amp;nbsp; I am not sure what you plan on doing with these DrawingCurves once you have them, so I did not know what type of collection type variable may be best for your situation either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oView As DrawingView = oDDoc.ActiveSheet.DrawingViews.Item(1)
Dim oViewDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oComp As ComponentOccurrence = oViewDoc.ComponentDefinition.Occurrences.Item(1)
Dim oDCurves As DrawingCurvesEnumerator = Nothing
Try
	oDCurves = oView.DrawingCurves(oComp)
Catch
	Logger.Error("Error getting DrawingCurves of input model geometry.")
	Exit Sub
End Try
If IsNothing(oDCurves) OrElse oDCurves.Count = 0 Then Exit Sub
Dim oDCurvesList As List(Of DrawingCurve) = oDCurves.Cast(Of DrawingCurve).ToList
For Each oDCurve As DrawingCurve In oDCurvesList
	If oDCurve.CurveType &amp;lt;&amp;gt; CurveTypeEnum.kLineSegmentCurve Then
		oDCurvesList.Remove(oDCurve)
	End If
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&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;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;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 17:56:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/enumerator-container-modifications/m-p/11813307#M150021</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-03-10T17:56:18Z</dc:date>
    </item>
  </channel>
</rss>

