Esempio n. 1
0
    def save_image(self):

        save_path = SNAPSHOT_FOLDER + "_SnapShot2.png"
        save_path_2 = SNAPSHOT_FOLDER + "_SnapShot1.png"
        persp_view = "Perspective"
        top_view = "Top"
        desire_width = 1800
        
        views = rs.ViewNames()
        
        try:
            if views:
                persp_view = views[0]
                top_view = views[1]
            width,height = rs.ViewSize(persp_view)
            scale = int(desire_width/width)
            image_size = (width*scale,height*scale)
            #rs.CurrentView(persp_view)
            rs.CreatePreviewImage(save_path, view=persp_view, size=image_size, flags=2, wireframe=False)
            #rs.Command("-_ViewCaptureToFile %s Width=%s  Height=%s  Scale=%s  DrawGrid=%s  DrawWorldAxes=%s  DrawCPlaneAxes=%s  TransparentBackground=%s _Enter" %(save_path,width,height,scale,"No","Yes","Yes","Yes"))
            width,height = rs.ViewSize(top_view)
            scale = int(desire_width/width)
            #rs.CurrentView(top_view)
            rs.CreatePreviewImage(save_path_2, view=top_view, size=image_size, flags=2, wireframe=False)
            #rs.Command("-_ViewCaptureToFile %s Width=%s  Height=%s  Scale=%s  DrawGrid=%s  DrawWorldAxes=%s  DrawCPlaneAxes=%s  TransparentBackground=%s _Enter" %(save_path_2,width,height,scale,"No","Yes","Yes","Yes"))
            return save_path,save_path_2
        except:
            return False
Esempio n. 2
0
def PostViewToTumblr(email, password):
    size = rs.ViewSize()
    path = '\\mypic.png'
    rs.Command('-_ViewCaptureToFile ' + path + ' Width=' + str(size[0]) + ' Height=' + str(size[1]) + ' DrawGrid=Yes DrawWorldAxes=Yes DrawCPlaneAxes=Yes _Enter', 0)
    print 'Post ' + rs.CurrentView() + ' view to tumblr' 
    comment = rs.StringBox (title='Add a caption to your post')

    url = 'http://www.tumblr.com/api/write'

    img=open(path, 'rb').read()

    values = {
    'type': 'photo',
    'email': email,
    'password': password,
    'data': img,
    'send-to-twitter': 'auto',
    'caption' : comment}
    
    data = urlencode(values,'utf-8')
    req = Request(url, data)

    try:
        response = urlopen(req)
        page = response.read()
        print 'Upload successful'
    except HTTPError, e:
        print 'Upload failed ' + e.code
Esempio n. 3
0
def GetPointDynamicDrawFuncHide(sender, args):

    obj_all = rs.VisibleObjects()
    rs.HideObjects(obj_all)

    cursPos = rs.GetCursorPos()
    viewSize = rs.ViewSize()
    stepSize = int(viewSize[1] / _NUM_LAYER)

    obj_Layer1 = 'Layer: 000001 Wall1'
    obj_Layer2 = 'Layer: 000002 Wall1'
    settings = Rhino.DocObjects.ObjectEnumeratorSettings()
    settings.HiddenObjects = True

    settings.NameFilter = obj_Layer1
    ids_L1 = [rhobj.Id for rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]

    settings.NameFilter = obj_Layer2
    ids_L2 = [rhobj.Id for rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]

    z_L1 = rs.BoundingBox(ids_L1[0])[0][2]
    z_L2 = rs.BoundingBox(ids_L2[0])[0][2]

    zVal = viewSize[1] - cursPos[3][1]

    z_level = int(zVal / stepSize)

    segmentList = ['Wall',
                   'DenseInfill',
                   'SparseInfill',
                   'Brim',
                   'Skirt',
                   'Support']

    zero_str = '000000'

    settings = ObjectEnumeratorSettings()
    settings.HiddenObjects = True

    for segment in segmentList:
        i = 0
        while 1:
            i += 1
            obj_LayerZ = str('Layer: ' + zero_str[:-len(str(z_level))] + str(z_level) + ' ' + segment + str(i))
            try:
                settings.NameFilter = obj_LayerZ
                ids_LZ = [rhobj.Id for rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]
                if len(ids_LZ) == 0:
                    break
                # rs.SelectObject(ids_LZ)
                rs.ShowObject(ids_LZ)

            except:
                print 'not found'

    args.Display.DrawDot(args.CurrentPoint, 'Layer ' + str(z_level) + ' - Distance ' + str(z_L2 - z_L1) + ' mm')
    Rhino.Display.RhinoView.Redraw(scriptcontext.doc.Views.ActiveView)
    Rhino.RhinoApp.Wait()
Esempio n. 4
0
                    rs.ZoomExtents()
                    create_view_image(
                        conf['part_img_right'] % (stepnumeral, partkind), w_l,
                        h_l)
                    #
                    rs.HideObject(part)
            for partkind, vvv in vv.items():
                rs.ShowObject(vvv)
            rs.LayerVisible(step, False)
        # utils.show_children(subsystem)
        utils.show_step_children(subsystem)
    utils.show_blocks()
    utils.show_subsystems()
    rs.ZoomExtents()


clear_img_dir()
# get CAD file structure
structure = utils.get_structure()
utils.structure_to_file(structure)
# set up view
rs.CurrentView(rs.ViewNames()[-1])  # typ "Perspective" on 4th tab
view_to_restore = rs.CurrentView()
size = rs.ViewSize()
view_aspect = size[0] / float(size[1])
# generate images
generate_step_images(structure)
generate_part_images(structure)
# restore view
rs.CurrentView(view_to_restore)