Jump to content

vs. AddSurface in this situation??


twk

Recommended Posts

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?

 

image.thumb.png.297675aa58346417f4f1609966f40636.png

Link to comment

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:])

 

Link to comment

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!

  • Like 1
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...