def SetUp(offset,h):

    sheet = rs.AddBox([[-10,-10,h],[10,-10,h],[10,10,h],[-10,10,h],[-10,-10,0],[10,-10,0],[10,10,0],[-10,10,0]])
    bigSheet = sheet

    box2 = rs.AddBox([[-5.25,-5.25,1],[5.25,-5.25,1],[5.25,5.25,1],[-5.25,5.25,1],[-5.25,-5.25,-2],[5.25,-5.25,-2],[5.25,5.25,-2],[-5.25,5.25,-2]])

    rs.MoveObject(box2, move_it)

    ribc = rs.BooleanIntersection([box2],[bigSheet],True)



    rs.SelectObject(ribc)
    rs.Command("_-Export C:\\" + dirsname + "\\protoslant_walk.igs ENTER")
    rs.Command("_SelNone")
    Rhino.FileIO.File3dm.Polish
    
    #fileName = Rhino.FileIO.File3dm
    
    #Rhino.FileIO.File3dm.Write(fileName,"C:\\"+dirsname+"\\protoslant_walk.3dm",5)
    rs.Command("_-Save C:\\" + dirsname + "\\protoslant_walk.3dm ENTER")
for i in range(0, 300):
    xnum = randX(10)
    ynum = randY(10)
    znum = randZ(10)
    pt = rs.AddPoint(placePt(100, 100, 50))

    index = rs.PointArrayClosestPoint(pts, pt)
    cp = pts[index]
    vect = rs.VectorCreate(cp, pt)
    unitVect = rs.VectorUnitize(vect)
    subVect = vect - unitVect
    newPt = rs.MoveObject(pt, subVect)

    #find newPt coordinates to feed into the 8 needed box corners
    newPtCoord = rs.PointCoordinates(newPt)
    #newPtCoord = rs.PointCoordinates(pt)
    #take newPt coordinates index 0,1, or 2 for x,y, or z respectively,
    #add random xnum,ynum, or znum to respective index
    newboxArray = rs.AddBox([(newPtCoord),(newPtCoord[0]+xnum,newPtCoord[1],newPtCoord[2]),\
    (newPtCoord[0]+xnum,newPtCoord[1]+ynum,newPtCoord[2]),(newPtCoord[0],newPtCoord[1]+ynum,newPtCoord[2]),\
    (newPtCoord[0],newPtCoord[1],newPtCoord[2]+znum),(newPtCoord[0]+xnum,newPtCoord[1],\
    newPtCoord[2]+znum),(newPtCoord[0]+xnum,newPtCoord[1]+ynum,newPtCoord[2]+znum),\
    (newPtCoord[0],newPtCoord[1]+ynum,newPtCoord[2]+znum)])
    pts.append(newPt)

    boxes.append(newboxArray)

selectVol = rs.GetObject("Select main volume")
boolInter = rs.BooleanIntersection(selectVol, boxes)
def bool_solids(los):
    env = los.pop(0)
    for s in los:
        e = rs.BooleanIntersection(env, s, True)
        env = e
    return env
Esempio n. 4
0
def main():


    # get objects to export
    objs = rs.GetObjects("select objects to Make3d", 0, True, True)
    if not objs: print "make3d aborted"; return
    
    # default_thickness =  rs.GetDocumentData('TNM_make3d', 'material_thickness')
    # if default_thickness:
        # default_thickness = float( default_thickness )
    # else:
        # default_thickness = 18
    
    material_thickness = rs.GetReal("Material Thickness", number=18.3)

    # rs.SetDocumentData('TNM_make3d', 'material_thickness', str( material_thickness ) )
        
    
    rs.EnableRedraw(False)

    checkPos(objs)

    set_volumes = []
    set_subtracts = []
    
    for obj in objs:
        if rs.IsBlockInstance(obj):   
            
            # get content
            copy = rs.CopyObject(obj)
            content = ce.explodeBlock( [copy] )
            
            # filter objects to only curves and points
            copies = filterObjects(content) 

            simplify(copies)

            result, subtracts = convertLayers(copies, material_thickness)
            
            set_volumes.append(result)
            set_subtracts.append(subtracts)
             
            rs.DeleteObjects(copies)    
            
            # addResultToBlock(obj, result)
            
        else:
            # add warning message collision check
            print obj
    
    rs.UnselectAllObjects()
    intersect = None
    for i, volume in enumerate(set_volumes):
        for j, subtracts in enumerate(set_subtracts):
            if(i != j):
                print rs.ObjectLayer(volume)
                
                intersect = rs.BooleanIntersection(rs.CopyObject(volume), subtracts, False)
                if intersect:
                    rs.SelectObjects(intersect)
                    
                    
            rs.DeleteObjects(subtracts)

            
       
    
    if intersect:
        rs.MessageBox("ERROR")

        
    redraw()
Esempio n. 5
0
def make_fingers(positive, negative, subdivisions):
  """
  intersect two collections of planes
  subdivide the intersections
  assign each subdivision to a guid from which it will be subtracted
  """

  # this vector is used to indicate axis of the intersection.
  # it needs to be parallel to the intersection
  # (there are other ways of doing this!)
  p0 = rs.GetPoint("select start of intersection")
  p1 = rs.GetPoint("select end of intersection")

  edge = rs.AddLine(p0, p1)
  vector = rs.VectorCreate(p0, p1)

  rs.EnableRedraw(False)

  # this dict maps a pair of planes (ps, ns) to their booleanintersection
  intersections = {}

  for ps in positive:
    for ns in negative:
      intersection = rs.BooleanIntersection(ps, ns, False)
      if intersection is not None:
        intersections[(ps, ns)] = intersection

  # here we construct some very large cylinders aligned with the axis you drew
  origins = []
  cylinders = []
  for i in range(subdivisions+1):
    origin = rs.EvaluateCurve(edge, rs.CurveParameter(edge, i * 1.0/(subdivisions)))
    origins.append(origin)

  rs.DeleteObject(edge)

  for i in range(subdivisions):
    plane = rs.PlaneFromNormal(origins[i], vector)
    circle = rs.AddCircle(plane, 100)
    planar_circle = rs.AddPlanarSrf(circle)

    extrusion_curve = rs.AddLine(origins[i], origins[i+1])
    cylinders.append(rs.ExtrudeSurface(planar_circle, extrusion_curve))

    rs.DeleteObject(circle)
    rs.DeleteObject(planar_circle)
    rs.DeleteObject(extrusion_curve)


  # we perform a boolean intersection between each intersection and
  # the cylinders to construct the fingers
  for key, intersection in intersections.items():
    ps, ns = key

    for i, cylinder in enumerate(cylinders):
      print "intersection", intersection
      print "cylinder", cylinder
      objs = [brep for brep in rs.BooleanIntersection(intersection, cylinder, False) if rs.IsBrep(brep)]
      # assign the resulting fingers to either the positive or negative
      if i % 2 == 0:
        guid_to_difference[ps].extend(objs)
      else:
        guid_to_difference[ns].extend(objs)

  DeleteItemOrList(cylinders)
  DeleteItemOrList(intersections.values())

  rs.EnableRedraw(True)
Esempio n. 6
0
copy0 = rs.CopyObject(hull)
rs.ObjectLayer(copy0, "Heel_0")

rs.LayerVisible("Default", False)

#####################################################
####                                             ####
#### Creating DWL and obtaining submerged volume ####
####                                             ####
#####################################################

aux_plane = rs.PlaneFromFrame( [-5,-50,draft], [1,0,0], [0,1,0] )
dwl = rs.AddPlaneSurface(aux_plane, 100, 100)

inter = rs.BooleanIntersection(copy0, dwl, False)

Nabla = rs.SurfaceVolumeCentroid(inter)
if Nabla:
    cb = rs.AddPoint(Nabla[0])

Volume0 = rs.SurfaceVolume(inter)
Initial_Volume = Volume0[0]

####################################
####                            ####
#### Heeled volume calculations ####
####                            ####
####################################

currentl2 = rs.CurrentLayer("Heel_20")
def main(north, boundary, timeperiod, monthRange, location):
    if sc.sticky.has_key('ladybug_release'):
        try:
            if not sc.sticky['ladybug_release'].isCompatible(ghenv.Component):
                return -1
        except:
            warning = "You need a newer version of Ladybug to use this compoent." + \
            "Use updateLadybug component to update userObjects.\n" + \
            "If you have already updated userObjects drag Ladybug_Ladybug component " + \
            "into canvas and try again."
            w = gh.GH_RuntimeMessageLevel.Warning
            ghenv.Component.AddRuntimeMessage(w, warning)
            return -1
        lb_sp = sc.sticky["ladybug_SunPath"]()
        lb_prep = sc.sticky["ladybug_Preparation"]()

        # setting solar noon variables
        latitude, longitude, timeZone, elevation = readLocation(_location)
        year = datetime.datetime.now().year
        day = 21
        """
        MONTH_DICT = {0:(3,6), 1:(3,9), 2:(3,12),\
              3:(6,9), 4:(6,12),\
              5:(9,12)}
        """
        s_mth, e_mth = MONTH_DICT[monthRange][0], MONTH_DICT[monthRange][1]
        s_snoon = get_solar_noon(s_mth, year, timeZone, day, latitude,
                                 longitude)
        e_snoon = get_solar_noon(e_mth, year, timeZone, day, latitude,
                                 longitude)
        t = timeperiod / 2.0
        shourlst = [s_snoon - t, s_snoon + t]
        ehourlst = [e_snoon - t, e_snoon + t]
        centerPt = rs.CurveAreaCentroid(boundary)[0]

        # do geometry operations
        boundary = clean_curve(boundary)
        s_sun_pts = get_sunpt(lb_sp,
                              lb_prep,
                              latitude,
                              centerPt,
                              s_mth,
                              day,
                              shourlst,
                              north_=north,
                              lon=longitude,
                              tZ=timeZone,
                              scale_=100)
        e_sun_pts = get_sunpt(lb_sp,
                              lb_prep,
                              latitude,
                              centerPt,
                              e_mth,
                              day,
                              ehourlst,
                              north_=north,
                              lon=longitude,
                              tZ=timeZone,
                              scale_=100)
        szone = make_zone(s_sun_pts, boundary)
        ezone = make_zone(e_sun_pts, boundary)
        return rs.BooleanIntersection(szone, ezone)
    else:
        print "You should first let the Ladybug fly..."
        ghenv.Component.AddRuntimeMessage(
            ERROR_W, "You should first let the Ladybug fly...")