Esempio n. 1
0
def alloyWeight():
    #alloy density
    density = {
        "Sterling Silver": 0.0105,
        "18K White": 0.0176,
        "18K Yellow": 0.0155,
        "9K White": 0.014,
        "9K Yellow": 0.012,
        "Platinum": 0.0215
    }

    #create option list
    alloy = []
    for y in density:
        alloy.append(y)
    try:
        #select object
        objs = rs.GetObject("Select PolySurfaces", rs.filter.polysurface)
        if objs is None:
            print "Aborted"
            return
        #check for naked edges
        if not rs.IsObjectSolid(objs):
            rs.ClearCommandHistory()
            print("\nPolySurface not solid")
            return
        #check for valid selection
        if objs:
            choice = rd.ListBox(alloy, "Select Alloy", "Alloys")
            wgt = round(rs.SurfaceVolume(objs)[0] * density.get(choice), 2)
            rs.ClearCommandHistory()
            print("\nVolume: " + str(round(rs.SurfaceVolume(objs)[0], 2)) +
                  " amounts to " + str(wgt) + "g of " + choice)
        else:
            rs.ClearCommandHistory()
            print("\nNo valid PolySurface Selected!")
    except:
        print "Operation Aborted"
        Rhino.Commands.Result.Cancel
Esempio n. 2
0
def ringSizes():
    fingerSizes = {}
    fingerChoice = []
    startSize = 72
    endSize = 91
    start = 14.5
    h_incr = 0.2

    for x in range(startSize, endSize):
        start += h_incr
        fingerSizes[str(chr(x))] = round(start, 2)
        start += h_incr
        fingerSizes[str(chr(x)) + chr(189)] = round(start, 2)

        fingerChoice.append(chr(x))
        fingerChoice.append(chr(x) + chr(189))
    #debug
    #print(fingerSizes)

    #listbox
    if fingerChoice:
        try:
            result = rd.ListBox(sorted(fingerChoice), "Select FingerSize",
                                "Finger Size", "N")
            if result:
                myLayer = "Finger Size: " + result
                rs.AddLayer(myLayer, col.Brown)
                rs.CurrentLayer(myLayer)
                rs.CurrentView("front")
                rs.Command("_Circle 0 " + str(fingerSizes.get(result)))
                rs.CurrentLayer("Default")
                rs.LayerLocked(myLayer, True)
                rs.ClearCommandHistory()
                if rs.IsLayer(myLayer):
                    print("\nFinger rail added!")
            else:
                print("\nOperation Aborted")
        except:
            print "Aborted by user"
Esempio n. 3
0
    def __init__(self):
        rs.AddLayer("garbage", visible=False)
        self.max = 500
        self.fsr = 3
        self.loc_pts = []
        self.res_obj = []
        self.num_copies = 1
        self.site_crv = rs.GetObject('pick site boundary')
        self.site_copy = []
        FileName = "input.csv"
        FilePath = rs.GetString(
            "Enter the working directory for the program : ")
        if (FilePath == ""):
            FilePath = 'c:/nir_dev/temp/output_1'
        try:
            os.stat(FilePath)
        except:
            print('folder does not exist')
            return
        os.chdir(FilePath)
        req_fsr = 3.0
        """
        # since total area for each function is given, fsr required is not applicable
        try:
            self.fsr=float(rs.GetString("Enter FSR required"))
        except:
            print('this is incorrect data type default value of fsr=3.0 assumed')
        """
        n = rs.GetInteger('Enter number of variations required')
        if (n == 0 or n == None):
            n = 1
        a = int(math.sqrt(n))
        b = int(math.sqrt(n))
        self.num_copies = n
        self.max = self.getMax()
        req_str_li = []
        k = 0
        rs.ClearCommandHistory()
        print('processing...')
        rs.EnableRedraw(False)

        # this is the correct field
        for i in range(0, a, 1):
            for j in range(0, b, 1):
                print('iteration %s in RunProc()' % (k))
                temp_site_crv = rs.CopyObject(self.site_crv,
                                              [self.max * i, self.max * j, 0])
                self.site_copy.append(temp_site_crv)
                m = main(FileName, self.fsr, temp_site_crv)
                r = m.getInpObj()
                self.res_obj.append(r)
                m.genFuncObj_Site()
                s = m.retResult()
                req_str_li.append(s)
                pt = rs.CurveAreaCentroid(temp_site_crv)[0]
                self.loc_pts.append(pt)
                self.addLabel(k, temp_site_crv)
                k += 1
        try:
            self.writeToCsv(k, req_str_li)
        except:
            pass
        # end of correct code block

        # start of revised code block
        """
        for i in range(0,a,1):
            for j in range(0,b,1):
                print('iteration %s in RunProc()'%(k))
                temp_site_crv=self.site_crv#rs.CopyObject(self.site_crv,[self.max*i,self.max*j,0])
                self.site_copy.append(temp_site_crv)
                m=main(FileName,self.fsr,temp_site_crv)
                r=m.getInpObj()
                self.res_obj.append(r)
                m.genFuncObj_Site()
                s=m.retResult()
                req_str_li.append(s)
                pt=rs.CurveAreaCentroid(temp_site_crv)[0]
                self.loc_pts.append(pt)
                self.addLabel(k,temp_site_crv)
                rs.RenderColor(1,(255,255,255))
                str_img=str(k+1)+'.png'
                rs.Redraw()
                #rs.Command("_ViewCaptureToFile",tr_img)
                rs.CreatePreviewImage(str_img, "Perspective", (1200,1024), 4, False)
                print('img created')
                m.delResult()
                k+=1
        self.writeToCsvPcp(k,req_str_li)
        """
        #end of revised code block

        rs.EnableRedraw(True)
Esempio n. 4
0
 def __init__(self, crv):
     rs.ClearCommandHistory()
     self.SITECRV=crv
     self.counter=0
     self.start()
Esempio n. 5
0
import rhinoscript.userinterface
import rhinoscript.geometry
import rhinoscriptsyntax as rs
import file2 as proc

__commandname__ = "gensite"

def RunCommand( is_interactive ):
  p=proc.RunProc()
  printDetails()
  return 0
rs.ClearCommandHistory()

def printDetails():
    print "This is a site builder plugin created by Georgia Institute of Technology in association with Perkins and Will"
    print "Contact:\n\t1. Nirvik: [email protected] \n\t2. John: [email protected] \n\t3. Dennis: [email protected]"

RunCommand(True)