Message 1 of 4
Not applicable
11-07-2018
06:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a *.sqlite base that was created in Infraworks sometime before and a I need to load some sources from it to the new project using javascript
While looking through some tips and js samples, I found one of the way to load data. As far as I undesrstood it uses providers method.
Here is a code where I want ro add BUILDINGS_NEW to the data source list:
var wkt = app.ActiveModel.CoordSysWkt;
file = "D:/Projects/MyModel.sqlite"
var sd = fdo.OpenDb(file)
print (sd.TableCount);
var providers = app.GetDataProviders(".sqlite");
for (i=0; i<sd.TableCount; i++) {
if (sd.Table(i).Name == 'USER_BUILDINGS_NEW'){
print (' your table has been found');
var tb_f = sd.Table(i)
path_t = file + '/' + sd.Table(i).Name;
for (p in providers) {
var configs = providers[p].FileConnect(md, path_t);
for (c in configs) {
print (c);
for (mm in c){
print (mm);
}
var cfg = configs[c];
cfg.TargetClassName = 'BUILDINGS';
cfg.SourceCoordSys = "XY-M";
cfg.PosCoordSys = wkt;
cfg.Name = 'USER_BUILDINGS_NEW';
cfg.Description = 'DEAF';
cfg.AnchorType = adsk.Enums.LocalOrigin;
// cfg.Position = point.BBox3d.Center;
cfg.Is3D = false;
var result = cfg.Import();
if (result) {
print("INFO: 3d model imported for " + 'USER_BUILDINGS_NEW' + "; bbox = " + result.AffectedExtent.ToString());}
else {
print("ERROR: 3d model import for " + 'USER_BUILDINGS_NEW' + " failed: " + path_t);
success = false;
}
}
}
}
}
Here I've got nothing.
What can be wrong or is there a completely another way to add new data?
Solved! Go to Solution.