So what's wrong with the code? It's what the dude did in the video. Just not working.
# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()
# Add code to modify the contents of geo.
def createCity():
import xml.dom.minidom
document=“”“
<osm version=”0.6“ generator=”Overpass API“>
<bounds minlat=”48.8423“ minlon=”2.3157“ maxlat=”48.8665“ maxlon=”2.3831“/> <node id=”361029“ lat=”48.8457739“ lon=”2.3675260“ version=”8“ timestamp=”2016-02-27T23:10:15Z“ changeset=”37491193“ uid=”522742“ user=”josmougn“/>
<node id=”361031“ lat=”48.8474791“ lon=”2.3655560“ version=”10“ timestamp=”2010-04-24T20:33:32Z“ changeset=”4515716“ uid=”17286“ user=”Pieren“>
<node id=”361032“ lat=”48.8508895“ lon=”2.3672954“ version=”5“ timestamp=”2010-04-24T19:09:56Z“ changeset=”4514867“ uid=”17286“ user=”Pieren“>
<node id=”361035“ lat=”48.8521381“ lon=”2.3695760“ version=”6“ timestamp=”2012-09-17T10:15:20Z“ changeset=”13141345“ uid=”456113“ user=”eric_G“/>
<node id=”361036“ lat=”48.8487850“ lon=”2.3679961“ version=”10“ timestamp=”2010-01-19T22:34:18Z“ changeset=”3662928“ uid=”33634“ user=”lapinos03“/>
<node id=”361038“ lat=”48.8428684“ lon=”2.3639709“ version=”9“ timestamp=”2012-10-07T15:43:26Z“ changeset=”13399945“ uid=”456113“ user=”eric_G“/>
<node id=”361046“ lat=”48.8399618“ lon=”2.3618169“ version=”14“ timestamp=”2011-02-08T22:27:26Z“ changeset=”7231649“ uid=”17286“ user=”Pieren“/>
<node id=”361047“ lat=”48.8416665“ lon=”2.3519925“ version=”5“ timestamp=”2012-11-08T17:39:03Z“ changeset=”13799861“ uid=”456113“ user=”eric_G“>
<osm/>
”“”
map = xml.dom.minidom.parseString(document)
if(map.documentElement.tagName != “osm”):
print ('Bad File Type')
return
def handleNodes(xmlData):
bounds = xmlData.getElementsByTagName(“bounds”)
minlat = float(bounds.getAttribute('minlat'))
maxlat = float(bounds.getAttribute('maxlat'))
minlon = float(bounds.getAttribute('minlon'))
maxlon = float(bounds.getAttribute('maxlon'))
normalizingFactor = sizeMultiplier / max((maxlon-minlon),(maxlat-minlat))
nodes = xmlData.getElementsByTagName('node')
for node in nodes:
lat = float(node.getAttribute('lat'))
lon = float(node.getAttribute('lon'))
normalizedLat = (lat-minlat) * normalizingFactor
normalizedLon = (lon-minlon) * normalizingFactor
point = geo.createPoint()
handleNodes(map)
map.unlink()
createCity()
CMIVFX - XML Cities
2413 4 0- tadian
- Member
- 90 posts
- Joined: March 2013
- Offline
- Enivob
- Member
- 2531 posts
- Joined: June 2008
- Offline
You need to at least report the error, dude.
How can we guess? There is a divide are you dividing by zero? Does the import fail? Is there indentation error? The list goes on. If it is cmiVFX training, that training comes with all the assets already typed in. Try using the supplied example file.
How can we guess? There is a divide are you dividing by zero? Does the import fail? Is there indentation error? The list goes on. If it is cmiVFX training, that training comes with all the assets already typed in. Try using the supplied example file.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- tadian
- Member
- 90 posts
- Joined: March 2013
- Offline
Awesome a Houdini Expert….Just what all of this may need
I have a feeling some form of functionality has been removed from houdini and this is causing the error. I hope there is a workaround.
OK, so this is for a new operator type - with operator name: OSMCity and Operator Label: OSMCity - Python Type - Network Type: Geometry Operator and finally saved as OSMCity.otl
Under Basic tab set the Minimum Inputs to 0 and the Maximum Inputs to 0
Go to the Code tab and run the code. You will get the following error…
Error: Python error: Traceback (most recent call last):
File “<stdin>”, line 57, in ,module
File “<stdin>”, line 23, in ,createCity
File “C:\PROGRA~1\SIDEEF~1\HOUDINI~1.16\python27\lib\xml\dom\minidobm.py”' . line 1931 , in parseString return expatbuilder.parseString(string)
File “C:\PROGRA~1\SIDEEF~1\HOUDINI~1.16\python27\lib\xml\dom\expatbuilder.py”, line 940, in parseString return builder.parseString(string)
File “C:\PROGRA~1\SIDEEF~1\HOUDINI~1.16\python27\lib\xml\dom\expatbuilder.py”, line 223, in parseString parser.Parse(string, True)
ExpatError: no element found: line 12, column 4
Last thing: attaching img of the code to see if that will help with formatting.
I have a feeling some form of functionality has been removed from houdini and this is causing the error. I hope there is a workaround.
OK, so this is for a new operator type - with operator name: OSMCity and Operator Label: OSMCity - Python Type - Network Type: Geometry Operator and finally saved as OSMCity.otl
Under Basic tab set the Minimum Inputs to 0 and the Maximum Inputs to 0
Go to the Code tab and run the code. You will get the following error…
Error: Python error: Traceback (most recent call last):
File “<stdin>”, line 57, in ,module
File “<stdin>”, line 23, in ,createCity
File “C:\PROGRA~1\SIDEEF~1\HOUDINI~1.16\python27\lib\xml\dom\minidobm.py”' . line 1931 , in parseString return expatbuilder.parseString(string)
File “C:\PROGRA~1\SIDEEF~1\HOUDINI~1.16\python27\lib\xml\dom\expatbuilder.py”, line 940, in parseString return builder.parseString(string)
File “C:\PROGRA~1\SIDEEF~1\HOUDINI~1.16\python27\lib\xml\dom\expatbuilder.py”, line 223, in parseString parser.Parse(string, True)
ExpatError: no element found: line 12, column 4
Last thing: attaching img of the code to see if that will help with formatting.
- Enivob
- Member
- 2531 posts
- Joined: June 2008
- Offline
- tadian
- Member
- 90 posts
- Joined: March 2013
- Offline
-
- Quick Links