getDrawingInfo: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page GetDrawingInfo to getDrawingInfo: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 8: Line 8:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
getDrawingInfo(mapName, drawingId)
getDrawingInfo(mapName, drawingId)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|mapName|A string containing the name of the map.}}
{{param|mapName|A string containing the name of the map.}}
Line 17: Line 17:
[h: dinfo = getDrawingInfo(getCurrentMapName(), id)]
[h: dinfo = getDrawingInfo(getCurrentMapName(), id)]
<pre>[r: json.indent(dinfo,2)]</pre>
<pre>[r: json.indent(dinfo,2)]</pre>
</source>
</syntaxhighlight>
'''Returns'''
'''Returns'''
<source lang="css" line>
<source lang="css" line>
Line 75: Line 75:
   "layer": "TOKEN"
   "layer": "TOKEN"
}
}
</source>
</syntaxhighlight>
|also=
|also=
{{func|getDrawingProperties}}
{{func|getDrawingProperties}}
}}
}}
[[Category:Draw Function]]
[[Category:Draw Function]]

Revision as of 17:03, 14 March 2023

getDrawingInfo() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.5.2
Returns extensive information about the specified drawing. The information is returned as a JSON object.

Usage

<source lang="mtmacro" line> getDrawingInfo(mapName, drawingId) </syntaxhighlight> Parameters

  • mapName - A string containing the name of the map.
  • drawingId - A string containing the id of the drawing. The easiest way to discover a drawing's Id is via the Draw Explorer interface.

Examples

<source lang="mtmacro" line>

[h: id = findDrawings(getCurrentMapName(),"Funky Shape")] [h: dinfo = getDrawingInfo(getCurrentMapName(), id)]

[r: json.indent(dinfo,2)]

</syntaxhighlight> Returns <source lang="css" line> {

 "fillColor": "#ffffff",
 "path":   [
       {
     "x": 250,
     "y": 200
   },
       {
     "x": 250,
     "y": 400
   },
       {
     "x": 500,
     "y": 400
   },
       {
     "x": 500,
     "y": 200
   },
       {
     "x": 400,
     "y": 200
   },
       {
     "x": 400,
     "y": 300
   },
       {
     "x": 350,
     "y": 300
   },
       {
     "x": 350,
     "y": 200
   },
       {
     "x": 250,
     "y": 200
   }
 ],
 "penWidth": 3,
 "name": "Funky Shape",
 "bounds":   {
   "x": 250,
   "width": 250,
   "y": 200,
   "height": 200
 },
 "penColor": "#000000",
 "id": "B7041D43935D4BDCA330E431D892DEAB",
 "type": "Polygon",
 "opacity": 1,
 "isEraser": 0,
 "layer": "TOKEN"

}

</syntaxhighlight>

See Also