Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Bounding Box

$
0
0

@onlyforpeace wrote:

Hello!

i’ve got a problem on a python script…
i have a lot of steel frame, in a doc, and i want to list them with a python script,
so my script take all metal tube, and make a bounding box around to give the lenght, and the section, but i’ve got a difference i think it’s the tolerance, but i don’t know where…

# coding: utf-8
import rhinoscriptsyntax as rs

def Orientation_Plane(Tube):
    ArrSurf=rs.ExplodePolysurfaces(Tube)
    Area=0
    for Surf in ArrSurf:
        AreaSurf=rs.SurfaceArea(Surf)
        if AreaSurf[0]>Area:
            BigSurf=Surf
            Area=AreaSurf[0]
    ArrEdge=rs.DuplicateEdgeCurves(BigSurf, select=False)
    Lg=0
    for Edge in ArrEdge:
        LgEdge=rs.CurveLength(Edge)
        if LgEdge>Lg:
            BigEdge=Edge
            Lg=LgEdge
    UDom=rs.SurfaceDomain(BigSurf,0)
    VDom=rs.SurfaceDomain(BigSurf,1)
    NormSurf=rs.SurfaceNormal(BigSurf,((UDom[1]-UDom[0])/2,(VDom[1]-VDom[0])/2))
    Origine=rs.CurveStartPoint(BigEdge)
    XVect=rs.CurveEndPoint(BigEdge)-rs.CurveStartPoint(BigEdge)
    Plane=rs.PlaneFromNormal(Origine,NormSurf,XVect)
    #rs.AddPlaneSurface(Plane, 500,500)
    rs.DeleteObjects(ArrEdge)
    rs.DeleteObjects(ArrSurf)
    BBox=rs.BoundingBox(Tube,Plane)
    rs.AddBox(BBox)
    print 'longueur', int(Lg)
    print 'Section', int(rs.Distance(BBox[3],BBox[0])),'x',int(rs.Distance(BBox[4],BBox[0]))
    


ArrTube=rs.GetObjects("selectionne l'ensemble des tubes")
PrefixTube=rs.GetString("une lettre de nommage?")
for Tube in ArrTube:
    Orientation_Plane(Tube)

it’s for square tube, i draw 70 x 70 square with 2000 lenght, and some times it’s returns 2000 x 70 x 69…

maybe you will see where is the matter…

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles