GRAPHISOFT®

Python APIVersion: 0.23 Beta

GetInfoString

Returns the compound ID string of the given element.

def GetInfoString (elemGuid) -> APIObject

 

Parameters

elemGuid
[in] GUID of an element.

 

Return Values

This function returns an APIObject containing the ID string of the element.

 

Remarks

This function is analogous to the ACAPI_Database (APIDb_GetCompoundInfoStringID, ...) function of the C++ API.

For information on how to interpret the returned APIObject, visit the C++ documentation.

 

Example

elemInfos = {}

# three capital letters (A-Z) followed by a '-' and 3 numbers
checkPattern = re.compile ('^[A-Z]{3}-[0-9]{3}$')

print("---------CHECKING ID FORMAT--------")

for elemGuid in GetSelectedElements():
    elemInfos[elemGuid] = GetInfoString (elemGuid)
    if checkPattern.match (elemInfos[elemGuid]) is None:
        print("{} badly formatted ID for element '{}'".format (elemInfos[elemGuid], elemGuid))

print("-----------------------------------")

print("----CHECKING FOR DUPLICATE IDs-----")
rev_infodict = {}
for key, value in elemInfos.items():
    rev_infodict.setdefault(value, set()).add(key)

dupIDs = [key for key, values in rev_infodict.items() if len(values) > 1]
print("{} duplicate IDs".format (dupIDs))
print("-----------------------------------")

 

Requirements

Version: Python API 0.1 or Later
Module: GS

 

See Also

ChangeInfoString

All functions