Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

A-side colour as materiel(flat pattern shot correctly ). folded part is show wrong , is here a fix ?

Darkforce_the_ilogic_guy
Advisor

A-side colour as materiel(flat pattern shot correctly ). folded part is show wrong , is here a fix ?

Darkforce_the_ilogic_guy
Advisor
Advisor

I have an ilogic code that change the colour of the A-side to the raw material colour without pattern. if an material have to be  turn the right way.  In many cases an alu floor plate with a pattern on one side. I want to change it A-side to the Alu without the pattern. 

 

bt_0-1673444631096.png

 

The flat pattern is show  Correctly( see below) but the folded part is show wrong see. above

 

bt_1-1673444775171.png

 

Is that a way to make it show it right on both ?

 

May current code for this is 

 

'this code paint the A-side same color as the material without the pattern on 
'version 1.05



If ThisDoc.Document.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	'MsgBox("This is not a Sheet Metal Part. Exiting rule.", vbCritical, "")
	Exit Sub
End If


Dim CurrentSM_Style = SheetMetal.GetActiveStyle()
Dim color
If CurrentSM_Style  = "St.S235 | Tear Plate |2000x1000x3" Or CurrentSM_Style = "St.S235 | Tear Plate |2500x1250x3" Or CurrentSM_Style = "St.S235 | Floor Plate |2500x1250x5" Or CurrentSM_Style = "St.S235 | Floor Plate |3000x1500x5" Then
	Color = "Steel"
End If

If CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 2000x1000x5" Or CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 2500x1250x5" Or CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 2500x1250x5*" Or CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 3000x1500x5" Then
	Color = "Aluminium"
End If

'MsgBox(Color)

If CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 2000x1000x5" Or CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 2500x1250x5" Or CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 2500x1250x5*" Or CurrentSM_Style = "Alu AW-5754 H114 | Floor Plate | 3000x1500x5" Or CurrentSM_Style = "St.S235 | Tear Plate |2000x1000x3" Or CurrentSM_Style = "St.S235 | Tear Plate |2500x1250x3" Or CurrentSM_Style = "St.S235 | Floor Plate |2500x1250x5" Or CurrentSM_Style = "St.S235 | Floor Plate |3000x1500x5" Then
	
	
Else 
	Exit Sub
	
End If


Dim oPDoc As PartDocument = ThisDoc.Document
Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
Dim oFaceToChange As Face = Nothing
If oSMDef.ASideDefinitions.Count > 0 Then
	oFaceToChange = oSMDef.ASideDefinitions.Item(1).ASideFace
End If
If IsNothing(oFaceToChange) Then
	'try to get the 'BaseFace' from the FlatPattern
	Dim oFP As FlatPattern = Nothing
	If oSMDef.HasFlatPattern Then
		oFP = oSMDef.FlatPattern
	Else
		Try
			oSMDef.Unfold
			oFP = oSMDef.FlatPattern
			oFP.ExitEdit
		Catch
			MsgBox("Error unfolding part to get FlatPattern.", vbCritical, "")
			Exit Sub
		End Try
	End If
	If IsNothing(oFP) Then Exit Sub
	oFaceToChange = oFP.BaseFace 'usually the stationary face when others unfold
	'oFaceToChange = oFP.BottomFace
End If
'get/specify appearance type Asset to supply as value to face appearance
'Dim oInvMatLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Inventor Material Library")
Dim oInvMatLib As AssetLibrary = ThisApplication.AssetLibraries.Item("KallesoeMaterialLibrary")

Dim oWhite As Asset = oInvMatLib.AppearanceAssets.Item(Color)

'Dim oWhite As Asset = oInvMatLib.AppearanceAssets.Item(Steel)
'Asset = oInvMatLib.AppearanceAssets.Item("Steel")



'get a 'local copy' of this appearance to work with (needed)
Dim oDocApps As AssetsEnumerator = oPDoc.AppearanceAssets
Dim oAppAsset As Asset = Nothing
Try
	oAppAsset = oDocApps.Item(Color)
Catch
	oAppAsset = oWhite.CopyTo(oPDoc, True)
End Try
oFaceToChange.Appearance = oAppAsset


'oFaceToChange.AppearanceSourceType = AppearanceSourceTypeEnum.kOverrideAppearance

 

 

 

 

 

 

0 Likes
Reply
206 Views
2 Replies
Replies (2)

bradeneuropeArthur
Mentor
Mentor
Can you share the part file?

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Sure. Here you. And add the ilogic files as well 

0 Likes