Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Path] How to get the location ?

Hello everyone, I'm new on the forum and despite my efforts on reading several post I haven't understand how to get the location of a path object. I'm able to get a path object, its _id property (and acknowledge that left and top properties are always 0). According to the API documentation I should use something like  JSON.parse(myPath.get("path")) and I'm expect to get an array containing the list of points of my drawing but I'm stuck with an  log("API SD Processing doorId : " + path._id + "..."); --> Display : "API SD Processing doorId : -MElVB6XxTCEz8Gb3N4o..." var pointArray = JSON.parse(path.get("path")); -->  TypeError: myPath.get is not a function var pointArray = JSON.parse(path._path); -->  SyntaxError: Unexpected token u in JSON at position 0 In a first time I draw a line and would like to know the middle, and later move it (if it's possible to change the point's coordinates of course). PS : Sorry for gramaticals mistakes unfortunately french people are not know for their language skills.
1597506603
The Aaron
Roll20 Production Team
API Scripter
It appears you myPath variable isn't a path object. Can you post the code where you're getting it?
1597511522
timmaugh
Pro
API Scripter
Could it just be that you're using the example code (where they reference an object named mypath), but you've named your variable simply 'path'?
1597512642

Edited 1597512796
Thank you Aaron for your quick and pertinent answer. My mistake I though msg.selected was a path. It works perfectly after getting the correct path object .each(msg.selected, function(obj) { var realPath = getObj('path', obj._id); var pointArray = JSON.parse(realPath.get("path")); });
Thanks for your thoughts timmaugh. It wasn't the case this time but it is always better to double check :)
1597533069
David M.
Pro
API Scripter
When I saw the topic and the name of the last poster, I did a double-take and wondered to myself if I may have been posting to the forum in my sleep. Legend has it that a similar scenario resulted in the genesis of The Aaron.