Select to view content in your preferred language

Read data from a file

2234
18
Jump to solution
03-16-2012 09:18 AM
CharalamposApostolou
Emerging Contributor
Is there a way to read data from a file? I have a document file with some attributes in each line and i want to read some attributes and build objects according to that.
0 Kudos
18 Replies
CharalamposApostolou
Emerging Contributor
I know only the basics of Python. I set the buildingID to float like you told me.
0 Kudos
MatthiasBuehler1
Deactivated User
it works fine here ..

the try commenting out some things and print the type of buildingID :

buildingID = int (ce.getAttribute(shape, 'buildingID'))
print type(buildingID)

I am not sure if this is really the issue.

what version of CityEngine are you using ?
0 Kudos
CharalamposApostolou
Emerging Contributor
I am using the 2010.3 version
0 Kudos
MatthiasBuehler1
Deactivated User
for me it's working too, in 2010.3, without edits.


are you using all forward slashes in the file paths ? ( '/')

sorry, but it seems you really have to track it down line by line.. it works fine here, so it must something small.

maybe add a screenshot, where I can see ALL the details too, ok ?
0 Kudos
CharalamposApostolou
Emerging Contributor
[ATTACH=CONFIG]14972[/ATTACH]

ok i will try to find whats going on
0 Kudos
CharalamposApostolou
Emerging Contributor
I think am doing something wrong in the second argument of this:
buildingID = int(ce.getAttribute(Shape, 'buildingID'))

did i have to set a path like "/CityEngine/..../buildingID" ?
0 Kudos
MatthiasBuehler1
Deactivated User
hi ..

no, the attribute is just an object attribute, thus it needs no path. it's linked to the shape.

name correct ? no syntax error ? no space at the end or similar ?

did you select the shape while running the script ? if the selection is empty, nothing is done ..
0 Kudos
CharalamposApostolou
Emerging Contributor
Thank you very much for your help. the code worked perfectly. I hadto change something in the directory.
0 Kudos
MatthiasBuehler1
Deactivated User
shaaring, shaaring ! 😉


glad I was able to help !
0 Kudos