- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How to Change Appearance of a solid Body in IPT in IAM Level?
I know the appearance in IPT can be manually changed in IAM level without modifying the IPT.
However, in my case, I prefer to change the appearance in certain solid body in IPT if it has multi solid bodies.
(I guess it will require user to select the solid).
I find similar topics in the iLogic forum but not match what I need.
Thanks for your help.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This code snippet can help you.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry, for the late response.
And thanks for your help.
Can the code not modify the part file when changing the appearance?
I'd like keep the part file or sub-assembly as it is.
Also, can "Inventor Material Library" be available in the list box?
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The code snippet can be modified to change appearance of SurfaceBodyProxy at the assembly level.
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.
See Set the appearance of an occurrence API Sample for more information.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@Michael.Navara wrote:The code snippet can be modified to change appearance of SurfaceBodyProxy at the assembly level.
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.
See Set the appearance of an occurrence API Sample for more information.
Sorry, I am new to iLogic.
Have looked your link to HELP but have no idea how to make it works.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²