<?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: How to Change Appearance of a solid Body in IPT in IAM Level? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12779811#M167452</link>
    <description>&lt;P&gt;This code snippet can help you.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
    Dim body As SurfaceBody
    Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick a body")
    Dim surfaceBodyProxy As SurfaceBodyProxy = TryCast(pick, SurfaceBodyProxy)
    If Not surfaceBodyProxy Is Nothing Then
        body = surfaceBodyProxy.NativeObject
    Else
        body = pick
    End If
    ChangeAppearance(body)
    ThisApplication.ActiveDocument.Update()
End Sub

Private Sub ChangeAppearance(body As SurfaceBody)
    Dim partDef As PartComponentDefinition = body.Parent
    Dim partDoc As PartDocument = partDef.Document
    Dim assetNames = partDoc.AppearanceAssets.OfType(Of Asset).Select(Function(x) x.DisplayName)
    Dim selectedAssetName As String = InputListBox("Select Appearance", assetNames).ToString()

    Dim selectedAsset As Asset = partDoc.AppearanceAssets.OfType(Of Asset).FirstOrDefault(Function(x) x.DisplayName = selectedAssetName)
    If selectedAsset Is Nothing Then Return

    body.Appearance = selectedAsset

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2024 08:13:18 GMT</pubDate>
    <dc:creator>Michael.Navara</dc:creator>
    <dc:date>2024-05-17T08:13:18Z</dc:date>
    <item>
      <title>How to Change Appearance of a solid Body in IPT in IAM Level?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12779399#M167445</link>
      <description>&lt;P&gt;I know the appearance in IPT can be manually changed in IAM level without modifying the IPT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, in my case, I prefer to change the appearance in certain solid body in IPT if it has multi solid bodies.&lt;/P&gt;&lt;P&gt;(I guess it will require user to select the solid).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I find similar topics in the iLogic forum but not match what I need.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 03:22:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12779399#M167445</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-05-17T03:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Appearance of a solid Body in IPT in IAM Level?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12779811#M167452</link>
      <description>&lt;P&gt;This code snippet can help you.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
    Dim body As SurfaceBody
    Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick a body")
    Dim surfaceBodyProxy As SurfaceBodyProxy = TryCast(pick, SurfaceBodyProxy)
    If Not surfaceBodyProxy Is Nothing Then
        body = surfaceBodyProxy.NativeObject
    Else
        body = pick
    End If
    ChangeAppearance(body)
    ThisApplication.ActiveDocument.Update()
End Sub

Private Sub ChangeAppearance(body As SurfaceBody)
    Dim partDef As PartComponentDefinition = body.Parent
    Dim partDoc As PartDocument = partDef.Document
    Dim assetNames = partDoc.AppearanceAssets.OfType(Of Asset).Select(Function(x) x.DisplayName)
    Dim selectedAssetName As String = InputListBox("Select Appearance", assetNames).ToString()

    Dim selectedAsset As Asset = partDoc.AppearanceAssets.OfType(Of Asset).FirstOrDefault(Function(x) x.DisplayName = selectedAssetName)
    If selectedAsset Is Nothing Then Return

    body.Appearance = selectedAsset

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 08:13:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12779811#M167452</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-05-17T08:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Appearance of a solid Body in IPT in IAM Level?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12786239#M167566</link>
      <description>&lt;P&gt;Sorry, for the late response.&lt;/P&gt;&lt;P&gt;And thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can the code not modify the part file when changing the appearance?&lt;/P&gt;&lt;P&gt;I'd like keep the part file or sub-assembly as it is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, can "Inventor Material Library" be available in the list box?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 02:42:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12786239#M167566</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-05-21T02:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Appearance of a solid Body in IPT in IAM Level?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12786838#M167574</link>
      <description>&lt;P&gt;The code snippet can be modified to change appearance of SurfaceBodyProxy at the assembly level.&lt;/P&gt;&lt;P&gt;If you want to add content of appearance library it is easy but you need to ensure the selected appearance to copy to the document before you assign them to the body.&lt;/P&gt;&lt;P&gt;See&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-6616A1BB-5977-44C8-B0BD-4B7D0FDAD6B6" target="_blank"&gt;Set the appearance of an occurrence&lt;/A&gt;&amp;nbsp;API Sample for more information.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
    Dim bodyProxy As SurfaceBodyProxy
    Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick a body")
    Dim surfaceBodyProxy As SurfaceBodyProxy = TryCast(pick, SurfaceBodyProxy)
    If Not surfaceBodyProxy Is Nothing Then
        bodyProxy = surfaceBodyProxy
    Else
        Return
    End If

    ChangeAppearance(bodyProxy)

    ThisApplication.ActiveDocument.Update()
End Sub

Private Sub ChangeAppearance(bodyProxy As SurfaceBodyProxy)
    Dim asmDef As AssemblyComponentDefinition = bodyProxy.ContainingOccurrence.ContextDefinition
    Dim asmDoc As AssemblyDocument = asmDef.Document
    Dim assetNames = asmDoc.AppearanceAssets.OfType(Of Asset).Select(Function(x) x.DisplayName)
    Dim selectedAssetName As String = InputListBox("Select Appearance", assetNames).ToString()

    Dim selectedAsset As Asset = asmDoc.AppearanceAssets.OfType(Of Asset).FirstOrDefault(Function(x) x.DisplayName = selectedAssetName)
    If selectedAsset Is Nothing Then Return

    bodyProxy.Appearance = selectedAsset

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 09:32:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12786838#M167574</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-05-21T09:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Appearance of a solid Body in IPT in IAM Level?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12791810#M167701</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;The code snippet can be modified to change appearance of SurfaceBodyProxy at the assembly level.&lt;/P&gt;&lt;P&gt;If you want to add content of appearance library it is easy but you need to ensure the selected appearance to copy to the document before you assign them to the body.&lt;/P&gt;&lt;P&gt;See&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-6616A1BB-5977-44C8-B0BD-4B7D0FDAD6B6" target="_blank" rel="noopener"&gt;Set the appearance of an occurrence&lt;/A&gt;&amp;nbsp;API Sample for more information.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I am new to iLogic.&lt;/P&gt;&lt;P&gt;Have looked your link to HELP but have no idea how to make it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 04:50:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-change-appearance-of-a-solid-body-in-ipt-in-iam-level/m-p/12791810#M167701</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-05-23T04:50:23Z</dc:date>
    </item>
  </channel>
</rss>

