Code:
If Not ThisDoc.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("Funktion nur in Baugruppen verfügbar.", MsgBoxStyle.Critical, "iLogic RGB")
Exit Sub
End IfDim oAssDoc As AssemblyDocument = ThisDoc.Document
Dim oAssets As Assets = oAssDoc.Assets
Dim oAppearance As Asset
Dim sRGB As String = InputBox("RGB-Werte", "iLogicRGB", "RGB-Werte mit Bindestrich getrennt")
If sRGB = String.Empty Then Exit Sub ' User canceled Input
Dim aRGB As String() = sRGB.Split("-")
Dim iR As Integer = CInt(aRGB(0))
Dim iG As Integer = CInt(aRGB(1))
Dim iB As Integer = CInt(aRGB(2))
If Not 0 <= iR <= 255 Then
Logger.Debug("iR out of range")
Exit Sub
End If
If Not 0 <= iG <= 255 Then
Logger.Debug("iG out of range")
Exit Sub
End If
If Not 0 <= iB <= 255 Then
Logger.Debug("iB out of range")
Exit Sub
End If
Try
oAppearance = oAssets.Item(sRGB)
Catch
oAppearance = oAssets.Add(kAssetTypeAppearance, "Generic", sRGB, sRGB)
Dim oTransObjs As TransientObjects = ThisApplication.TransientObjects
Dim oColor As ColorAssetValue = oAppearance.Item("generic_diffuse")
oColor.Value = oTransObjs.CreateColor(iR, iG, iB)
End Try
Dim oCompOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Komponente auswählen")
Component.Color(oCompOcc.Name )=oAppearance.DisplayName