Skip to content

GET_ATTR_ID ​

GET_ATTR_ID returns the ID of an attribute.

Syntax ​

leo-grammar
CC "Core" GET_ATTR_ID classid:ClassID attrname:strValue .


ClassID :	id | bp-model | we-model .


#-->RESULT ecode:intValue attrid:id
CC "Core" GET_ATTR_ID classid:ClassID attrname:strValue .


ClassID :	id | bp-model | we-model .


#-->RESULT ecode:intValue attrid:id

Parameters ​

  • classid (idValue) - ClassID
  • attrname (strValue) -

Returns ​

  • ecode (intValue) - Contains the error code or is 0 in case of success.
  • attrid (idValue) -

Details ​

The name of the attribute has to be passed in the argument attrname and the id of the class has to be passed with the argument classid. When you want to retrieve the id of a modelattribute, pass bp-model or we-model in the argument classid.

See Also ​

Examples ​

asc
# get all selected objects
CC "Modeling" GET_SELECTED
IF (objids = "")
{
   CC "AdoScript" ERRORBOX "No object has been selected!"
   EXIT
}

# from the list of selected objects, extract the first objectid
SET selected:(VAL token(objids,0," "))

# get the class of the selected object
CC "Core" GET_CLASS_ID objid:(selected)

# get the attribute "Name" of the class
CC "Core" GET_ATTR_ID classid:(classid) attrname:"Name"
IF (ecode != 0)
{
   CC "AdoScript" ERRORBOX "The selected object does not contain an attribute called \"Name\"!"
   EXIT
}

# set the name of the selected object
CC "Core" SET_ATTR_VAL objid:(selected) attrid:(attrid) val:"Seppl"
IF (ecode != 0)
{
   CC "AdoScript" ERRORBOX "Could not set the attribute value!"
   EXIT
}
# get all selected objects
CC "Modeling" GET_SELECTED
IF (objids = "")
{
   CC "AdoScript" ERRORBOX "No object has been selected!"
   EXIT
}

# from the list of selected objects, extract the first objectid
SET selected:(VAL token(objids,0," "))

# get the class of the selected object
CC "Core" GET_CLASS_ID objid:(selected)

# get the attribute "Name" of the class
CC "Core" GET_ATTR_ID classid:(classid) attrname:"Name"
IF (ecode != 0)
{
   CC "AdoScript" ERRORBOX "The selected object does not contain an attribute called \"Name\"!"
   EXIT
}

# set the name of the selected object
CC "Core" SET_ATTR_VAL objid:(selected) attrid:(attrid) val:"Seppl"
IF (ecode != 0)
{
   CC "AdoScript" ERRORBOX "Could not set the attribute value!"
   EXIT
}

Renames the selected object to "Seppl".

Versions and Changes ​

Available since ADOxx 1.3