How to use grab method in Pyscreenshot

Best Python code snippet using pyscreenshot_python

ui.py

Source:ui.py Github

copy

Full Screen

1import bpy, os2from bpy.types import Panel3from .preferences import GRABDOC_PT_presets4from .generic_utils import proper_scene_setup5################################################################################################################6# UI7################################################################################################################8class PanelInfo:9 bl_category = 'GrabDoc'10 bl_space_type = 'VIEW_3D'11 bl_region_type = 'UI'12class GRABDOC_OT_config_maps(bpy.types.Operator):13 """Configure the UI visibility of maps (also disables them from baking when hidden)"""14 bl_idname = "grab_doc.config_maps"15 bl_label = "Configure Map Visibility"16 bl_options = {'REGISTER'}17 18 def execute(self, context):19 return {'FINISHED'}20 21 def invoke(self, context, event):22 return context.window_manager.invoke_props_dialog(self, width = 200)23 24 def draw(self, context):25 grabDoc = context.scene.grabDoc26 layout = self.layout27 layout.prop(grabDoc, 'uiVisibilityNormals', text = "Normals")28 layout.prop(grabDoc, 'uiVisibilityCurvature', text = "Curvature")29 layout.prop(grabDoc, 'uiVisibilityOcclusion', text = "Ambient Occlusion")30 layout.prop(grabDoc, 'uiVisibilityHeight', text = "Height")31 layout.prop(grabDoc, 'uiVisibilityMatID', text = "Material ID")32 layout.prop(grabDoc, 'uiVisibilityAlpha', text = "Alpha")33 layout.prop(grabDoc, 'uiVisibilityAlbedo', text = "Albedo (Blender Only)")34 layout.prop(grabDoc, 'uiVisibilityRoughness', text = "Roughness (Blender Only)")35 layout.prop(grabDoc, 'uiVisibilityMetalness', text = "Metalness (Blender Only)")36class GRABDOC_PT_grabdoc(PanelInfo, Panel):37 bl_label = 'GrabDoc Hub'38 def draw_header_preset(self, context):39 if proper_scene_setup():40 GRABDOC_PT_presets.draw_panel_header(self.layout)41 def draw(self, context):42 grabDoc = context.scene.grabDoc43 layout = self.layout44 col = layout.column(align = True)45 row = col.row(align = True)46 row.enabled = not grabDoc.modalState47 row.scale_y = 1.548 row.operator("grab_doc.setup_scene", text = "Refresh Scene" if proper_scene_setup() else "Setup Scene", icon = "TOOL_SETTINGS")49 if proper_scene_setup():50 row.scale_x = 1.151 row.operator("grab_doc.remove_setup", text = "", icon = "CANCEL")52 53 row = col.row(align = True)54 row.scale_y = .9555 row.prop(56 grabDoc,57 "collSelectable",58 text = "Select",59 icon = 'RESTRICT_SELECT_OFF' if grabDoc.collSelectable else 'RESTRICT_SELECT_ON'60 )61 row.prop(62 grabDoc,63 "collVisible",64 text = "Visible",65 icon = 'RESTRICT_VIEW_OFF' if grabDoc.collVisible else 'RESTRICT_VIEW_ON'66 )67 row.prop(68 grabDoc,69 "collRendered",70 text = "Render",71 icon = 'RESTRICT_RENDER_OFF' if grabDoc.collRendered else 'RESTRICT_RENDER_ON'72 )73 box = col.box()74 box.use_property_split = True75 box.use_property_decorate = False76 row = box.row()77 row.prop(grabDoc, "scalingSet", text = 'Scaling', expand = True)78 row = box.row()79 row.enabled = not grabDoc.modalState80 row.prop(grabDoc, "refSelection", text = 'Reference')81 row.operator("grab_doc.load_ref", text = "", icon = 'FILE_FOLDER')82 row = box.row()83 row.prop(grabDoc, "gridSubdivisions", text = "Grid")84 row.separator()85 row.prop(grabDoc, "useGrid", text = "")86class GRABDOC_PT_export(PanelInfo, Panel):87 bl_label = 'Export Maps'88 bl_parent_id = "GRABDOC_PT_grabdoc"89 90 @classmethod91 def poll(cls, context):92 return proper_scene_setup()93 def draw(self, context):94 grabDoc = context.scene.grabDoc95 layout = self.layout96 layout.activate_init = True97 layout.use_property_split = True98 layout.use_property_decorate = False99 user_prefs = context.preferences.addons[__package__].preferences100 marmo_exe = user_prefs.marmoEXE101 col = layout.column(align=True)102 if grabDoc.bakerType == 'Blender':103 row = col.row(align=True)104 row.scale_y = 1.5105 row.operator("grab_doc.export_maps", icon = "EXPORT")106 else: # Marmoset107 row = col.row()108 if not os.path.exists(marmo_exe):109 row.alignment = 'CENTER'110 row.label(text="Give Marmoset Toolbag .exe Path", icon = 'INFO')111 row = col.row()112 row.prop(user_prefs, 'marmoEXE', text = 'Toolbag .exe')113 col.separator()114 else:115 row.prop(user_prefs, 'marmoEXE', text = "Toolbag .exe")116 row = col.row(align=True)117 row.scale_y = 1.5118 row.operator(119 "grab_doc.bake_marmoset",120 text="Bake in Marmoset" if grabDoc.marmoAutoBake else "Open in Marmoset",121 icon="EXPORT"122 ).send_type = 'open'123 row.operator("grab_doc.bake_marmoset", text = "", icon = 'FILE_REFRESH').send_type = 'refresh'124 box = col.box()125 row = box.row()126 row.enabled = not grabDoc.modalState127 row.prop(grabDoc, 'bakerType', text = "Baker")128 row = box.row()129 row.alert = not os.path.exists(bpy.path.abspath(grabDoc.exportPath))130 row.prop(grabDoc, 'exportPath', text = "Export Path")131 row.alert = False132 row.operator("grab_doc.open_folder", text = '', icon = "FOLDER_REDIRECT")133 box.prop(grabDoc, "exportName", text = "Name")134 row = box.row()135 row.prop(grabDoc, "exportResX", text = 'Resolution')136 row.prop(grabDoc, "exportResY", text = '')137 row.prop(grabDoc, 'lockRes', icon_only = True, icon = "LOCKED" if grabDoc.lockRes else "UNLOCKED")138 row = box.row()139 if grabDoc.bakerType == 'Blender':140 row.prop(grabDoc, "imageType")141 else:142 row.prop(grabDoc, "imageType_marmo")143 row.separator(factor = .5)144 145 row2 = row.row()146 if grabDoc.imageType == "OPEN_EXR":147 row2.prop(grabDoc, "colorDepthEXR", expand = True)148 elif grabDoc.imageType != "TARGA" or grabDoc.bakerType == 'Marmoset':149 row2.prop(grabDoc, "colorDepth", expand = True)150 else:151 row2.enabled = False152 row2.prop(grabDoc, "colorDepthTGA", expand = True)153 if grabDoc.bakerType == 'Blender':154 if grabDoc.imageType != "TARGA":155 image_settings = context.scene.render.image_settings156 row = box.row(align = True)157 if grabDoc.imageType == "PNG":158 row.prop(grabDoc, "imageCompPNG", text = "Compression")159 elif grabDoc.imageType == "OPEN_EXR":160 row.prop(image_settings, "exr_codec", text = "Codec")161 else: # TIFF162 row.prop(image_settings, "tiff_codec", text = "Codec")163 else: # Marmoset164 row = box.row(align = True)165 row.prop(grabDoc, "marmoSamples", text = "Samples", expand = True)166 box = col.box()167 box.use_property_split = False168 col = box.column(align = True)169 col.prop(170 grabDoc,171 "onlyRenderColl",172 text="Use Bake Group",173 icon='CHECKBOX_HLT' if grabDoc.onlyRenderColl else 'CHECKBOX_DEHLT'174 )175 col.prop(176 grabDoc,177 "exportPlane",178 text='Export Plane as FBX',179 icon='CHECKBOX_HLT' if grabDoc.exportPlane else 'CHECKBOX_DEHLT'180 )181 col.prop(182 grabDoc,183 "openFolderOnExport",184 text="Open Folder on Export",185 icon='CHECKBOX_HLT' if grabDoc.openFolderOnExport else 'CHECKBOX_DEHLT'186 )187 if grabDoc.bakerType == 'Marmoset':188 col = box.column(align = True)189 col.prop(grabDoc, 'marmoAutoBake', text='Bake on Import', icon='CHECKBOX_HLT' if grabDoc.marmoAutoBake else 'CHECKBOX_DEHLT')190 col = col.column(align = True)191 col.enabled = True if grabDoc.marmoAutoBake else False192 col.prop(193 grabDoc,194 'marmoClosePostBake',195 text='Close Toolbag after Baking',196 icon='CHECKBOX_HLT' if grabDoc.marmoClosePostBake else 'CHECKBOX_DEHLT'197 )198class GRABDOC_PT_view_edit_maps(PanelInfo, Panel):199 bl_label = 'Preview / Edit Maps'200 bl_parent_id = "GRABDOC_PT_grabdoc"201 202 @classmethod203 def poll(cls, context):204 return proper_scene_setup()205 def draw_header_preset(self, context):206 self.layout.operator("grab_doc.config_maps", emboss = False, text = "", icon = "SETTINGS")207 def draw(self, context):208 grabDoc = context.scene.grabDoc209 layout = self.layout210 col = layout.column(align = True)211 row = col.row(align = True)212 row.scale_y = 1.25213 in_trim_cam = [area.spaces.active.region_3d.view_perspective for area in context.screen.areas if area.type == 'VIEW_3D'] == ['CAMERA']214 row.operator("grab_doc.view_cam", text = "Leave GrabDoc Camera" if in_trim_cam else "View GrabDoc Camera", icon = "OUTLINER_OB_CAMERA")215 col.prop(grabDoc, 'autoExitCamera', text = "Leave Cam on Preview Exit", icon='CHECKBOX_HLT' if grabDoc.autoExitCamera else 'CHECKBOX_DEHLT')216 if grabDoc.modalState:217 col.separator()218 row = col.row(align = True)219 row.scale_y = 1.5220 row.operator("grab_doc.leave_modal", icon="CANCEL")221 # Special clause for Material ID preview222 if grabDoc.modalPreviewType != 'ID':223 mat_preview_type = grabDoc.modalPreviewType.capitalize()224 else:225 mat_preview_type = "Material ID"226 row = col.row(align = True)227 row.scale_y = 1.1228 row.operator("grab_doc.export_preview", text = f"Export {mat_preview_type}", icon = "EXPORT")229 layout = col.box()230 if grabDoc.modalPreviewType == 'normals':231 normals_ui(layout, context)232 elif grabDoc.modalPreviewType == 'curvature':233 curvature_ui(layout, context)234 elif grabDoc.modalPreviewType == 'occlusion':235 occlusion_ui(layout, context)236 elif grabDoc.modalPreviewType == 'height':237 height_ui(layout, context)238 elif grabDoc.modalPreviewType == 'alpha':239 alpha_ui(layout, context)240 elif grabDoc.modalPreviewType == 'ID':241 id_ui(layout, context)242 elif grabDoc.modalPreviewType == 'albedo':243 albedo_ui(layout, context)244 elif grabDoc.modalPreviewType == 'roughness':245 roughness_ui(layout, context)246 elif grabDoc.modalPreviewType == 'metalness':247 metalness_ui(layout, context)248class GRABDOC_PT_normals_settings(PanelInfo, Panel):249 bl_label = ''250 bl_parent_id = "GRABDOC_PT_view_edit_maps"251 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}252 @classmethod253 def poll(cls, context):254 return not context.scene.grabDoc.modalState and context.scene.grabDoc.uiVisibilityNormals255 def draw_header(self, context):256 grabDoc = context.scene.grabDoc257 row = self.layout.row(align = True)258 row.separator(factor = .5)259 row.prop(grabDoc, 'exportNormals', text = "")260 row.operator(261 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",262 text = "Normals Preview"263 ).preview_type = 'normals'264 265 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'normals'266 row.separator(factor = 1.3)267 def draw(self, context):268 normals_ui(self.layout, context)269def normals_ui(layout, context):270 grabDoc = context.scene.grabDoc271 layout.use_property_split = True272 layout.use_property_decorate = False273 col = layout.column()274 col.prop(grabDoc, "engineNormals", text = "Engine")275 col = layout.column()276 col.prop(grabDoc, 'flipYNormals', text = "Flip Y (-Y)")277 if grabDoc.bakerType == 'Blender':278 col.separator(factor=.5)279 col.prop(grabDoc, 'useTextureNormals', text = "Texture Normals")280 col.separator(factor=.5)281 col.prop(grabDoc, 'reimportAsMatNormals', text = "Import as Material")282 col.separator(factor=1.5)283 col.prop(284 grabDoc,285 "samplesNormals" if grabDoc.engineNormals == 'blender_eevee' else "samplesCyclesNormals",286 text = 'Samples'287 )288 col.separator(factor=1.5)289 col.prop(grabDoc, 'suffixNormals', text = "Suffix")290class GRABDOC_PT_curvature_settings(PanelInfo, Panel):291 bl_label = ''292 bl_parent_id = "GRABDOC_PT_view_edit_maps"293 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}294 @classmethod295 def poll(cls, context):296 return not context.scene.grabDoc.modalState and context.scene.grabDoc.uiVisibilityCurvature297 def draw_header(self, context):298 grabDoc = context.scene.grabDoc299 row = self.layout.row(align = True)300 row.separator(factor = .5)301 row.prop(grabDoc, 'exportCurvature', text = "")302 303 row.operator(304 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",305 text = "Curvature Preview"306 ).preview_type = 'curvature'307 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'curvature'308 row.separator(factor = 1.3)309 def draw(self, context):310 curvature_ui(self.layout, context)311def curvature_ui(layout, context):312 grabDoc = context.scene.grabDoc313 layout.use_property_split = True314 layout.use_property_decorate = False315 col = layout.column()316 if grabDoc.bakerType == 'Blender':317 col.prop(grabDoc, 'ridgeCurvature', text = "Ridge")318 col.separator(factor=.5)319 col.prop(grabDoc, 'valleyCurvature', text = "Valley")320 col.separator(factor=1.5)321 col.prop(grabDoc, "samplesCurvature", text = "Samples")322 col.separator(factor=.5)323 col.prop(grabDoc, 'contrastCurvature', text = "Contrast")324 else: # Marmoset325 pass326 327 col.separator(factor=1.5)328 col.prop(grabDoc, 'suffixCurvature', text = "Suffix")329class GRABDOC_PT_occlusion_settings(PanelInfo, Panel):330 bl_label = ''331 bl_parent_id = "GRABDOC_PT_view_edit_maps"332 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}333 @classmethod334 def poll(cls, context):335 return not context.scene.grabDoc.modalState and context.scene.grabDoc.uiVisibilityOcclusion336 def draw_header(self, context):337 grabDoc = context.scene.grabDoc338 row = self.layout.row(align = True)339 row.separator(factor = .5)340 row.prop(grabDoc, 'exportOcclusion', text = "")341 row.operator(342 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",343 text = "Occlusion Preview"344 ).preview_type = 'occlusion'345 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'occlusion'346 row.separator(factor = 1.3)347 def draw(self, context):348 occlusion_ui(self.layout, context)349def occlusion_ui(layout, context):350 grabDoc = context.scene.grabDoc351 layout.use_property_split = True352 layout.use_property_decorate = False353 col = layout.column()354 if grabDoc.bakerType == 'Marmoset':355 col.prop(grabDoc, "marmoAORayCount", text = "Ray Count")356 else: # Blender357 col.prop(grabDoc, 'reimportAsMatOcclusion', text = "Import as Material")358 col.separator(factor=.5)359 col.prop(grabDoc, 'gammaOcclusion', text = "Intensity")360 col.separator(factor=.5)361 col.prop(grabDoc, 'distanceOcclusion', text = "Distance")362 col.separator(factor=1.5)363 col.prop(grabDoc, "samplesOcclusion", text = "Samples")364 col.separator(factor=.5)365 col.prop(grabDoc, 'contrastOcclusion', text = "Contrast")366 col.separator(factor=1.5)367 col.prop(grabDoc, 'suffixOcclusion', text = "Suffix")368class GRABDOC_PT_height_settings(PanelInfo, Panel):369 bl_label = ''370 bl_parent_id = "GRABDOC_PT_view_edit_maps"371 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}372 @classmethod373 def poll(cls, context):374 return not context.scene.grabDoc.modalState and context.scene.grabDoc.uiVisibilityHeight375 def draw_header(self, context):376 grabDoc = context.scene.grabDoc377 row = self.layout.row(align = True)378 row.separator(factor = .5)379 row.prop(grabDoc, 'exportHeight', text = "")380 row.operator(381 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",382 text = "Height Preview"383 ).preview_type = 'height'384 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'height'385 row.separator(factor = 1.3)386 def draw(self, context):387 height_ui(self.layout, context)388def height_ui(layout, context):389 grabDoc = context.scene.grabDoc390 layout.use_property_split = True391 layout.use_property_decorate = False392 col = layout.column()393 394 if grabDoc.bakerType == 'Blender':395 col.prop(grabDoc, 'invertMaskHeight', text = "Invert Mask")396 col.separator(factor=.5)397 row = col.row()398 row.prop(grabDoc, "rangeTypeHeight", text = 'Height Mode', expand = True)399 if grabDoc.rangeTypeHeight == 'MANUAL':400 col.separator(factor=.5)401 col.prop(grabDoc, 'guideHeight', text = "0-1 Range")402 if grabDoc.bakerType == 'Blender':403 col.separator(factor=1.5)404 col.prop(grabDoc, "samplesHeight", text = "Samples")405 col.separator(factor=.5)406 col.prop(grabDoc, 'contrastHeight', text = "Contrast")407 408 col.separator(factor=1.5)409 col.prop(grabDoc, 'suffixHeight', text = "Suffix")410class GRABDOC_PT_id_settings(PanelInfo, Panel):411 bl_label = ''412 bl_parent_id = "GRABDOC_PT_view_edit_maps"413 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}414 @classmethod415 def poll(cls, context):416 return not context.scene.grabDoc.modalState and context.scene.grabDoc.uiVisibilityMatID417 def draw_header(self, context):418 grabDoc = context.scene.grabDoc419 row = self.layout.row(align = True)420 row.separator(factor = .5)421 row.prop(grabDoc, 'exportMatID', text = "")422 423 row.operator(424 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",425 text = "Mat ID Preview"426 ).preview_type = 'ID'427 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'ID'428 row.separator(factor = 1.3)429 def draw(self, context):430 id_ui(self.layout, context)431def id_ui(layout, context): 432 grabDoc = context.scene.grabDoc433 layout.use_property_split = True434 layout.use_property_decorate = False435 col = layout.column()436 row = col.row()437 if grabDoc.bakerType == 'Marmoset':438 row.enabled = False439 row.prop(grabDoc, "fakeMethodMatID", text = "ID Method")440 else:441 row.prop(grabDoc, "methodMatID", text = "ID Method")442 if grabDoc.methodMatID == "MATERIAL" or grabDoc.bakerType == 'Marmoset':443 col = layout.column()444 col.separator(factor=.5)445 col.scale_y = 1.1446 col.operator("grab_doc.quick_id_setup")447 row = col.row(align = True)448 row.scale_y = .9449 row.label(text = " Remove:")450 row.operator("grab_doc.quick_remove_random_mats")451 col = layout.column()452 col.separator(factor=.5)453 col.scale_y = 1.1454 col.operator("grab_doc.quick_id_selected")455 row = col.row(align = True)456 row.scale_y = .9457 row.label(text = " Remove:")458 row.operator("grab_doc.quick_remove_manual_mats")459 row.operator("grab_doc.quick_remove_selected_mats")460 if grabDoc.bakerType == 'Blender':461 col.separator(factor=1.5)462 col.prop(grabDoc, "samplesMatID", text = "Samples")463 col.separator(factor=1.5)464 col.prop(grabDoc, 'suffixID', text = "Suffix")465class GRABDOC_PT_alpha_settings(PanelInfo, Panel):466 bl_label = ''467 bl_parent_id = "GRABDOC_PT_view_edit_maps"468 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}469 @classmethod470 def poll(cls, context):471 return not context.scene.grabDoc.modalState and context.scene.grabDoc.uiVisibilityAlpha472 def draw_header(self, context):473 grabDoc = context.scene.grabDoc474 row = self.layout.row(align = True)475 row.separator(factor = .5)476 row.prop(grabDoc, 'exportAlpha', text = "")477 row.operator(478 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",479 text = "Alpha Preview"480 ).preview_type = 'alpha'481 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'alpha'482 row.separator(factor = 1.3)483 def draw(self, context):484 alpha_ui(self.layout, context)485def alpha_ui(layout, context):486 grabDoc = context.scene.grabDoc487 layout.use_property_split = True488 layout.use_property_decorate = False489 col = layout.column()490 491 if grabDoc.bakerType == 'Blender':492 col.prop(grabDoc, 'invertMaskAlpha', text = "Invert Mask")493 col.separator(factor=1.5)494 col.prop(grabDoc, 'samplesAlpha', text = "Samples")495 else: # Marmoset496 pass497 498 col.separator(factor=1.5)499 col.prop(grabDoc, 'suffixAlpha', text = "Suffix")500class GRABDOC_PT_albedo_settings(PanelInfo, Panel):501 bl_label = ''502 bl_parent_id = "GRABDOC_PT_view_edit_maps"503 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}504 @classmethod505 def poll(cls, context):506 grabDoc = context.scene.grabDoc507 return not grabDoc.modalState and grabDoc.uiVisibilityAlbedo and grabDoc.bakerType == 'Blender'508 def draw_header(self, context):509 grabDoc = context.scene.grabDoc510 row = self.layout.row(align = True)511 row.separator(factor = .5)512 row.prop(grabDoc, 'exportAlbedo', text = "")513 row.operator(514 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",515 text = "Albedo Preview"516 ).preview_type = 'albedo'517 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'albedo'518 row.separator(factor = 1.3)519 def draw(self, context):520 albedo_ui(self.layout, context)521def albedo_ui(layout, context):522 grabDoc = context.scene.grabDoc523 layout.use_property_split = True524 layout.use_property_decorate = False525 col = layout.column()526 col.prop(grabDoc, "engineAlbedo", text = "Engine")527 col.separator(factor=1.5)528 col.prop(529 grabDoc,530 "samplesAlbedo" if grabDoc.engineAlbedo == 'blender_eevee' else "samplesCyclesAlbedo",531 text = 'Samples'532 )533 col.separator(factor=1.5)534 col.prop(grabDoc, 'suffixAlbedo', text = "Suffix")535class GRABDOC_PT_roughness_settings(PanelInfo, Panel):536 bl_label = ''537 bl_parent_id = "GRABDOC_PT_view_edit_maps"538 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}539 @classmethod540 def poll(cls, context):541 grabDoc = context.scene.grabDoc542 return not grabDoc.modalState and grabDoc.uiVisibilityRoughness and grabDoc.bakerType == 'Blender'543 def draw_header(self, context):544 grabDoc = context.scene.grabDoc545 row = self.layout.row(align = True)546 row.separator(factor = .5)547 row.prop(grabDoc, 'exportRoughness', text = "")548 row.operator(549 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",550 text = "Roughness Preview"551 ).preview_type = 'roughness'552 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'roughness'553 row.separator(factor = 1.3)554 def draw(self, context):555 roughness_ui(self.layout, context)556def roughness_ui(layout, context):557 grabDoc = context.scene.grabDoc558 layout.use_property_split = True559 layout.use_property_decorate = False560 col = layout.column()561 col = layout.column()562 col.prop(grabDoc, "engineRoughness", text = "Engine")563 col.separator(factor=1.5)564 col.prop(565 grabDoc,566 "samplesRoughness" if grabDoc.engineRoughness == 'blender_eevee' else "samplesCyclesRoughness",567 text = 'Samples'568 )569 col.separator(factor=1.5)570 col.prop(grabDoc, 'suffixRoughness', text = "Suffix")571class GRABDOC_PT_metalness_settings(PanelInfo, Panel):572 bl_label = ''573 bl_parent_id = "GRABDOC_PT_view_edit_maps"574 bl_options = {'HEADER_LAYOUT_EXPAND', 'DEFAULT_CLOSED'}575 @classmethod576 def poll(cls, context):577 grabDoc = context.scene.grabDoc578 return not grabDoc.modalState and grabDoc.uiVisibilityMetalness and grabDoc.bakerType == 'Blender'579 def draw_header(self, context):580 grabDoc = context.scene.grabDoc581 row = self.layout.row(align = True)582 row.separator(factor = .5)583 row.prop(grabDoc, 'exportMetalness', text = "")584 row.operator(585 "grab_doc.preview_warning" if grabDoc.firstBakePreview else "grab_doc.preview_map",586 text = "Metalness Preview"587 ).preview_type = 'metalness'588 row.operator("grab_doc.offline_render", text = "", icon = "RENDER_STILL").render_type = 'metalness'589 row.separator(factor = 1.3)590 def draw(self, context):591 metalness_ui(self.layout, context)592def metalness_ui(layout, context):593 grabDoc = context.scene.grabDoc594 layout.use_property_split = True595 layout.use_property_decorate = False596 col = layout.column()597 col = layout.column()598 col.prop(grabDoc, "engineMetalness", text = "Engine")599 col.separator(factor=1.5)600 col.prop(601 grabDoc,602 "samplesMetalness" if grabDoc.engineMetalness == 'blender_eevee' else "samplesCyclesMetalness",603 text = 'Samples'604 )605 col.separator(factor=1.5)606 col.prop(grabDoc, 'suffixMetalness', text = "Suffix")607################################################################################################################608# REGISTRATION609################################################################################################################610classes = (611 GRABDOC_PT_grabdoc,612 GRABDOC_OT_config_maps,613 GRABDOC_PT_export,614 GRABDOC_PT_view_edit_maps,615 GRABDOC_PT_normals_settings,616 GRABDOC_PT_curvature_settings,617 GRABDOC_PT_occlusion_settings,618 GRABDOC_PT_height_settings,619 GRABDOC_PT_id_settings,620 GRABDOC_PT_alpha_settings,621 GRABDOC_PT_albedo_settings,622 GRABDOC_PT_roughness_settings,623 GRABDOC_PT_metalness_settings624)625def register():626 for cls in classes:627 bpy.utils.register_class(cls)628def unregister():629 for cls in classes:630 bpy.utils.unregister_class(cls)631# ##### BEGIN GPL LICENSE BLOCK #####632#633# This program is free software; you can redistribute it and/or634# modify it under the terms of the GNU General Public License635# as published by the Free Software Foundation; either version 2636# of the License, or (at your option) any later version.637#638# This program is distributed in the hope that it will be useful,639# but WITHOUT ANY WARRANTY; without even the implied warranty of640# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the641# GNU General Public License for more details.642#643# You should have received a copy of the GNU General Public License644# along with this program; if not, write to the Free Software Foundation,645# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.646#...

Full Screen

Full Screen

cnn_finance.py

Source:cnn_finance.py Github

copy

Full Screen

1from enum import Enum2from typing import List3from typing import Dict4from typing import Union5import finnews.news_enum as enums_news6from finnews.parser import NewsParser7class CNNFinance():8 def __init__(self):9 """Initializes the `CNNFinance` client."""10 # Define the URL used to query feeds.11 self.url = 'http://rss.cnn.com/rss/{topic}.rss'12 self.url_buzz = 'http://rss.cnn.com/cnnmoneymorningbuzz'13 # Define the parser client.14 self.news_parser = NewsParser(client='cnn_finance')15 def __repr__(self) -> str:16 """Represents the string representation of the client object.17 Returns:18 ----19 (str): The string representation.20 """21 return "<CNNFinance Connected: True'>"22 def all_stories(self) -> List[Dict]:23 """Used to query topics from the All Stories RSS feed.24 Returns:25 ----26 List[Dict]: A list of news articles organzied in dictionaries.27 Usage:28 ----29 >>> from finnews.client import News30 >>> # Create a new instance of the News Client.31 >>> news_client = News()32 >>> # Grab the CNN Finance News Client.33 >>> cnn_finance = news_client.cnn_finance34 >>> # Grab the All Stories Feed.35 >>> cnn_finance_all_stories = cnn_finance.all_stories()36 """37 # Grab the data.38 data = self.news_parser._make_request(39 url=self.url.format(topic='money_latest')40 )41 return data42 def top_stories(self) -> List[Dict]:43 """Used to query topics from the Top Stories RSS feed.44 Returns:45 ----46 List[Dict]: A list of news articles organzied in dictionaries.47 Usage:48 ----49 >>> from finnews.client import News50 >>> # Create a new instance of the News Client.51 >>> news_client = News()52 >>> # Grab the CNN Finance News Client.53 >>> cnn_finance = news_client.cnn_finance54 >>> # Grab the Top Stories Feed.55 >>> cnn_finance_top_stories = cnn_finance.top_stories()56 """57 # Grab the data.58 data = self.news_parser._make_request(59 url=self.url.format(topic='money_topstories')60 )61 return data62 def most_popular(self) -> List[Dict]:63 """Used to query topics from the Most Popular RSS feed.64 Returns:65 ----66 List[Dict]: A list of news articles organzied in dictionaries.67 Usage:68 ----69 >>> from finnews.client import News70 >>> # Create a new instance of the News Client.71 >>> news_client = News()72 >>> # Grab the CNN Finance News Client.73 >>> cnn_finance = news_client.cnn_finance74 >>> # Grab the Most Popular Feed.75 >>> cnn_finance_most_popular = cnn_finance.most_popular()76 """77 # Grab the data.78 data = self.news_parser._make_request(79 url=self.url.format(topic='money_mostpopular')80 )81 return data82 def companies(self) -> List[Dict]:83 """Used to query topics from the Companies RSS feed.84 Returns:85 ----86 List[Dict]: A list of news articles organzied in dictionaries.87 Usage:88 ----89 >>> from finnews.client import News90 >>> # Create a new instance of the News Client.91 >>> news_client = News()92 >>> # Grab the CNN Finance News Client.93 >>> cnn_finance = news_client.cnn_finance94 >>> # Grab the Companies Feed.95 >>> cnn_finance_companies = cnn_finance.companies()96 """97 # Grab the data.98 data = self.news_parser._make_request(99 url=self.url.format(topic='money_news_companies')100 )101 return data102 def international(self) -> List[Dict]:103 """Used to query topics from the Internationals RSS feed.104 Returns:105 ----106 List[Dict]: A list of news articles organzied in dictionaries.107 Usage:108 ----109 >>> from finnews.client import News110 >>> # Create a new instance of the News Client.111 >>> news_client = News()112 >>> # Grab the CNN Finance News Client.113 >>> cnn_finance = news_client.cnn_finance114 >>> # Grab the Internationals Feed.115 >>> cnn_finance_international = cnn_finance.international()116 """117 # Grab the data.118 data = self.news_parser._make_request(119 url=self.url.format(topic='money_news_international')120 )121 return data122 def economy(self) -> List[Dict]:123 """Used to query topics from the Economy RSS feed.124 Returns:125 ----126 List[Dict]: A list of news articles organzied in dictionaries.127 Usage:128 ----129 >>> from finnews.client import News130 >>> # Create a new instance of the News Client.131 >>> news_client = News()132 >>> # Grab the CNN Finance News Client.133 >>> cnn_finance = news_client.cnn_finance134 >>> # Grab the Economoy Feed.135 >>> cnn_finance_economy = cnn_finance.economy()136 """137 # Grab the data.138 data = self.news_parser._make_request(139 url=self.url.format(topic='money_news_economy')140 )141 return data142 def video_news(self) -> List[Dict]:143 """Used to query topics from the Video News RSS feed.144 Returns:145 ----146 List[Dict]: A list of news articles organzied in dictionaries.147 Usage:148 ----149 >>> from finnews.client import News150 >>> # Create a new instance of the News Client.151 >>> news_client = News()152 >>> # Grab the CNN Finance News Client.153 >>> cnn_finance = news_client.cnn_finance154 >>> # Grab the Video News Feed.155 >>> cnn_finance_video_news = cnn_finance.video_news()156 """157 # Grab the data.158 data = self.news_parser._make_request(159 url=self.url.format(topic='money_video_business')160 )161 return data162 def media(self) -> List[Dict]:163 """Used to query topics from the Media RSS feed.164 Returns:165 ----166 List[Dict]: A list of news articles organzied in dictionaries.167 Usage:168 ----169 >>> from finnews.client import News170 >>> # Create a new instance of the News Client.171 >>> news_client = News()172 >>> # Grab the CNN Finance News Client.173 >>> cnn_finance = news_client.cnn_finance174 >>> # Grab the Media Feed.175 >>> cnn_finance_media = cnn_finance.media()176 """177 # Grab the data.178 data = self.news_parser._make_request(179 url=self.url.format(topic='money_media')180 )181 return data182 def markets(self) -> List[Dict]:183 """Used to query topics from the Markets RSS feed.184 Returns:185 ----186 List[Dict]: A list of news articles organzied in dictionaries.187 Usage:188 ----189 >>> from finnews.client import News190 >>> # Create a new instance of the News Client.191 >>> news_client = News()192 >>> # Grab the CNN Finance News Client.193 >>> cnn_finance = news_client.cnn_finance194 >>> # Grab the Markets Feed.195 >>> cnn_finance_markets = cnn_finance.markets()196 """197 # Grab the data.198 data = self.news_parser._make_request(199 url=self.url.format(topic='money_markets')200 )201 return data202 def morning_buzz(self) -> List[Dict]:203 """Used to query topics from the Morning Buzz RSS feed.204 Returns:205 ----206 List[Dict]: A list of news articles organzied in dictionaries.207 Usage:208 ----209 >>> from finnews.client import News210 >>> # Create a new instance of the News Client.211 >>> news_client = News()212 >>> # Grab the CNN Finance News Client.213 >>> cnn_finance = news_client.cnn_finance214 >>> # Grab the Morning Buzz Feed.215 >>> cnn_finance_morning_buzz = cnn_finance.morning_buzz()216 """217 # Grab the data.218 data = self.news_parser._make_request(219 url=self.url_buzz220 )221 return data222 def techonology(self) -> List[Dict]:223 """Used to query topics from the Technology RSS feed.224 Returns:225 ----226 List[Dict]: A list of news articles organzied in dictionaries.227 Usage:228 ----229 >>> from finnews.client import News230 >>> # Create a new instance of the News Client.231 >>> news_client = News()232 >>> # Grab the CNN Finance News Client.233 >>> cnn_finance = news_client.cnn_finance234 >>> # Grab the Technology Feed.235 >>> cnn_finance_technology = cnn_finance.technology()236 """237 # Grab the data.238 data = self.news_parser._make_request(239 url=self.url.format(topic='money_technology')240 )241 return data242 def personal_finance(self) -> List[Dict]:243 """Used to query topics from the Personal Finance RSS feed.244 Returns:245 ----246 List[Dict]: A list of news articles organzied in dictionaries.247 Usage:248 ----249 >>> from finnews.client import News250 >>> # Create a new instance of the News Client.251 >>> news_client = News()252 >>> # Grab the CNN Finance News Client.253 >>> cnn_finance = news_client.cnn_finance254 >>> # Grab the Personal Finance Feed.255 >>> cnn_finance_personal_finance = cnn_finance.personal_finance()256 """257 # Grab the data.258 data = self.news_parser._make_request(259 url=self.url.format(topic='money_pf')260 )261 return data262 def autos(self) -> List[Dict]:263 """Used to query topics from the Autos RSS feed.264 Returns:265 ----266 List[Dict]: A list of news articles organzied in dictionaries.267 Usage:268 ----269 >>> from finnews.client import News270 >>> # Create a new instance of the News Client.271 >>> news_client = News()272 >>> # Grab the CNN Finance News Client.273 >>> cnn_finance = news_client.cnn_finance274 >>> # Grab the Autos Feed.275 >>> cnn_finance_autos = cnn_finance.autos()276 """277 # Grab the data.278 data = self.news_parser._make_request(279 url=self.url.format(topic='money_autos')280 )281 return data282 def funds(self) -> List[Dict]:283 """Used to query topics from the Funds RSS feed.284 Returns:285 ----286 List[Dict]: A list of news articles organzied in dictionaries.287 Usage:288 ----289 >>> from finnews.client import News290 >>> # Create a new instance of the News Client.291 >>> news_client = News()292 >>> # Grab the CNN Finance News Client.293 >>> cnn_finance = news_client.cnn_finance294 >>> # Grab the Funds Feed.295 >>> cnn_finance_funds = cnn_finance.funds()296 """297 # Grab the data.298 data = self.news_parser._make_request(299 url=self.url.format(topic='money_funds')300 )301 return data302 def colleges(self) -> List[Dict]:303 """Used to query topics from the College RSS feed.304 Returns:305 ----306 List[Dict]: A list of news articles organzied in dictionaries.307 Usage:308 ----309 >>> from finnews.client import News310 >>> # Create a new instance of the News Client.311 >>> news_client = News()312 >>> # Grab the CNN Finance News Client.313 >>> cnn_finance = news_client.cnn_finance314 >>> # Grab the College Feed.315 >>> cnn_finance_colleges = cnn_finance.colleges()316 """317 # Grab the data.318 data = self.news_parser._make_request(319 url=self.url.format(topic='money_pf_college')320 )321 return data322 def insurance(self) -> List[Dict]:323 """Used to query topics from the Insurance RSS feed.324 Returns:325 ----326 List[Dict]: A list of news articles organzied in dictionaries.327 Usage:328 ----329 >>> from finnews.client import News330 >>> # Create a new instance of the News Client.331 >>> news_client = News()332 >>> # Grab the CNN Finance News Client.333 >>> cnn_finance = news_client.cnn_finance334 >>> # Grab the Insurance Feed.335 >>> cnn_finance_insurance = cnn_finance.insurance()336 """337 # Grab the data.338 data = self.news_parser._make_request(339 url=self.url.format(topic='money_pf_insurance')340 )341 return data342 def taxes(self) -> List[Dict]:343 """Used to query topics from the Taxes RSS feed.344 Returns:345 ----346 List[Dict]: A list of news articles organzied in dictionaries.347 Usage:348 ----349 >>> from finnews.client import News350 >>> # Create a new instance of the News Client.351 >>> news_client = News()352 >>> # Grab the CNN Finance News Client.353 >>> cnn_finance = news_client.cnn_finance354 >>> # Grab the Taxes Feed.355 >>> cnn_finance_taxes = cnn_finance.taxes()356 """357 # Grab the data.358 data = self.news_parser._make_request(359 url=self.url.format(topic='money_pf_taxes')360 )361 return data362 def retirement(self) -> List[Dict]:363 """Used to query topics from the Retirement RSS feed.364 Returns:365 ----366 List[Dict]: A list of news articles organzied in dictionaries.367 Usage:368 ----369 >>> from finnews.client import News370 >>> # Create a new instance of the News Client.371 >>> news_client = News()372 >>> # Grab the CNN Finance News Client.373 >>> cnn_finance = news_client.cnn_finance374 >>> # Grab the Retirment Feed.375 >>> cnn_finance_retirement = cnn_finance.retirement()376 """377 # Grab the data.378 data = self.news_parser._make_request(379 url=self.url.format(topic='money_retirement')380 )381 return data382 def lifestyle(self) -> List[Dict]:383 """Used to query topics from the Lifestyle RSS feed.384 Returns:385 ----386 List[Dict]: A list of news articles organzied in dictionaries.387 Usage:388 ----389 >>> from finnews.client import News390 >>> # Create a new instance of the News Client.391 >>> news_client = News()392 >>> # Grab the CNN Finance News Client.393 >>> cnn_finance = news_client.cnn_finance394 >>> # Grab the Lifestyle Feed.395 >>> cnn_finance_lifestyle = cnn_finance.lifestyle()396 """397 # Grab the data.398 data = self.news_parser._make_request(399 url=self.url.format(topic='money_lifestyle')400 )401 return data402 def real_estate(self) -> List[Dict]:403 """Used to query topics from the Real Estate RSS feed.404 Returns:405 ----406 List[Dict]: A list of news articles organzied in dictionaries.407 Usage:408 ----409 >>> from finnews.client import News410 >>> # Create a new instance of the News Client.411 >>> news_client = News()412 >>> # Grab the CNN Finance News Client.413 >>> cnn_finance = news_client.cnn_finance414 >>> # Grab the Real Estate Feed.415 >>> cnn_finance_real_estate = cnn_finance.real_estate()416 """417 # Grab the data.418 data = self.news_parser._make_request(419 url=self.url.format(topic='money_realestate')420 )421 return data422 def luxury(self) -> List[Dict]:423 """Used to query topics from the Luxury RSS feed.424 Returns:425 ----426 List[Dict]: A list of news articles organzied in dictionaries.427 Usage:428 ----429 >>> from finnews.client import News430 >>> # Create a new instance of the News Client.431 >>> news_client = News()432 >>> # Grab the CNN Finance News Client.433 >>> cnn_finance = news_client.cnn_finance434 >>> # Grab the Luxury Feed.435 >>> cnn_finance_luxury = cnn_finance.luxury()436 """437 # Grab the data.438 data = self.news_parser._make_request(439 url=self.url.format(topic='money_luxury')440 )441 return data442 def small_business(self) -> List[Dict]:443 """Used to query topics from the Small Business RSS feed.444 Returns:445 ----446 List[Dict]: A list of news articles organzied in dictionaries.447 Usage:448 ----449 >>> from finnews.client import News450 >>> # Create a new instance of the News Client.451 >>> news_client = News()452 >>> # Grab the CNN Finance News Client.453 >>> cnn_finance = news_client.cnn_finance454 >>> # Grab the Small Business Feed.455 >>> cnn_finance_small_business = cnn_finance.small_business()456 """457 # Grab the data.458 data = self.news_parser._make_request(459 url=self.url.format(topic='money_smbusiness')460 )...

Full Screen

Full Screen

Motion.py

Source:Motion.py Github

copy

Full Screen

...176 while self.getRx():177 continue178 pass179180 def grab(self, switch="ON"):181 if not self.lock:182 self.TX_data_py2(MOTION["GRAB"][switch])183 while self.getRx():184 continue185 pass186187 def check_GRAB(self):188 if not self.lock:189 self.TX_data_py2(MOTION["GRAB"]["DISTANCE"])190 while self.getRx():191 continue192 return self.distance193194195if __name__ == '__main__':196 temp = Motion()197 x = temp.check_GRAB()198 print("거리: ", x)199 print("거리+10: ", x + 10)200 pass201202 '''def move(self, grab=None, grab_direction=MOTION["DIR"]["LEFT_GRAB"], scope=MOTION["SCOPE"]["NORMAL"],203 direct=MOTION["DIR"]["LEFT"], repeat=1):204 if not self.lock:205 if grab is None:206 for _ in range(repeat):207 self.TX_data_py2(MOTION["MODE"]["MOVE"] + direct + scope)208 elif grab is "GRAB":209 for _ in range(repeat):210 self.TX_data_py2(MOTION["MODE"]["MOVE"] + grab_direction + scope)211 while self.getRx():212 continue213 pass214215 def turn(self, grab=None, grab_direction=MOTION["GRAB_TURN"]["LEFT"], direct=MOTION["DIR"]["LEFT"], repeat=1):216 if not self.lock:217 if grab is None:218 for _ in range(repeat):219 self.TX_data_py2(direct + MOTION["MODE"]["TURN"])220 elif grab is "GRAB":221 for _ in range(repeat):222 self.TX_data_py2(grab_direction + MOTION["MODE"]["TURN"])223 while self.getRx():224 continue225 pass226227 def grab(self):228 if not self.lock:229 self.TX_data_py2(MOTION["GRAB"])230 while self.getRx():231 continue232 pass233234 def grab_off(self):235 if not self.lock:236 self.TX_data_py2(MOTION["GRAB_OFF"])237 while self.getRx():238 continue239 pass240241 def check_GRAB(self):242 if not self.lock:243 self.TX_data_py2(MOTION["GRAB_DISTANCE"])244 while self.getRx():245 continue246 return self.distance247248249# Tx를 보낸 후 응답을 받을 때 까지 Lock을 걸기 반대쪽에서 보낸 Rx가 유실 될 수도 있으니, 일정시간이 지나도 답이 안오면 재요청250251252if __name__ == '__main__':253 temp = Motion()254 temp.grab()255 x = temp.check_GRAB()256 print("distance: ", x)257 print("distance + 10:", x + 10)258 # i = 5259 # while i > 0:260 # print(i)261 # temp.walk(speed=MOTION["SPEED"]["FAST"])262 # #temp.TX_data_py2(1)263 # i -= 1 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Pyscreenshot automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful