Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello All, What ever the color

Status
Not open for further replies.

sri91

Mechanical
Joined
Aug 29, 2019
Messages
43
Location
IN
Hello All,
What ever the color code i am using for the sub string in a drawing text, it is changing to black color. Can any one help me in solving this. The below is the code. Thanks in advance.

DrawingText.setparameteronsubstring catcolor, starting position, length, ival

Thanks
Sri
 
Which means that you fail to set catcolor in a correct way.
CATIA expects it to be encoded in RGBA:

Code:
catcolor = 255 * 255 * 255 * red + 255 * 255 * green + 255 * blue + alpha
 
Hello Little,
Thanks for the answer. I have taken the color codes from google. I have given 32 and 5 also. For both the values it is changing to Black only. Please help me.
Thanks
Sri
 
Use this functions to convert between RGBA and Long:

Code:
' Courtesy of Little Cthulhu, 2020
Function RGBAtoLong(r, g, b, a)
    Dim lColorRGBA
    If (r >= 128) Then
        ' first bit is not 0, resulting long is negative
        lColorRGBA = &H81000000 + (r - 129) * &H1000000 + g * &H10000 + b * &H100 + a
    Else
        ' first bit is 0, resulting long is positive
        lColorRGBA = r * &H1000000 + g * &H10000 + b * &H100 + a
    End If
    RGBAtoLong = lColorRGBA
End Function

Function LongToRGBA(lngColor) ' Array[4]
    Dim lColor: lColor = Abs(lngColor)
    If lngColor < 0 Then
        lColor = lColor - 1
    End If
    ReDim rgba(3)
    Dim i: For i = 0 To 3
        rgba(3 - i) = lColor Mod 256
        lColor = (lColor - rgba(3 - i)) / 256
        If lngColor < 0 Then
            rgba(3 - i) = 255 - rgba(3 - i)
        End If
    Next
    LongToRGBA = rgba
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top