Jump to content
twk

vs. AddSurface in this situation??

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

Share this post


Link to post

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

 

Share this post


Link to post

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

Share this post


Link to post

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

 

Share this post


Link to post

Like I said, someone else will have to help with Python syntax 😉

 

Share this post


Link to post

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

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×