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: 

Infraworks Confiuration Script mapping from csv file

4 REPLIES 4
Reply
Message 1 of 5
gleeuwdrent
423 Views, 4 Replies

Infraworks Confiuration Script mapping from csv file

I am trying to create a configuration script to map shapefile coverages to coverage styles based on the shapefile attributes and a csv file. My csv file has the following structure: 

gleeuwdrent_0-1621435896280.png

I'm using this script in my configuration file:

function Process(SOURCE, COVERAGES) { 
    COVERAGES.EXTERNAL_ID = SOURCE["FeatId"];
    COVERAGES.RULE_STYLE =GetMapping(SOURCE["LAYER"]);
    return true;
}



function GetMapping(layername)
{
	var  data = file.ReadFile("C:/Users/XXXX/Documents/Infraworks NLCS mapping.csv");
	var rows = data.split("\n");
	for (var i = 0; i < rows.length; i++)
	{
		var cells = rows[i].split(",");
		if(cells[0] == layername)
		{
		return cells[1];
		}
	}
	return null;
}

 

The script is working fine, but the coverage style is not recognized, while the style name is correct:

gleeuwdrent_1-1621435979592.png

 

When I enter the same style in the manual style, the style is correctly mapped:

gleeuwdrent_2-1621436061376.png

 

Any thoughts how to fix this? Or is it a bug in Infraworks?

4 REPLIES 4
Message 2 of 5
andrewofabley
in reply to: gleeuwdrent

I typically do this by having the attributes on the shape file itself, and then employing a style rule.

Is that an option?

AEC Collection / Safe FME / ESRI ArcGIS / Unreal Engine
Digital Engineering Lead, Compulsive Problem Solver.
Message 3 of 5
Matt.Wunch
in reply to: gleeuwdrent

@gleeuwdrent I wrote a similar script a few years back. It was focused on buildings but can be modified for coverages. Let me know if it helps or if you have any questions about it.

 

https://knowledge.autodesk.com/search-result/caas/simplecontent/content/update-infraworks-360-data-u...

 

Message 4 of 5
gleeuwdrent
in reply to: Matt.Wunch

Helllo Matt, thanks for your reply. Your example creates an afterwards mapping: first import your assets and then style them using a scripts. That gives good results, but when you re-import your assets, all modifications will be lost and you have to re run the script. That's not desirable for ease of use.

Message 5 of 5

@gleeuwdrent if you want, you can import the layer AND stylize by script. Here is a sample script to import city furniture type but you can customize by modifying or adding UI to this. Please rename the .txt to .js before running. I always suggest taking a backup of the model before experimenting with a script for just-in-case situations.

Regards,

Ramesh S
Product Manager - Infrastructure Solutions

Ramesh.Sridharan@autodesk.com



Ramesh Sridharan
Product Manager

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report