Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Report Lat/Long/Elevation for a POI with a simple script

elliott.rosenfeld
Autodesk

Report Lat/Long/Elevation for a POI with a simple script

elliott.rosenfeld
Autodesk
Autodesk

1) Make sure you have POIs in your model.

Note: Do not select any POIs before running the script. If a POI is selected when you run the script, the User Data field will not report Lat-Long-Elevation until you de-select and then re-select that POI.

2) Click  >  >  to open the Scripting Console.

3) Paste this script into the Scripting Area. See: To create and run scripts from the Scripting Console for more information.

 

function getCoordinate(feature) {
 var vector = feature.GEOMETRY.Centroid2d;
 var vector2 = feature.GEOMETRY.BBox3d.Center;
 if(vector == null) { return; }
 vector = app.ReprojectPointDbToLL84(vector);
 if(vector == null) { return; }
 var longitude = vector.X;
 var latitude = vector.Y;
 var elevation = vector2.Z
 return latitude + ", " + longitude + ", " + elevation;
}
var db = app.ActiveModelDb;
var classID = db.TableIndex("POIS");
var poisTable = db.Table(classID);
var poisRow = poisTable.GetWriteRow();
poisTable.StartQuery();
var row = poisTable.Next();
while(row){
 poisRow["USER_DATA"]=getCoordinate(row);
 var featureId=row.ID;
 poisTable.UpdateFeature(poisRow,featureId);
 print( "Feature "+featureId+" was updated.");
 row = poisTable.Next();
}
poisTable.EndQuery();

4) Click Start Script. You will be notified about how many POIs were updated. In this example, I have 3 POIs in my model, so 3 features were updated.

undefined

5) Select any POI. ( I am selecting the Helicopter POI that I sketched, just for fun).

6) Open the Properties Palette for that POI.

7) Lat-Long-Elevation for the selected POI will appear in the User Data field.

undefined

Note: The User Data field will report in Lat-Long-Elevation format, which switches the order of the X-Y values reported in the InfraWorks 360 status bar (bottom-left corner of the application window).


Principal Specialist, Infrastructure
Reply
2,816 Views
9 Replies
Replies (9)

Anonymous
Not applicable

Nice!

Is it possible to modify the script so that the coordinates is shown in the same coordinate system as set in the model properties, i.eg. ETRS89.UTM-32N?

0 Likes

elliott.rosenfeld
Autodesk
Autodesk

Thanks! I am checking on this. My guess is yes, but it will take a little thought. I'll get back to you soon!

 

Best,

Elliott


Principal Specialist, Infrastructure
0 Likes

elliott.rosenfeld
Autodesk
Autodesk

I believe this will do the trick, although I haven't had a chance to test it out yet. I will report back shortly.

 

//convertion from LL84 to UTM-32N

var transforms = new adsk.SRSTransform("EPSG:4326", " ETRS89.UTM-32N");

 

Thanks!

Elliott


Principal Specialist, Infrastructure
0 Likes

Anonymous
Not applicable

Thanks!

Is this string supposed to be implemented in the original script or run separately? I can't seem to get it to work from my end...

How about also including a script for exporting POI properties out to a text file? 🙂

0 Likes

elliott.rosenfeld
Autodesk
Autodesk

Hmm, I am also encountering some difficulties getting the transform to work. I'll continue tinkering with this and report back when I have a solution. As for exporting the POI properties out to a text file, you could consider using the Data Table to produce a report. To do so, right-click on the feature class in Model Explorer and choose "View in Data Table." Locate the POI, right-click on it, and choose CSV export selected.

undefined


Principal Specialist, Infrastructure
0 Likes

Anonymous
Not applicable

Thanks! The csv-export is what I was looking for. 🙂

0 Likes

John_DeLeeuw
Advisor
Advisor

Hi @elliott.rosenfeld, did you manage to reproject from DBCs to UserCs yet?

 

I'm trying to change the script but can't get it to work.

John de Leeuw
Senior Consultant

Community Ambassador - Twitter - LinkedIn

0 Likes

ajpancha
Advisor
Advisor

...
Greetings, if I wanted to move an object or point of interest at a specific location at a given coordinate bone XYZ, that option could perform that action ?? I should build on some sequence of script as mentioned in this post ?? or forming might, in advance thousand thanks and a thousand apologize for the question ...


Atte.

 

 

 

ESPAÑOL

...
Saludos, si yo quisiera mover un objeto o punto de interes a un lugar especifico, osea a una coordenada dada XYZ, con que opción podría realizar dicha acción?? tendría que basarme en alguna secuencia de script como la que se menciona en este post?? o de que forma podría hacerlo, de antemano mil gracias y mil disculpe por la pregunta...
Atte.

 

 

> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
PD:
Si la info es de tu interés, dale manitos arriba (KUDO)...
Si la info da solución a tu inquietud, o es conocimiento nuevo para poderlo aplicar en el futuro, acéptalo como SOLUCIÓN...

TU ACEPTACIÓN O APOYO EN CUALQUIERA DE LAS 2 FORMAS, ES EL INCENTIVO PARA PODER SEGUIR APORTANDO CON LO MUCHO O POCO QUE SEPAMOS DE ESTE GRAN SOFTWARE PARA EL BIEN DE TODA LA COMUNIDAD...

Felices festividades de Carnaval y feriado...

ALEJANDRO PANCHANA (Guayaquil-Ecuador)
Facebook | Twitter | Screencast



0 Likes

Scohen-DDSCAD
Observer
Observer

FYI, I got the SPC by simply changing the coordinate system of the model to the SPC, and then run the script.  Of course, make sure you change it back to the system it was using before.

 

-Seth Cohen

0 Likes

Type a product name