Jump to content

Recommended Posts

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

for prim in geo.prims():
path = prim.attribValue("path")
newpath = path[:20]
Prim.setattribvale("path",newpath)

 

getting error
Error 
Python error: IndentationError: ('expected an indented block', ('', 8, 4, 'path = prim.attribValue("path")\n'))

 

i dont know anything about python i started a tutorial and getting this error he was using some older version of houdini and i am 17.5 may be because of this or anything else, please help me out .

Thanks :) 

Share this post


Link to post
Share on other sites

Your code should look like this : 

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

for prim in geo.prims():
	path = prim.attribValue("path")
	newpath = path[:20]
	Prim.setattribvale("path",newpath)

When you use a for loop or an if statement, you need to indent the block of code you want to execute within this loop.

 

#quick example : create a matrix with each point position
import numpy as np

node = hou.pwd()
geo = node.geometry()

pts = len(geo.iterPoints())

all_pos = np.zeros((pts, 3))

i = 0

for pt in geo.iterPoints():
    #code i want to execute in the loop so I indent it
    all_pos[i, 0] = pt.position()[0]
    all_pos[i, 1] = pt.position()[1]
    all_pos[i, 2] = pt.position()[2]
    
    i += 1
    
#my loop is finished so 
print all_pos

Hope you'll understand,

 

Cheers

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

×