Jump to content

My python Code Not working


m0rtezaaghili

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

Link to comment
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]

Link to comment
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
Link to comment
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

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...