Jump to content
Sign in to follow this  
m0rtezaaghili

My python Code Not working

Recommended Posts

Hi guys

i'm newcomer in Houdini, my simple code not working and don't show error in Houdini console!

i changed the Tag Name to "osk" from "osm" but i don\t see error 'Bad file type' in console.


import xml.dom.minidom
document="""
<osk version="0.6" generator="CGImap 0.1.0" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<bounds minlat="40.7432000" minlon="-73.9897000" maxlat="40.8052000" maxlon="-73.9304000"/>
<node id="1420631950" lat="40.7711745" lon="-73.9792204" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631974" lat="40.7716867" lon="-73.9779803" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631985" lat="40.7694268" lon="-73.9788969" user="dchiles" uid="153669" visible="true" version="1" changeset="9189979" timestamp="2011-09-02T04:12:03Z"/>
</osk>
"""
map = xml.dom.minidom.parseString(document)
if (map.documentElement.tagName != "osm");
print('Bad File Type')
return
[/CODE]

Thanks

Share this post


Link to post
Share on other sites


import xml.dom.minidom
document="""
<osk version="0.6" generator="CGImap 0.1.0" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<bounds minlat="40.7432000" minlon="-73.9897000" maxlat="40.8052000" maxlon="-73.9304000"/>
<node id="1420631950" lat="40.7711745" lon="-73.9792204" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631974" lat="40.7716867" lon="-73.9779803" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631985" lat="40.7694268" lon="-73.9788969" user="dchiles" uid="153669" visible="true" version="1" changeset="9189979" timestamp="2011-09-02T04:12:03Z"/>
</osk>
"""
map = xml.dom.minidom.parseString(document)
if (map.documentElement.tagName != "osm"):
print('Bad File Type')
[/CODE]

You have a ; instead of :

[size=4]also return can/should only be used in functions[/size]

Share this post


Link to post
Share on other sites

if your real code is part of the function and indents are correct (like if() statement should be aligned with map)

then the only error is that you've put semicolon after if() instead of a colon

so it should be


...
map = xml.dom.minidom.parseString(document)
if (map.documentElement.tagName != "osm"):
print('Bad File Type')
return
[/CODE]

EDIT: late reply

Edited by anim

Share this post


Link to post
Share on other sites


import xml.dom.minidom
document="""
<osk version="0.6" generator="CGImap 0.1.0" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<bounds minlat="40.7432000" minlon="-73.9897000" maxlat="40.8052000" maxlon="-73.9304000"/>
<node id="1420631950" lat="40.7711745" lon="-73.9792204" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631974" lat="40.7716867" lon="-73.9779803" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631985" lat="40.7694268" lon="-73.9788969" user="dchiles" uid="153669" visible="true" version="1" changeset="9189979" timestamp="2011-09-02T04:12:03Z"/>
</osk>
"""
map = xml.dom.minidom.parseString(document)
if (map.documentElement.tagName != "osm"):
print('Bad File Type')
[/CODE]

You have a ; instead of :

[size=4]also return can/should only be used in functions[/size]

if your real code is part of the function and indents are correct [size=4](like if() statement should be aligned with map)[/size]

[size=4]then the only error is that you've put semicolon after if() instead of a colon[/size]

[size=4]so it should be[/size]

[CODE]
...
map = xml.dom.minidom.parseString(document)
if (map.documentElement.tagName != "osm"):
print('Bad File Type')
return
[/CODE]

EDIT: late reply

Thank you Both of my friends

but it not working and i don't know why my Houdini console is not showing in popup

Share this post


Link to post
Share on other sites

open Window/Python Source Editor

paste this there (hopefully it comes through with correct indents)


def go():
import xml.dom.minidom
document="""
<osk version="0.6" generator="CGImap 0.1.0" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<bounds minlat="40.7432000" minlon="-73.9897000" maxlat="40.8052000" maxlon="-73.9304000"/>
<node id="1420631950" lat="40.7711745" lon="-73.9792204" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631974" lat="40.7716867" lon="-73.9779803" user="Aaron Lidman" uid="53073" visible="true" version="2" changeset="15468871" timestamp="2013-03-23T17:11:31Z"/>
<node id="1420631985" lat="40.7694268" lon="-73.9788969" user="dchiles" uid="153669" visible="true" version="1" changeset="9189979" timestamp="2011-09-02T04:12:03Z"/>
</osk>
"""
map = xml.dom.minidom.parseString(document)
if (map.documentElement.tagName != "osk"):
print('Bad File Type')
return[/CODE]

press Apply

then open Python Shell and type

[CODE]hou.session.go()[/CODE]

it will execute your function defined in python source editor, it's easier to debug that way than writing everything in shell

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Dear Tomas

its working, but i have a question, why Houdini console not running for me?

edit:

houdini console is working perfect!!

Edited by m0rtezaaghili

Share this post


Link to post
Share on other sites

in my experience the Houdini Console don't show up if it has other output available

usually while I have Python Shell open all python outputs are shown directly in there

or while i was working on Linux they were output to Linux Shell

otherwise I didn't have a problem of console not showing up

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×