Combine flags into one hexadecimal value - how?

Hi Group,

Is there a way to easily represent a combination of flags (for example for object types in ObjectsByType method) into a single hexadecimal value that can be provided into the method?
For example, I want 4+8+16 - can I instead provide a single &H… value for that combo?


Ok, looks like it was quite simple, adding the values of types does that. Doh!

You can run ObjectsByType(4+8+16) or whatever and it runs fine - don’t even need to use ObjectsByType(28)… Works for all filtering stuff, been using it for years… --Mitch

Thanks Mitch - I was actually always using the 1+2+… version - for the first time today ran into a need to have a single number, and got stupid for a second !


I don’t believe it for a minute… :stuck_out_tongue_winking_eye:

1 Like

@Jarek, @Helvetosaur,

since it belongs to this topic, you can as well find out if one object type is part of some added types using the function below:

Option Explicit

Call Main()
Sub Main()
    Dim x, y
    x = 8
    y = 28
    Rhino.Print IsObjTypeInside(x, y) 
End Sub

Public Function IsObjTypeInside(ByRef objType, ByRef addedTypes)
    If (addedTypes And objType) Then 
        IsObjTypeInside = True 
        IsObjTypeInside = False
    End If
End Function


1 Like

nice! thanks Clement–