There are two sets of flags that control how named groups and members of named groups may be copied or propagated …
NamedGroupFlags: The NamedGroupFlags structure holds settings for the NamedGroup as a whole.
The members are public and can be manipulated directly
NamedGroupMemberFlags: The Flags stored for each member of a NamedGroup.
The members are public, so they can be manipulated directly.
Use
NamedGroupFlags
when you create a named group.
NamedGroupFlags() instantiates a new NamedGroupFlags with default values of false for
allowDuplicates, exclusiveMembers, allowFarReferences, closed, selectMembers, and anonymous …
flags = NamedGroupFlags()
Use
NamedGroupMemberFlags
when you add members to a named group.
NamedGroupMemberFlags() instantiates a new NamedGroupMemberFlags with default values …
flags = NamedGroupMemberFlags()
Call AddMember() to add a new element to a named group.
The new member is granted the default NamedGroupMemberFlags.
GetFlags() and SetFlags() give you the option to change flags later.
The Python API documentation for the named group flags omits essential information: the flags themselves are not documented. As revealed on the MicroStation Programming Forum, you can ask Python to reveal the documentation in the source code. Thanks to Bentley Systems staffer YongAn Fu for helping with that missing information.
The flag names differ slightly from their source in the C++ MicroStationAPI …
# NamedGroupFlags
AllowDuplicates
AllowFarReferences
Anonymous
Closed
ExclusiveMembers
SelectMembers
# NamedGroupMemberFlags
BackwardPropagate
ForwardPropagate
GroupPropagate
JSON doesn't understand custom classes such as NamedGroupFlags.
We must translate an instance of NamedGroupFlags to something that JSON
does understand, such as an int.
Two functions are provided that translate NamedGroupFlags to an int
and translate an int to NamedGroupFlags.
You'll find them in the
Named Group Proxy
module.
Thanks to Bentley Systems staffer
YongAn Fu
for writing those functions …
def NamedGroupFlags_to_int(cls, flags: NamedGroupFlags) -> int: ''' Class method interprets NamedGroupFlags as an integer. ''' value = 0 if flags.AllowDuplicates: value |= 1 << 0 if flags.ExclusiveMembers: value |= 1 << 1 if flags.AllowFarReferences: value |= 1 << 2 if flags.Closed: value |= 1 << 3 if flags.SelectMembers: value |= 1 << 4 if flags.Anonymous: value |= 1 << 5 return value def int_to_NamedGroupFlags(cls, value: int) -> NamedGroupFlags: ''' Class method interprets an integer as NamedGroupFlags. ''' flags = NamedGroupFlags() flags.AllowDuplicates = bool(value & (1 << 0)) flags.ExclusiveMembers = bool(value & (1 << 1)) flags.AllowFarReferences = bool(value & (1 << 2)) flags.Closed = bool(value & (1 << 3)) flags.SelectMembers = bool(value & (1 << 4)) flags.Anonymous = bool(value & (1 << 5)) return flags
Post questions about MicroStation programming to the MicroStation Programming Forum.