01-11-2023
05:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-11-2023
05:49 AM
A-side colour as materiel(flat pattern shot correctly ). folded part is show wrong , is here a fix ?
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.
The flat pattern is show Correctly( see below) but the folded part is show wrong see. above
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