Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SDETERS 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
Aug 29, 2019
43
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
 
Replies continue below

Recommended for you

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