Piyushraj59 Posted July 17, 2020 Share Posted July 17, 2020 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 Quote Link to comment Share on other sites More sharing options...
DonRomano Posted July 17, 2020 Share Posted July 17, 2020 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 Quote Link to comment Share on other sites More sharing options...
berkninan Posted October 28, 2020 Share Posted October 28, 2020 Python language is a very sensitive language for indentation, it has caused confusion for many beginners. Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include: Forgetting to indent the statements within a compound statement Forgetting to indent the statements of a user-defined function. The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces. The indentation can be any consistent white space . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.