• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

(Inner Exception #1) System.ArgumentException: Value type of 'AttributeString' is not assignable to required type of 'AttributeInteger'

Messages
15
Country
southafrica
Good afternoon,

Running scenProc stops at this step:
CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCIndforest4"|{72e37d90-824e-4e97-9187-a60491864a49}

with this error:
---> (Inner Exception #1) System.ArgumentException: Value type of 'AttributeString' is not assignable to required type of 'AttributeInteger'

In the argument used, "layer" is a string field in the shapefile attribute table with a length of 100 characters.

What am I doing wrong?

Assistance will be appreciated.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Hi,

Would you be able to provide some test data with these attributes? Then I can try to reproduce it.
 
Messages
15
Country
southafrica
Thank you Arno,

I have attached a zip file with data.

Just something strange I noticed is that when I can get scenProc to process past the offending line in the script, it reads and processes other similar lines in the script just fine.

So the relevant lines in the original script are:

1. CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCIndforest4"|{72e37d90-824e-4e97-9187-a60491864a49} -- This is where the processing stops.
2. CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCWoodlandOpenBush6"|{dc5c8dcb-551e-4980-867d-ee6d12695c50}
3. CreateAGNPolyVeg|FTYPE="POLYGON" and layer="3320NLCPlantWoodMature32"|{fbea356c-ea46-49d6-8593-7adba0afae1d}
4. CreateAGNPolyVeg|FTYPE="POLYGON" and layer="3320NLCPlantWoodYoung33"|{dcf543b7-c0d5-4fd4-b970-83965c2911c9}

To get scenProc to process past line 1, I changed line 1 to the following:
CreateAGNPolyVeg|FTYPE="POLYGON" and DN= 1|{72e37d90-824e-4e97-9187-a60491864a49}

DN is just a dummy field in the attribute table - all records have a DN value of 1.

With the above change scenProc processes line 1, and then moves on to lines 2, 3 and 4 without any issues, processes them and creates the scenery.

If I totally remove line 1, the process then stops with line 2.

Thank you for looking into this.

Regards
Rudi
 

Attachments

  • 3320.zip
    2.4 MB · Views: 246

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Hi,

I used this script with the SHP file you attached:

Code:
ImportOGR|3320NLC04063233MinRoads.shp|*|*|NOREPROJ
#
SplitGrid|AGN|*
#
CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCIndforest4"|{72e37d90-824e-4e97-9187-a60491864a49}
CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCWoodlandOpenBush6"|{dc5c8dcb-551e-4980-867d-ee6d12695c50}
CreateAGNPolyVeg|FTYPE="POLYGON" and layer="3320NLCPlantWoodMature32"|{fbea356c-ea46-49d6-8593-7adba0afae1d}
CreateAGNPolyVeg|FTYPE="POLYGON" and layer="3320NLCPlantWoodYoung33"|{dcf543b7-c0d5-4fd4-b970-83965c2911c9}

But it runs without errors on my machine. Are you using a recent development release of scenProc?
 
Messages
15
Country
southafrica
Hi Arno,

I am running v3.0.0.0 r005f854e DEV 2020/05/11. Should I try a different version?

Rudi
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
I haven't changed a lot to the CreateAGNPolyVeg step the last month, but could you try to get the latest development release and see if that helps?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Humm, interesting that with the same script and the same SHP file we get different results. Let me think what else might influence this.
 
Messages
15
Country
southafrica
Arno,

Just ran the script with the latest development release again, this time with success. I am not sure what caused it to fail previously.

Thank you for your assistance.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
OK, let me know if you see the issue again.
 
Messages
15
Country
southafrica
Arno,

When I include the code you provided with the rest of my code, the same problem arises. Through trail and error I have identified the offending line of code but cannot figure out what is wrong with the code.

The code is as follows:
#IMPORT DATA
#
ImportOGR|J:\3320NLC04063233MinRoads.shp|*|*|NOREPROJ
#
ImportOGR|J:\3320Buildings.shp|*|*|NOREPROJ
#
ImportOGR|J:\3320Roads.shp|*|fclass|NOREPROJ
#
SPLITGRID|AGN|*
#
# CREATE VEGETATION
CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCIndforest4"|{72e37d90-824e-4e97-9187-a60491864a49}
CreateAGNPolyVeg|FTYPE="POLYGON" and layer= "3320NLCWoodlandOpenBush6"|{dc5c8dcb-551e-4980-867d-ee6d12695c50}
CreateAGNPolyVeg|FTYPE="POLYGON" and layer="3320NLCPlantWoodMature32"|{fbea356c-ea46-49d6-8593-7adba0afae1d}
CreateAGNPolyVeg|FTYPE="POLYGON" and layer="3320NLCPlantWoodYoung33"|{dcf543b7-c0d5-4fd4-b970-83965c2911c9}

Running the above code with the latest release gives me the same error as before and no vegetation is created. However, when I remove the reference to the 3rd shapefile (Roads), the code executes perfectly. There is no obvious issue with the Roads shapefile. The path is correct, there is an attribute called fclass and it opens in QGIS.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Could it be the roads file has an attribute layer as well, but with integer data type instead of string?
 
Messages
15
Country
southafrica
The roads file is a standard OSM file that has several attributes.

The attribute "fclass", which I use to identify residential roads, is a string with length 28.

There is however also an attribute called "layer" in the attribute table of the shapefile that is an integer.

My understanding is that ImportOGR|J:\3320Roads.shp|*|fclass|NOREPROJ as used in the script will only look at the fclass attribute and ignore the rest.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Hi,

When scenProc imports the features from the SHP files it will read all attributes.

To be able to validate the filter strings I also keep a summary of all attributes, where one of the things I store is the attribute type (string, float, integer). What happens here is that that summary will use the last data type, so integer instead. But in your CreateAGNPolyVeg you are using a string value in the filter, that is where the error comes from.

Let me check if I can do something about this, but a temporarily work around would be to switch the order of importing the roads and vegetation data.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
I made a test case here now, but the work around I suggested won't help. Let me see if i can understand what happens here.
 
Messages
15
Country
southafrica
Thank you Arno,

The other option would be for me to extract the road categories I require from the shapefile (I use 3 types) and create separate shapefiles for each category of road, and then use ImportOGR|J:\abcdef.shp|*|*|NOREPROJ , ImportOGR|J:\ghijk.shp|*|*|NOREPROJ, etc .

Not sure if one can have more than one shapefile containing same type of feature in the script. I can test this perhaps and let you know?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Hi,

The quickest workaround would probably be to remove the layer attribute from the roads, if you don't use that attribute in your script.

I'm trying to find a proper solution for this.
 
Messages
15
Country
southafrica
Arno,

Removing the layer attribute did the trick.

I am not using the layer attribute at this time so this solution works for me.
 
Top