twk Posted June 15, 2019 Share Posted June 15, 2019 The Addsurface function only takes in two handles. How would you do a list of handles? As per screenshot below: where some rectangles are overlapping and some aren't? using Addsurface in a for loop seems impossible as once the surfaces are added h1, h2 are deleted. Thoughts anyone? Quote Link to comment
twk Posted June 17, 2019 Author Share Posted June 17, 2019 Got it to work! # Disclaimer: no responsibility taken for data loss. Code responsibly, save often. def addsurface_from_list(objs_list:list): # where objs_list is a list of object handles of rectangle/polygon/arc/etc.. if len(objs_list) > 0: fobj = objs_list[0] for o in objs_list[1:]: add = vs.AddSurface(fobj, o) if add not in [0, None]: objs_list.remove(o) objs_list.append(add) break addsurface_from_list(objs_list[1:]) Quote Link to comment
Pat Stanford Posted June 17, 2019 Share Posted June 17, 2019 Nice work. I thought I had responded last week, but it ended up sitting as a draft. You ended up exactly what I was going to recommend. Add 2 then add Repeat add 1 to the result. You might need to add some error checking. The manual for AddSurface says it only works with overlapping objects. You could get a nil handle for the added object if they don't overlap. Good Job! 1 Quote Link to comment
twk Posted June 17, 2019 Author Share Posted June 17, 2019 the vs.AddSurface result is either a handle if surfaces overlap, or None/0 if the added surfaces don't overlap. I provided error checking on line: if add not in [0, None]: Quote Link to comment
Pat Stanford Posted June 17, 2019 Share Posted June 17, 2019 Like I said, someone else will have to help with Python syntax 😉 Quote Link to comment
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.