Get object by ID

How could I get an Object by it’s ID on the scripting API?

I don’t think there’s anything for this (at least not that I’ve seen in the docs), so you would need to iterate all the layers (possibly recursively, if you need to support groups), and for each object layer, you’d need to iterate every object until you find the one with the ID you need.

If you need this for resolving Object References, you should renerally not need it - when an object with that ID exists in the map, the API will give you the MapObject directly. IDs are only returned by the API when the objects don’t exist, or if you ask a MapObject for its ID directly (in which case, you should already have the MapObject).

Hmm I have my custom function to resolve properties to include the default values of nested types

export function resolveObjectProperties(
  item: MapObject,
  defaults: Record<string, MapPropertyValue>
) {
  const properties = item.resolvedProperties();
  return Object.entries(properties).reduce((acc, [key, property]) => {
    let value = getResolvedValue(property);

    if (isPropertyValue(property)) {
      const defaultValues = defaults[property.typeName];
      if (defaultValues != null && JSON.stringify(defaultValues) !== "{}") {
        value = mergician(defaultValues as any, value);

    return {
      [key]: value,
  }, {});

And this way the reference is the ID of the object even if the object exist, will go the brute force route and hopefully when the nested types thing works I can get the resolved object