konstantin magnus Posted December 25, 2018 Share Posted December 25, 2018 (edited) I want to export single tiles of a grid by their id attribute with Python. Because saveToFile() is lacking any filter options, I am trying to use a loop for deleting all redundant primitives before each export. Unfortunately once primitives have been deleted for the first time, they are gone for all subsequent loops, too. node = hou.pwd() geo = node.geometry() dir_exp = node.evalParm('dir_export') id_values = geo.primIntAttribValues("id") id_count = len(set(id_values)) # is there a more hou way to count unique attribute values? for iteration in range(id_count): geo_change = geo path_export = dir_exp + 'segment' + str(iteration) + '.obj' prims = [p for p in geo_change.prims() if p.attribValue('id') != iteration] geo_change.deletePrims(prims) # how can I keep the full geo data for the remaining loops? geo_change.saveToFile(path_export) How can I keep the full geometry for each loop? And are there any better ways to export geometry parts based on attributes with Python? landscape_slice_export.hiplc Edited December 25, 2018 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
petz Posted December 28, 2018 Share Posted December 28, 2018 there are a number of different ways how you could do this. for high polycount meshes, however, python might be fairly slow ... please take a look at the attached file. hth. petz landscape_slice_export_1.hiplc 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 5, 2019 Author Share Posted March 5, 2019 On 28.12.2018 at 1:53 AM, petz said: for high polycount meshes, however, python might be fairly slow ... Thank you again! It performs nicely for exporting some sliced cityscapes that need 3d printing. 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.