Can I get it to paint all the A-side and not only one surface?

Can I get it to paint all the A-side and not only one surface?

Darkforce_the_ilogic_guy
Advisor Advisor
464 Views
9 Replies
Message 1 of 10

Can I get it to paint all the A-side and not only one surface?

Darkforce_the_ilogic_guy
Advisor
Advisor

I have a ilogic code , that paint the A-side on sheet metal , if the material is not the same on both side ,,, but if I have a bent part .. not all of if this paintet on the fold part .. is there a way to fix that?

0 Likes
465 Views
9 Replies
Replies (9)
Message 2 of 10

Cadkunde.nl
Collaborator
Collaborator

I see no ilogic rule in the part, could it have been an external rule

 

I feel its that you are only painting the first face, not the whole collection

0 Likes
Message 3 of 10

Cadkunde.nl
Collaborator
Collaborator

Here is how i find and select all 3 faces of the A-Side

 

Dim odoc As PartDocument = ThisDoc.Document
Dim smcomp As Inventor.SheetMetalComponentDefinition = odoc.ComponentDefinition

Dim aside As Inventor.ASideDefinition = smcomp.ASideDefinitions.Item(1)
Dim sel As Inventor.SelectSet = odoc.SelectSet

MsgBox(aside.Faces.Count)

For i = 1 To aside.Faces.Count
	sel.Select(aside.Faces.Item(i))
Next
0 Likes
Message 4 of 10

Michael.Navara
Advisor
Advisor

I don't know how you set the color to ASideFace, but here is the next step, how to apply the same Appearance to tangentially connected faces

 

Dim part As PartDocument = ThisDoc.Document
Dim smCompDef As SheetMetalComponentDefinition = part.ComponentDefinition
Dim aSideFace As Face = smCompDef.ASideFace
For Each tangentFace As Face In aSideFace.TangentiallyConnectedFaces
	tangentFace.Appearance = aSideFace.Appearance
Next
0 Likes
Message 5 of 10

nstevelmans
Advocate
Advocate

Hi All,

 

Try this,

 

 

Dim oPartDoc As PartDocument =  ThisDoc.Document
        Dim oSheetMetalCompdef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition

        Dim assetLib As AssetLibrary
        assetLib = ThisApplication.AssetLibraries.Item("Inventor material Library")

        Dim libAsset As Asset = assetLib.AppearanceAssets.Item("Red")

        'get a 'local copy' of this appearance to work with (needed)
        Dim oDocApps As AssetsEnumerator = oPartDoc.AppearanceAssets
        Dim oAppAsset As Asset = Nothing

        Try
            oAppAsset = oDocApps.Item("Red")
        Catch
            oAppAsset = libAsset.CopyTo(oPartDoc, True)
        End Try

        Dim oListFaces As New List(Of Faces)

        Dim oAsideDef As ASideDefinition = oSheetMetalCompdef.ASideDefinitions.Item(1)

        For Each face As Face In oAsideDef.Faces
            Face.Appearance = oAppAsset
        Next
0 Likes
Message 6 of 10

Darkforce_the_ilogic_guy
Advisor
Advisor

Sorry I seens for have fail in sending the ilogic with ... but here it is

'this code paint the A-side same color as the material without the pattern on 
'version 1.05
'Add Faom CO35
'version 1.06
Dim runscript As Boolean
runscript = False

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
	runscript = True
	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
	runscript = True
	Color = "Aluminium"
End If


If CurrentSM_Style = "Pl Flexfoam CO35 | Sound Absorption Plate | 1200x1500x30" Then
	runscript = True
	
	Color = "RAL 1021 Rape yellow"
	
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
	
	runscript = True
Else 
	'Exit Sub
	
End If


If runscript = False Then
	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
Message 7 of 10

Darkforce_the_ilogic_guy
Advisor
Advisor

I use your code to modify my code ... so now it does paint the A-side if the A-side is add by the user. but I need it to work even if the A-side is not define by the user . My code now look like this

 

'this code paint the A-side same color as the material without the pattern on 
'version 1.05
'Add Faom CO35
'version 1.06
Dim runscript As Boolean
runscript = False

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
	runscript = True
	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
	runscript = True
	Color = "Aluminium"
End If


If CurrentSM_Style = "Pl Flexfoam CO35 | Sound Absorption Plate | 1200x1500x30" Then
	runscript = True
	
	Color = "RAL 1021 Rape yellow"
	
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
	
	runscript = True
Else 
	'Exit Sub
	
End If


If runscript = False Then
	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


Try
Dim oListFaces As New List(Of Faces)

 Dim oAsideDef As ASideDefinition = oSMDef.ASideDefinitions.Item(1)

        For Each face As Face In oAsideDef.Faces
            Face.Appearance = oAppAsset
        Next
Catch
'error if aside is not add jet
'How does I get it to paint the side that would be the a-side ?

End Try

 

If the A-side is add by the user it now paint all of it ... but I it is not ..It will cause an error and only paint one surface. any idear how to get it to paint all the A-side face on both cases?

0 Likes
Message 8 of 10

Darkforce_the_ilogic_guy
Advisor
Advisor

you code work fine if I have a-side in the browser tree , but I need  it to work even if it is not. My our code does but does not paint all the surface if there is more then one(i case of a ben part) I need to get it to work if there is a A-side or not... and it both case where there are one or more then one A-side Faces

0 Likes
Message 9 of 10

Cadkunde.nl
Collaborator
Collaborator

Is it always obvious which side is Aside?

Is it always the largest side? Does it matter with bends up or bends down direction?

Will this be 100% foolproof without engineer?

If so, then we need input on how to automatically make the aside.

 

 

If its better the engineer looks at it: just notify the engineer to create the Aside when saving:

(Add this to event before save for part documents)

 

If ThisDoc.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then

Dim oPDoc As PartDocument = ThisDoc.DocumentDim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition

If oSMDef.ASideDefinitions.Count = 0 Then

Msgbox(“You forgot aside")

End If 

End If

0 Likes
Message 10 of 10

Darkforce_the_ilogic_guy
Advisor
Advisor

Well we already have a code to create A-side for the users. most material is does not matter with is the A-side.  but we does have some material when it matter a lot. like floor plate. where the two sides are not the same. Color the A-side is a way to make it visible if you have hade the side choss both for the engineer and the guy in the work shop- That is create the physiscal part 

bt_0-1680513720180.png

 

0 Likes