I am attempting to apply a creation date through a '.CSV' connection to either a point of interest or city furniture component.
The script is running but I cannot figure out the text for the ?? below:
write.CREATION_DATE = ( ?? [3]);
Full script:
function UpdateCITY_FURNITUREData() {
var db = app.ActiveModelDb;
var sset = app.ActiveSelectionSet;
if (sset.QueryCount() < 1) {
alert("Please select one or more City Furniture and try again.");
return;
}
var tableName = "CITY_FURNITURE";
var filter = sset.GetFilter(db.TableIndex("CITY_FURNITURE"));
var table = db.Table("CITY_FURNITURE");
var extent = table.QueryExtent(filter);
table.StartQuery(filter);
table.BeginWriteBatch();
var read;
var write = table.GetWriteRow();
while (read = table.Next()) {
var coords = file.ReadFile("P:/Glasgow/BLC/ARCH/370311 - CPR/02-Drawings/2.00-BIM/01-WIP/Infraworks_Data/Script File.csv");
var coordsa = coords.split("\n");
for (var i = 0; i < coordsa.length; i++) {
var txta = coordsa[i].split(",");
if (txta.length < 4) // Number of columns in the CSV file
continue;
// If the name of the building is euqal to the record
// found in the CSV file then...
if (read.NAME == (txta[0])) { // 0 is the first column - A
write.CREATION_DATE = (dt[3]); // Scale X Updated
// (4th column - D)
table.UpdateFeature(write, read.ID); // Update the model
write.Invalidate();
}
}
}
table.CommitWriteBatch();
table.EndQuery();
app.InvalidateTileCache(db.TableIndex(tableName), extent);
return true;
}
UpdateCITY_FURNITUREData();
@scott.fleming27, I understand what you are trying to do here and InfraWorks JS can probably get this done the way you want but that takes good scripting skills which most users lack. I think InfraWorks 360 should provide a capability of adding multiple Data Sources to features. That way you could use a specific key to connect your CSV file (or even other GIS data sources) to your Furniture Items and populate the creation dates.
Please vote on this idea if you also support this.
'dt' needs to be 'txta' if the data you're trying to apply to the CREATION_DATE is in the fourth column of the CSV.
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
Can you post a screenshot of the first few columns/rows so I can see how the data is formatted?
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
After looking at it a bit more, you may need to convert the text string (for the date value) to a date. I don't have time right now to dive into it but let me Google it for you.
See if you can come up with a solution. If not, would a set of custom properties be an option? You could add anything you want and format the fields to your liking.
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
Any luck with this? I've been playing around with all sorts of stuff (date parsing, formats, etc) but still no luck. Might have to call in the big guns and ask for help. @elliott.rosenfeld, got any ideas on how to input a value for the Creation Date of an object?
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
Hi Matt, all:
Good discussion here! I'll play around with this today and get back to you. I have also sent this discussion to one of our resident JS experts, so hopefully we can find a solution very soon.
Best,
Elliott
Thanks for the help all.
We have managed to figure it out with the help of the JS guys in our office. We have dates appearing in the properties when running the script (see image). Result!
The date appears to be considering the time as well and therefore reads it as a day before, we will sort that out and I shall share the script when refined.
Thanks
Scott
Awesome! Glad to hear it! I'd like to hear more about your solution if possible. Are you willing to share your script so we can look it over?
..also, i just heard back from a colleague, who provided me this information, in case it's still handy for anyone reading this:
"I was able to write a date to the property CREATION_DATE by using a JS date object. The user should be able to split the string variable which contains the complete date/time which is read from the CSV file and convert it to a date by
var d = new Date(year, month, day, time, minutes, seconds)
and then assign d to the CREATION_DATE property
To improve performance, it would probably be better to first read the name out of the CSV file, create a filter out of it and then query the database table using this filter, which should return a single feature only. But depending on the (small?) number of CityFurniture assets, this might not be necessary."
Thanks!
Elliott
Ahhh!!! I was soooo close with the code I was messing around with. 🙂
Thanks for posting @elliott.rosenfeld. Just need to keep in mind that the months are stored in a list format with the first item being [0]. 0 = January, 1 = February, 2 = March, 3 = April and so on and so forth.
var d = new Date("2016", ("08" -1), "10"); write.CREATION_DATE = (d); // Returns 10-Aug-2016
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
Thanks Matt!
Just to keep everyone in the loop for future reference, the issue we seem to be having is time zone, where the model defaults at 00:00:00 but at some point in the process it resorts back to 23:00:00 on the day before due to time zone. being -1hour
Trying to work out the solution just now in the script, we could obviously specify the time in the script and this would solve it but we really don't want to have our excel and then the .csv with time data displayed as it is unnecessary in 99% of projects.
Thanks,
Scott
If you can post your JS code maybe we can help you figure it out. More eyes are (almost) always better.
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
All,
I have proposed this for the AU 2017 conference, please vote for me and I will share all!
Proposal is called "The Land Before Time - The Infraworks 360 feature we have all been missing."
Thanks in advance if you do vote!
Cheers,
Scott
@scott.fleming27very cool and good luck. I just voted for it. And feel free to use this script to automate the exporting of images (if you're using bookmarks).
https://knowledge.autodesk.com/community/article/21911
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.