Back to SDS/2 Parametric Scripts

 

## VBtoVBFraming.py Version 1.00

## Copyright (c) 2007 Bruce Vaughan, BV Detailing & Design, Inc.

## All rights reserved.

## NOT FOR SALE. The software is provided "as is" without any warranty.

###############################################################################

"""

## Determine supporting VB member object at each end of a vertical brace member

## Also determine VB member object on FS of supporting member

## Set attributes to string "None" if no member is found

## Members must have at least one coincident point and occur at the 'LE'

##  or 'RE' of the supported vertical brace.

## DO NOT USE SWAP MEMBER ENDS!!!

##

## Version 1.00 (2/1/07) -    Initial release

"""

from macrolib.L3D import DistancePointLine3D, LineLineIntersect3D

from point import Point

from member import Member, MemberLocate, MemberAllocated

from param import yes_or_no, Warning, ClearSelection

 

class VBtoVBSupport(object): 

    def __init__(self, mem1, mem_type='Vertical Brace', prox=0.01):

        mi = 1               # member index

        self.right_member = "None"

        self.right_thru_mem = "None"

        self.left_member = "None"

        self.left_thru_mem = "None"

       

        # Look for supporting VB member

        while mi < MemberAllocated() and (self.right_member == "None" or self.left_member == "None"):

            try:

                mem2 = Member(mi)

            except:

                mi = mi + 1

            else:

                if mem2.type in [mem_type, ]:

                    # Supporting VB ends, supported VB right end

                    a = DistancePointLine3D(mem2.left.location, mem2.right.location, mem1.right.location)

                    # Supporting VB ends, supported VB left end

                    b = DistancePointLine3D(mem2.left.location, mem2.right.location, mem1.left.location)

                    if self.right_member == "None":

                        if (a.position == "Not Beyond LE" or a.position == "Not Beyond RE") and a.dist < prox:

                            self.right_member = mem2

                    if self.left_member == "None":

                        if (b.position == "Not Beyond LE" or b.position == "Not Beyond RE") and b.dist < prox:

                            self.left_member = mem2

                mi += 1

        # Look for 'thru' VB member if a supporting member is present

        if self.right_member != "None":

            mi = 1

            while mi < MemberAllocated() and self.right_thru_mem == "None":

                try:

                    mem2 = Member(mi)

                except:

                    mi = mi + 1

                else:

                    if mem2.type in [mem_type, ]:

                        if mem1.right.location.dist(mem2.left.location) < prox:

                            self.right_thru_mem = mem2

                mi += 1

                           

        if self.left_member != "None":

            mi = 1

            while mi < MemberAllocated() and self.left_thru_mem == "None":

                try:

                    mem2 = Member(mi)

                except:

                    mi = mi + 1

                else:

                    if mem2.type in [mem_type, ]:

                        if mem1.left.location.dist(mem2.right.location) < prox:

                            self.left_thru_mem = mem2

                mi += 1

               

        #print self.left_member, self.left_thru_mem, self.right_member, self.right_thru_mem

                           

# end class definition

#####################################################################

 

def test_VBtoVBSupport():

    while 1:

        ClearSelection()

        mem1 = MemberLocate("Select a VB MEMBER")

       

        a = VBtoVBSupport(mem1)

       

        if a.left_member != "None":

            print type(a.left_member)

            if 'member' in repr(a.left_member):

                print 'left member!'

            Warning("A left end %s member object was found.\nMember # = %s\nMember piecemark = %s\nSection size = %s\n\n" % \

                    (a.left_member.type, a.left_member.number, a.left_member.piecemark, a.left_member.section_size))

            if a.left_thru_mem != "None":

                Warning("A left end %s thru_mem object was found.\nMember # = %s\nMember piecemark = %s\nSection size = %s\n\n" % \

                        (a.left_thru_mem.type, a.left_thru_mem.number, a.left_thru_mem.piecemark, a.left_thru_mem.section_size))

               

        else:

            print type(a.left_member)

            if 'member' not in repr(a.left_member):

                print 'NO left member!'

            Warning("There was no left end member object found.")

 

        if a.right_member != "None":

            print type(a.right_member)

            if 'member' in repr(a.right_member):

                print 'right member!'

            Warning("A right end %s member object was found.\nMember # = %s\nMember piecemark = %s\nSection size = %s\n\n" % \

                    (a.right_member.type, a.right_member.number, a.right_member.piecemark, a.right_member.section_size))

            if a.right_thru_mem != "None":

                Warning("A right end %s thru_mem object was found.\nMember # = %s\nMember piecemark = %s\nSection size = %s\n\n" % \

                        (a.right_thru_mem.type, a.right_thru_mem.number, a.right_thru_mem.piecemark, a.right_thru_mem.section_size))

        else:

            print type(a.right_member)

            if 'member' not in repr(a.right_member):

                print 'NO right member!'

            Warning("There was no right end member object found.")

           

        if not yes_or_no("Again?"):

            break

    ## END test_mem_splice_object() #################################################

if __name__ == '__main__':

    try:

        test_VBtoVBSupport()

    finally:

        del test_VBtoVBSupport

        del VBtoVBSupport