Community
InfraWorks Forum
Welcome to Autodesk’s InfraWorks Forums. Share your knowledge, ask questions, and explore popular InfraWorks topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

9 REPLIES 9
Reply
Message 1 of 10
elliott.rosenfeld
2342 Views, 9 Replies

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

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.

ill_script_ran.jpg

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.

Ill_latlongelevation_reported.jpg

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
Labels (2)
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: elliott.rosenfeld

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?

Message 3 of 10

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
Message 4 of 10

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
Message 5 of 10
Anonymous
in reply to: elliott.rosenfeld

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? 🙂

Message 6 of 10

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.

data_table_export.png


Principal Specialist, Infrastructure
Message 7 of 10
Anonymous
in reply to: elliott.rosenfeld

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

Message 8 of 10

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

Message 9 of 10

...
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



Message 10 of 10
Scohen-DDSCAD
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report