Expression Syntax Error

Expression Syntax Error

Anonymous
Not applicable
3,125 Views
9 Replies
Message 1 of 10

Expression Syntax Error

Anonymous
Not applicable

Hi there,

 

I am trying to create an expression to apply some specific styles. Unfortunately I cannot create the expression as I always get the following message: Invalid Expression: Generic Syntax Error.

This is my workflow:

  • Model created with model builder
  • Drag and drop shape file (polygons representing zones with certain attributes, among them population density)\
  • Configure shape file as Coverage Area.
  • Select Expression Editor from the Rule Style box

Expression Editor 1.JPG

  • Under Properties/Numeric, double click Pop_Dens

Expression Editor 2.JPG

  • Under Operators/Comparison, double click = (note it also inserts [value])

Expression Editor 3.JPG

  • On the right pane, select from the drop down Pop_Dens and from the list below double click 25, for instance. Note the number gets inserted after [value]

Expression Editor 4.JPG

  • I tried the following combinations

     

    Pop_Dens = 25

    Pop_Dens = '25'

    Pop_Dens = [25]

    Pop_Dens = ['25']

    I have also tried removing the spaces.

  • Select OK. Syntax Error message.

Expression Editor 5.JPG

 

Am I doing something wrong?

 

Any help would be much appreciated.

 

Cheers

 

Javier

 

0 Likes
Accepted solutions (1)
3,126 Views
9 Replies
Replies (9)
Message 2 of 10

kathy.feng
Autodesk
Autodesk

The Rule style field in data source configuration dialog is used to apply styles for all features when import, and it requires the style value or style values returned from the expressions. The expression you provided was returned with true or false,  not like a valid style. 

 

If you'd like to apply some styles to some feature classes, it's recommended to define style rules and run in the model via Style Rules panel, see details at  http://help.autodesk.com/view/INFMDR/ENU/?guid=GUID-4279B93A-99B6-4DF3-87B7-A10F64C4688B

 

Regards,

Kathy

 

Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.

 

0 Likes
Message 3 of 10

Anonymous
Not applicable

Hi Kathy,

 

Thanks for your quick reply. The link you sent doesn't work but I guess you mean this one

http://help.autodesk.com/view/INFMDR/ENU/?guid=GUID-295892D4-AFCB-4217-A48F-992F87564B00

 

I tried using that style rules panel but I failed. This comes to my ignorance about writing expressions and how the system works.

Let's recap and see if you can please help me out.

  • I have a shp with attributes. Among them, Pop_Dens
  • I would like to create a style rule that will show the polygons contained in the aforementioned shp in different colours depending on a range of values of Pop_Dens. Please see image below

Legend.JPG

 

  • I tried creating a coverage area style rule called Population_Density_3 with an expression 'Pop_Dens' > 100 AND 'Pop_Dens' <=  400 and add a bright green colour to it

Capture.JPG

 

  • I then configured the shp file to use that rule style

Capture2.JPG

 

  • And finally I run the rules

The result is not correct. Only a handful of polygons get coloured. I double checked in Civil 3D and there's definitely more polygons within that range. I don't know where my mistake is unfortunately. My ultimate goal is to get a rule that colours all polygons depending on the value range, as per image above. Is that possible to do in a single expression?

 

Any help would be greatly appreciated.

 

Regards

 

Javier

 

 

 

 

 

0 Likes
Message 4 of 10

kathy.feng
Autodesk
Autodesk

Hi Javier,

 

Thanks for the reply. Sorry about the bad link for Help that has extra space at the end. The content you redirected is correct. 

 

If I understand correctly, you want to stylize features with different attribute ranges. 

 

From steps you shared, I didn't quite sure if the style rule name is executable in data source dialog. Would it be an option to you to import all data in and then run style rules? If yes, here's what I recreate to this option:

  1. import SHP as coverage with blank configurations in rule style ( all data is imported )
  2. define style rules in Style Rules panel (same as your steps before data source configure, I added 4 rules with expressions of numeric attributes)
  3. click Commit button to save style rules Style Rules panel 
  4. click Run Rules button at Style Rules panel  

Then assets are colored with the style rule definitions. see snapshot below.  

StyleRule.png

 

Can you try to see if it fits your needs? 

 

Regards,

Kathy 

 

Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.

 

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

Thanks for that lengthy reply Kathy. Unfortunately I haven't been able to apply your instructions to my example. Most likely, it's due to my lack of knowledge of expressions and GIS.

 

So, you use ID, which is a property found under Properties/Common in the Create Filter Expression. Is there a way to add the Pop_Dens property to that list. Otherwise the system doesn't really let you use it. I tried assigning to the imported shp the Pop_Dens to the External ID (see picture for clarification)

 

Capture.JPG

 

and then create and expression using that Extenal ID property.

 

Capture2.JPG

 

 

Unfortunately, the rules do not apply properly. Only some polygons are coloured and they don't even get the correct values. Sorry, I'm a bit lost. Apologies if this is too dumb but I cannot figure out what I'm doing wrong here.

 

Regards

 

0 Likes
Message 6 of 10

kathy.feng
Autodesk
Autodesk

Hmm, seemed lyour case may be specific. Would you mind sharing me the model so that I can look closer? If possible, adding me (kathy.feng@autodesk.com) to your online group or sharing the network drive would be good for me. Thanks.

 

Regards,

Kathy

0 Likes
Message 7 of 10

kathy.feng
Autodesk
Autodesk
Accepted solution

Hi Javier,

 

 

 

Thank you for sharing the model. I checked your proposal and found from model explorer -> coverage data table that, not all shp data imported as coverage when you specify 'Pop_Dens' as External ID.  So the style rules based on those records are incomplete.  The reason I feel is that  'External ID' isn't allow duplicated values, so it imports only distinct Pop_Dens.

 

There're two options to map attributes when import.  

Option 1: add script and map to unused column in the coverage table. ( In Coverage data table you can see what're columns defined)

Option 2: leverage existing common column, and double check record number in the data table title (in case the result isn't as expected)

 

I shared you the model including two proposals with above options, hope it helpful. 

 

mappattributes.png

 

 

Regards,

Kathy

 

Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.

 

 

0 Likes
Message 8 of 10

Anonymous
Not applicable

Hi Kathy,

 

Sorry for taking so long to reply but I was on leave. Yes, the model you sent works fine. I’m not particularly impressed with Infrawork’s capabilities in this area. It’s really easy to this in Civil 3D / Map 3D that I can’t believe they made it so hard in Infraworks. My knowledge in creating those sort of expression is very minimal like the average user, I guess.

 

So thanks for your help on this. There’s potential but not quite the functionality. Please let me know if you find an easier way.

 

Regards

 

Javier

0 Likes
Message 9 of 10

kathy.feng
Autodesk
Autodesk

Hi Javier,

 

It's good to know that the model is helpful to you, and thank you for sharing us your candid comments on InfraWorks capabilities on this area. I will let you know if any better idea. Btw, you're highly welcomed to post your ideas on Idea and get voted. 

 

Regards,

Kathy

 

Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.

0 Likes
Message 10 of 10

IBIMKOREA
Explorer
Explorer

Does anyone solve this problem in Infraworks?! really?

0 Likes