User:Alessia/coding+3d

From XPUB & Lens-Based wiki
< User:Alessia
Revision as of 00:24, 28 December 2023 by Alessia (talk | contribs)

Python


https://runestone.academy/ns/books/published/thinkcspy/index.html

Python ASCII


https://pypi.org/project/keyboard/

Blender Python scripting


Python API documentation: https://docs.blender.org/api/current/

A set of rules and tools to let software applications communicate with each other, it defines the methods that apps use to exchange data.
API Application Programming Interface
https://www.youtube.com/watch?v=ByGJQzlzxQg&ab_channel=AaronJack
UI to the user, API for the code. Log in —- UI —- Front End —- API —- Back End
++++Enable Developer Extra and Python Tooltips!++++
The Python Console has autocompletion

The Blender Python API can’t create Blender data that exists outside the main Blender database (accessed through bpy.data)
bpy (Blender Python), there are some specific modules in Blender that may not be found in standard Python

Cheat Sheet
https://docs.blender.org/manual/en/dev/advanced/operators.html#bpy-ops-wm-operator-cheat-sheet


Shell scripting languages

powershell

https://learn.microsoft.com/en-us/training/modules/introduction-to-powershell/

Cmdlets:(pronounced commandlets) commands to perform tasks and operations. Building blocks for Powershell scripts and commands.

Get-Command

To filter the list, keep in mind the verb-noun naming standard for cmdlets. For example, in the Get-Random command, Get is the verb and Random is the noun. Use flags to target either the verb or the noun in the command you want. The flag you specify expects a value that's a string. You can add pattern-matching characters to that string to ensure you express that, for example, a flag's value should start or end with a certain string.

Get-Location / pwd 


Set-Location oppure cd (change directory)
dir / Get-ChildItem per vedere file in directory

(=ls)

Cd .. torna indietro di uno
Cls clear (doesn't affect the command history)

Open a text file with the default associated editor

Start-Process -FilePath "C:\Path\To\Your\Filename.extension"

To open the file with a specific application use the Verb parameter
“Edit” open the file with the default editor

Start-Process -FilePath "C:\Path\To\Your\Filename.extension" -Verb "Edit"

To open the file with a different application (example with visual studio code, “code” is the command to launch vscode)

Start-Process "code" -ArgumentList "C:\Path\To\Your\Filename.extension"

version of powershell

$PSVersionTable



automatic variables: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.4



newrocker.png 【┘】



To set the timer duration (seconds)

$timerDuration = 30

to ask the user for the timer duration tho (second choice)

do {
    $timerInput = Read-Host "Enter timer duration in seconds"
} while (-not [System.Int32]::TryParse($timerInput, [ref]$timerDuration) -or $timerDuration -lt 0)

Display then a message when the timer starts

Write-Host "Timer running for $timerDuration seconds..."

Start the countdown. $i, i for index, the loop counter. -gt is to compare 2 numbers, comparison operator (greater than, it returns true or false). Start-Sleep for the delay to get the countdown effect. -NoNewline to not print different lines but just one- "r" escape sequence, carriage return character, to clear the current line in the console.

  for ($i = $timerDuration; $i -gt 0; $i--) {
    Write-Host -NoNewline "Time remaining: $i seconds... "
    Start-Sleep -Seconds 1
    Write-Host -NoNewline "`r"
}

Display a message when the timer has finished

Write-Host "The end!"

sound notification

[console]::beep()

oppure

[system.media.systemsounds]::beep.play()