hi,
what kind of drawings we are talking about ? assmbly or part drawings ? you want to have colors in shaded view or you want to make part lines colored?
there is many ways to do it but i could suggest to start from coding each part by color , check ilogic below it will create new view repr in each part and change color to definied one - it will work both from part and from assembly:
it gets length from custom iproperty, but it can be adjusted, also i do not use "standard" colors names because inventor sometimes change it to language specific ones..
Sub main
On Error Resume Next
Dim view_repr_name = "color_coding"
Dim custom_iproperty_name As String ="s_length"
Dim color_dictionary As New Dictionary(Of String, String) From {
{"1000 mm", "xYellow;255;255;0"},
{"1100 mm", "xRed;255;0;0"},
{"1200 mm", "xBlue;0;0;255" }}
If ThisApplication.ActiveDocumentType =DocumentTypeEnum.kPartDocumentObject Then
Dim pdoc As PartDocument = ThisDoc.Document
If color_dictionary.ContainsKey(pdoc.PropertySets(4)(custom_iproperty_name).Value) Then
Dim name As String=""
Dim R, G, B As Integer
name = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value), ";")(0)
R = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value), ";")(1)
G = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value), ";")(2)
B = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value),";")(3)
Call GetColorAsset(pdoc,view_repr_name, name, R, G, B)
End If
ElseIf ThisApplication.ActiveDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim ass As AssemblyDocument =ThisApplication.ActiveDocument
Dim check As String = ""
check=ass.ComponentDefinition.RepresentationsManager.DesignViewRepresentations(view_repr_name).Name
If check = view_repr_name Then
ass.ComponentDefinition.RepresentationsManager.DesignViewRepresentations(view_repr_name).Activate
Else
ass.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add(view_repr_name).Activate
End If
For Each occ As ComponentOccurrence In ass.ComponentDefinition.Occurrences
If occ.DefinitionDocumentType<>DocumentTypeEnum.kPartDocumentObject Then Continue For
Dim pdoc As PartDocument = occ.Definition.Document
If color_dictionary.ContainsKey(pdoc.PropertySets(4)(custom_iproperty_name).Value) Then
Dim name As String
Dim R, G, B As Integer
name = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value), ";")(0)
R = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value), ";")(1)
G = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value), ";")(2)
B = Split(color_dictionary(pdoc.PropertySets(4)(custom_iproperty_name).Value),";")(3)
Call GetColorAsset(pdoc,view_repr_name, name, R, G, B)
occ.SetDesignViewRepresentation(view_repr_name,, True)
End If
Next
End If
End Sub
Function GetColorAsset(doc As PartDocument,view_repr_name As String, name As String, R As Integer, G As Integer, B As Integer) As Asset
Dim Asset As Asset=Nothing
Try
Asset = doc.Assets.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", , name)
Catch ex As Exception
Try
Asset = doc.Assets.Item(name)
Catch ex1 As Exception
doc.Rebuild()
doc.Update()
Try
Asset = doc.Assets.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", , name)
Catch ex2 As Exception
End Try
End Try
End Try
Dim uColor As ColorAssetValue = Asset.Item("generic_diffuse")
Dim clr As Inventor.Color = ThisApplication.TransientObjects.CreateColor(R, G, B)
uColor.Value = clr
check = ""
Try
check = doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations(view_repr_name).Name
Catch ex As Exception
End Try
If check = view_repr_name Then
doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations(view_repr_name).Activate
Else
doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add(view_repr_name).Activate
End If
Try
doc.ActiveAppearance = Asset
Catch ex As Exception
End Try
doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations(1).Activate
doc.Save
End Function

then you can place shaded view into your drawings... if you want to make lines colored then give me know, if you will fail with code, maybe you could share you sample file...