<?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 Re: Change color of features only on flatpattern view in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11778891#M26652</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4745824"&gt;@gildas.lincot&lt;/a&gt;.&amp;nbsp; Judging from the attached images, the feature you are looking for was defined while the part was not in its Flat Pattern mode, and the view you are working with is of its FlatPattern, so I do not think you will find that feature in that view.&amp;nbsp; The FlatPattern is like its own ComponentDefinition, so it may contain geometry that resulted from that feature, but will not contain that feature directly, so you will need to identify which 'Faces' of the FlatPattern's body model were 'created by' that feature, then use each of those Faces in the DrawingCurves part of the code.&amp;nbsp; Below is a modified example of your code.&amp;nbsp; Give this version a try, and see if it works better for you.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;'Regle pour changer la couleur de la gravure sur mise en plan Déplié

If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kDrawingDocumentObject Then
	'MsgBox("Cette Règle '" &amp;amp; iLogicVb.RuleName &amp;amp; "' ne fonctionne que pour les Mise en Plans!",vbOKOnly, "MAUVAIS TYPE DE DOCUMENT")
	Exit Sub
	Return
End If
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Inventor.Sheet = oDoc.ActiveSheet
'Definition des lignes en rouge (R, G, B)
Dim oRed As Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

For Each oView As DrawingView In oSheet.DrawingViews
	If oView.IsFlatPatternView = False Then Continue For
	Dim oPDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
	Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	Dim oEFs As EmbossFeatures = oSMDef.Features.EmbossFeatures
	Dim oGravure As EmbossFeature = Nothing
	For Each oEF As EmbossFeature In oEFs
		If Left(oGravure.Name, 7) = "Gravure" Then
			oGravure = oEF
			Exit For
		End If
	Next 'oEF
	If IsNothing(oGravure) Then
		MsgBox("Gravure EmbossFeature Not Found", vbCritical, "")
		Exit Sub
	End If
	'now get the FlatPattern, so we can find the Edges of that feature in it
	Dim oFP As FlatPattern = oSMDef.FlatPattern
	Dim oFaces As Faces = oFP.Body.Faces
	For Each oFace As Face In oFaces
		If oFace.CreatedByFeature IsNot oGravure Then Continue For
		Dim oDCurves2 As DrawingCurvesEnumerator = Nothing
		Try
			oDCurves2 = oView.DrawingCurves(oFace)
		Catch oEx As Exception
			Logger.Error("Error getting DrawingCurves from Face created by Gravure feature")
			Continue For 'skip to next oView
		End Try
		If IsNothing(oDCurves2) OrElse oDCurves2.Count = 0 Then Continue For
		For Each oDCurve As DrawingCurve In oDCurves2
			oDCurve.Color = oRed
		Next 'oDCurve
	Next 'oFace
Next 'oView&lt;/LI-CODE&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;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2023 13:50:40 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2023-02-24T13:50:40Z</dc:date>
    <item>
      <title>Change color of features only on flatpattern view</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11778557#M26651</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been looking for a few days but without result a way to change the color of a function named "Gravure..." only on the view of the flatpattern.&lt;/P&gt;&lt;P&gt;I already have a code start but I can't "reach" the "Gravure..." function in the flatpattern.&lt;/P&gt;&lt;P&gt;I found in "Inventor help" the function "GetFlatPetternEntity or GetSheetMetalEntity" but I did not find an example to understand how it works.&lt;/P&gt;&lt;P&gt;Does anyone have an idea? Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;'Regle pour changer la couleur de la gravure sur mise en plan Déplié&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocumentType&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;DocumentTypeEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kDrawingDocumentObject&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
	&lt;SPAN&gt;'MsgBox("Cette Règle '" &amp;amp; iLogicVb.RuleName &amp;amp; "' ne fonctionne que pour les Mise en Plans!",vbOKOnly, "MAUVAIS TYPE DE DOCUMENT")&lt;/SPAN&gt;
	&lt;SPAN&gt;Exit&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
	&lt;SPAN&gt;Return&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDrawing&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oSheet&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Sheet&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveSheet&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingViews&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1).&lt;SPAN&gt;ReferencedDocumentDescriptor&lt;/SPAN&gt;.&lt;SPAN&gt;ReferencedDocument&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SheetMetalComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oGravure&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;EmbossFeature&lt;/SPAN&gt;


&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingView&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingViews&lt;/SPAN&gt;
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;IsFlatPatternView&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;		
		
		&lt;SPAN&gt;'Verification qu'il y ai des bossages "GravureX"&lt;/SPAN&gt;
		&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oGravure&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oPDef&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;EmbossFeatures&lt;/SPAN&gt;
			&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Left&lt;/SPAN&gt;(&lt;SPAN&gt;oGravure&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt;, 7) = &lt;SPAN&gt;"Gravure"&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
			
			&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDCurves2&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingCurvesEnumerator&lt;/SPAN&gt;
			
			&lt;SPAN&gt;oDCurves2&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingCurves&lt;/SPAN&gt;(&lt;SPAN&gt;oGravure&lt;/SPAN&gt;) &lt;SPAN&gt;'Here Something's wrong!&lt;/SPAN&gt;
			
				&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oDCurves2&lt;/SPAN&gt;.&lt;SPAN&gt;Count&lt;/SPAN&gt; &amp;lt;&amp;gt; 0  &lt;SPAN&gt;Then&lt;/SPAN&gt;
					&lt;SPAN&gt;'Definition des lignes en rouge (R, G, B)&lt;/SPAN&gt;
					&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oRed&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Color&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateColor&lt;/SPAN&gt;(255, 0, 0)
					&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oDCurve&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingCurve&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oDCurves2&lt;/SPAN&gt;
					&lt;SPAN&gt;oDCurve&lt;/SPAN&gt;.&lt;SPAN&gt;Color&lt;/SPAN&gt; = &lt;SPAN&gt;oRed&lt;/SPAN&gt;
					&lt;SPAN&gt;Next&lt;/SPAN&gt;
				&lt;SPAN&gt;Else&lt;/SPAN&gt;
					&lt;SPAN&gt;'Sortie de la regle&lt;/SPAN&gt;
					&lt;SPAN&gt;Exit&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
				&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&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;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;SPAN&gt;Next&lt;/SPAN&gt;
	

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 11:06:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11778557#M26651</guid>
      <dc:creator>gildas.lincot</dc:creator>
      <dc:date>2023-02-24T11:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change color of features only on flatpattern view</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11778891#M26652</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4745824"&gt;@gildas.lincot&lt;/a&gt;.&amp;nbsp; Judging from the attached images, the feature you are looking for was defined while the part was not in its Flat Pattern mode, and the view you are working with is of its FlatPattern, so I do not think you will find that feature in that view.&amp;nbsp; The FlatPattern is like its own ComponentDefinition, so it may contain geometry that resulted from that feature, but will not contain that feature directly, so you will need to identify which 'Faces' of the FlatPattern's body model were 'created by' that feature, then use each of those Faces in the DrawingCurves part of the code.&amp;nbsp; Below is a modified example of your code.&amp;nbsp; Give this version a try, and see if it works better for you.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;'Regle pour changer la couleur de la gravure sur mise en plan Déplié

If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kDrawingDocumentObject Then
	'MsgBox("Cette Règle '" &amp;amp; iLogicVb.RuleName &amp;amp; "' ne fonctionne que pour les Mise en Plans!",vbOKOnly, "MAUVAIS TYPE DE DOCUMENT")
	Exit Sub
	Return
End If
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Inventor.Sheet = oDoc.ActiveSheet
'Definition des lignes en rouge (R, G, B)
Dim oRed As Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

For Each oView As DrawingView In oSheet.DrawingViews
	If oView.IsFlatPatternView = False Then Continue For
	Dim oPDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
	Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	Dim oEFs As EmbossFeatures = oSMDef.Features.EmbossFeatures
	Dim oGravure As EmbossFeature = Nothing
	For Each oEF As EmbossFeature In oEFs
		If Left(oGravure.Name, 7) = "Gravure" Then
			oGravure = oEF
			Exit For
		End If
	Next 'oEF
	If IsNothing(oGravure) Then
		MsgBox("Gravure EmbossFeature Not Found", vbCritical, "")
		Exit Sub
	End If
	'now get the FlatPattern, so we can find the Edges of that feature in it
	Dim oFP As FlatPattern = oSMDef.FlatPattern
	Dim oFaces As Faces = oFP.Body.Faces
	For Each oFace As Face In oFaces
		If oFace.CreatedByFeature IsNot oGravure Then Continue For
		Dim oDCurves2 As DrawingCurvesEnumerator = Nothing
		Try
			oDCurves2 = oView.DrawingCurves(oFace)
		Catch oEx As Exception
			Logger.Error("Error getting DrawingCurves from Face created by Gravure feature")
			Continue For 'skip to next oView
		End Try
		If IsNothing(oDCurves2) OrElse oDCurves2.Count = 0 Then Continue For
		For Each oDCurve As DrawingCurve In oDCurves2
			oDCurve.Color = oRed
		Next 'oDCurve
	Next 'oFace
Next 'oView&lt;/LI-CODE&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;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 13:50:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11778891#M26652</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-02-24T13:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Change color of features only on flatpattern view</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11786911#M26653</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help. I've tried your code and there is an error on line 20.&lt;/P&gt;&lt;P&gt;So i have change this part:&lt;/P&gt;&lt;P&gt;For Each oEF As EmbossFeature In oEFs&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Left(oGravure.Name, 7) = "Gravure" Then&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&amp;nbsp;oGravure = oEF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;For Each oEF As EmbossFeature In oEFs&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; oGravure = oEF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Left(oGravure.Name, 7) = "Gravure" Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No more error, but no action... The color of lines doesn't change...&lt;/P&gt;&lt;P&gt;Have you an another idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regard.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 09:25:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/change-color-of-features-only-on-flatpattern-view/m-p/11786911#M26653</guid>
      <dc:creator>gildas.lincot</dc:creator>
      <dc:date>2023-02-28T09:25:58Z</dc:date>
    </item>
  </channel>
</rss>

