macOS vs Windows: Launching Multiple App Instances

Background: I’m a Windows user. I now use a Mac for work. I’m going to document the differences as I run into them.

First up: launching multiple instances of an app.

I was doing 3d modeling work in Blender on macOS. I have a CAD model of a vehicle (model A). I used Blender to reduce the complexity of the model (model B). Now that I’m done with model B, I want to compare model A to model B.

I have model B loaded in Blender. Now I want to load model A in a second instance of Blender. How do you do that?

Windows

There are several ways I can think of to do this on Windows

  1. Right-click the Blender icon in the taskbar and select “Blender”
  2. Middle-click the Blender icon
  3. Click “Start” and select Blender
  4. Click “Search” and type “Blender” [Enter]

macOS

I tried right-clicking the Blender icon in the Dock and selecting Blender, but it just brings up the existing Blender.

I tried middle-clicking, and playing around with modifier keys. Nothing worked.

I searched the internet and found a post that said it was possible to launch a second copy of an app…but you had to do it from the command line.

Preview Release of DDD

I now have DDD in a demo-able state, and you can try it out too.

What is DDD?

Cross-platform (Windows, Linux, Mac) 3D tools for PowerShell

That is an odd tagline, because PowerShell is known for automating IT tasks. It has nothing to do with computer graphics.

DDD is a PowerShell module. It adds commands to PowerShell to make working with 3D graphics easy.

For more info on what DDD is, see my kickoff post: http://www.davidlenihan.com/2020/04/17/introducing-ddd/

DDD Commands

The commands available in this release:

  • New-Point
  • New-PointArray
  • New-Vector
  • New-VectorArray
  • New-Matrix
  • New-MatrixArray
  • New-IdentityMatrix
  • New-ZeroMatrix
  • New-RotateXMatrix
  • New-RotateYMatrix
  • New-RotateZMatrix
  • New-ScaleMatrix
  • New-TranslateMatrixXYZ
  • New-TranslateMatrixVector
  • Get-CrossProduct
  • Get-DotProduct
  • Out-3d

These commands allow you to create points, vectors, and matrices. You can manipulate points and vectors by multiplying them by matrices. You can view the primitives in 3D by piping (‘|’) the output to the command ‘Out-3d.’

Simple DDD example

Here is a simple example. Create a point at 1, 1, 1 and display it in 3D.

New-Point 1 1 1 | Out-3d

In the 3D view, you can rotate with the mouse, keyboard (WASD or arrow keys), or touch gestures. Press Esc to exit.

Installation

DDD has a single requirement: PowerShell 7 or higher. In the near future, PowerShell 7 will be built into Windows 10. For now, you have to add it to your system.

NOTE: Even though DDD will work on any platform supported by PowerShell 7, I have not yet created a version of Out-3d that works on Mac or Linux. I plan on working on that next.

Demos

Once you have PowerShell 7 installed, you can copy and paste these demos into the PowerShell 7 console to run the scripts. You can modify these scripts and see what results you get. If you come up with your own creation, please share it with me via me@davidlenihan.com.

Coil

# create a coil
Install-Module DDD -Repository PSGallery
Import-Module DDD
0..3600 | ForEach-Object {
    $deg = $_ 
    $rad = $deg*[Math]::PI/180 
    $x = [Math]::Sin($rad)*360
    $y = $deg
    $z = [Math]::Cos($rad)*360
    New-Point $x $y $z
} | Out-3d

Sphere

# create a sphere
Install-Module DDD -Repository PSGallery
Import-Module DDD
$allPoints = @() # empty array
for($degY = 0; $degY -lt 360; $degY += 10) {
    for($degZ = 0; $degZ -lt 360; $degZ += 10) {
        $x = 1
        $y = 0
        $z = 0
        $pt = New-Point $x $y $z
        $rotZ = New-RotateZMatrix $degZ
        $rotY = New-RotateYMatrix $degY
        $allPoints += $rotZ * $rotY * $pt
    } 
} 
$allPoints | Out-3d

Teapot

The last demo is of a the iconic Utah teapot. This simple script is doing quite a bit…

  • Download an .obj file that represents a teapot
  • Convert the file in memory to an array of lines at the line breaks
  • Use a regular expression to find all the vertices
  • Create points using DDD’s New-Point
  • Visualize points using DDD’s Out-3d
# load a teapot in OBJ file format
Install-Module DDD -Repository PSGallery
Import-Module DDD

$url = "https://graphics.cs.utah.edu/courses/cs6620/fall2019/prj05/teapot.obj"
$obj = (Invoke-WebRequest $url).ToString()
$windowsLineEnding = "`r`n"
$lines = $obj -split $windowsLineEnding

# regular expression to match a vertex: "v <X_FLOAT> <Y_FLOAT> <Z_FLOAT>"
$geometricVertex = '^v'  # https://en.wikipedia.org/wiki/Wavefront_.obj_file#Geometric_vertex
$whitespace = '\s+'
$float = '[\d\.\-]+'
$restOfLine = '.*$'
# use "Named Captures" to get x, y, and z: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7#named-captures
$vertRegex = "$geometricVertex$whitespace(?<x>$float)$whitespace(?<y>$float)$whitespace(?<z>$float)$restOfLine"

# parse .obj and output verts
$teapot = $lines | ForEach-Object {
    if ($_ -match $vertRegex) {New-Point $Matches.x $Matches.y $Matches.z}
} 
$teapot | Out-3d

What’s Next?

I proved to myself that I could make PowerShell a great environment for quickly working with 3D graphics. Here are some of the things I plan on doing…

Source Code

The source code for building DDD is available here: https://github.com/lenihan/DDD

Feedback

Let me know what you think. I want this to be a solid product, so if you have any problems, please let me know. Post in the comments or send me an email: me@davidlenihan.com.

11/12/2020 Updates

  • Added “-Repository PSGallery” to Install-Module in examples. Without this, examples will fail for users that already have a default repository setup that is not PSGallery. Thanks Craig!
  • Updated PowerShell installation instructions for Windows 10 to use Microsoft Store

Escape From New York

I loved Escape from New York as a kid. It was the first R-rated movie I ever saw. I own it on Blu-ray and decided to re-watch it.

The opening sequence describes the situation with an uncredited narration by Jamie Lee Curtis…

In 1988 the crime rate in the United States rises 400%. The once great city of New York becomes the one maximum security prison for the entire country. A 50-foot containment wall is erected along the New Jersey shoreline across the Harlem River and down along the Brooklyn shoreline. It completely surrounds Manhattan Island. All bridges and waterways are mined. The United States police force, like an army, is encamped around the island. There are no guards inside the prison, only prisoners and the worlds they have made. The rules are simple: once you go in, you don’t come out.

It doesn’t sound so far fetched anymore: create a place for people that do not want police.

I love John Carpenter’s synth soundtrack. Opening track here.

I did not know there was an alternate opening to the movie. This opening shows Snake getting busted for robbing the Bank of the United States…the crime that sent him to New York Maximum Security Prison. You can see that they have created “USART,” a subway that covers all of the USA (looks like it is the BART station in Berkeley to me). I like the original opening better with the focus on New York as a prison.

I watched the credits and noticed something new to me: James Cameron (Terminator, Aliens, Titanic) is listed as doing special effects and matte artwork.

Highly recommended.

Mini Reviews: Ozark season 2,3, Dead To Me season 2, The Wrong Missy

Ozark Season 2 and Season 3 (Netflix)

I loved this show. It is really well done. Season three really got to me. Highly recommended. I put it up there with Breaking Bad as one of the greatest TV series of all time.

Dead to Me Season 2 (Netflix)

I really liked the first season. Season 2 was not as good, but still worth watching. The characters (Christina Applegate and Linda Cartdellini) are still fun to watch.

The Wrong Missy (Netflix)

This movie is dumb. But I have to admit I laughed out loud several times. Looking at the trailer, I thought Lauren Lapkus was trying too hard. After watching the movie, I thought she was hilarious. She makes this movie work.

It’s Alive!

My old blog covers January 2003 to January 2013. I accidently overwrote it when I started this blog.

I brought it back to life. You can now access it here:

http://oldblog.davidlenihan.com/

How I Fixed It

  1. I used WinSCP to download my old blog to my computer.
  2. I ran this PowerShell script to update all the links to the new location (/ORIGINAL_davidlenihan.com)
    ls *.html,*.xml -r -files | %{(gc $_ -Raw) -replace 'davidlenihan\.com','davidlenihan.com/ORIGINAL_davidlenihan.com' | Set-Content $_}
  3. I used Adobe Media Encoder to convert all .wmv, . mov, and .mpg to .mp4 that can play in modern browsers.
  4. I ran this PowerShell script to change all references to videos to .mp4
    ls *.html -file -r | %{(gc $_ -Raw) -replace '(?<url>\"http://(www\.|)davidlenihan\.com/[^ ]*)\.(wmv|mov|mpg)\"', '${url}.mp4"' | Set-Content $_}
  5. I used WinSCP to upload the updated blog contents to the new location on the web server
  6. I created a subdomain (http://oldblog.davidlenihan.com) that points to the actual location (http://www.davidlenihan.com/ORIGINAL_davidlenihan.com) for easier access
  7. I placed a link to the old blog on the bottom right side under “Links”

Let me know if you find any issues.

My Family’s Home Pages

Editor’s note:

This blog post was originally posted April 9, 2006. My old Moveable Type blog has been replaced with a new WordPress blog. In updating to the new blog, all my old posts ‘went away.’ I will periodically bring back some of them so they can live again. I had to update this post because many of the links no longer work and the JavaScript code did not work correctly with Chrome.

David


For Christmas 2000, I thought it would be a nice gift to give my family their own domains. I wanted my family to actually set up their own home pages, but I knew they probably would not. So I decided to give them a little incentive…I setup *very* annoying home pages for each of them based on the internet classic hamster dance.

Here are the original home pages, safely archived on my web site:

Of the original 4 web sites I setup, only my brother has kept his domain, but removed the “bro dance” home page. My Dad, Mom, and Joe let their domains expire and no longer own them.

Banned Video: Plandemic

See the source image

Plandemic is a 24 minute “preview” of an upcoming documentary. Good luck trying to find it. Google, Facebook , YouTube, Vimeo, and Twitter have all decided you should not see the video. The video is gone. The thing you will find instead is lots of websites, articles, and videos telling you why Plandemic is wrong.

Any time someone tells me I cannot watch something….that is what I want to watch.

Here is how you can watch it…

Watch it yourself and form your own opinion.

Thoughts on Microsoft Build 2020

I “attended” the virtual Microsoft Build conference this week. Here is what I found interesting.

MakeCode Arcade

I had no idea anything like this existed. MakeCode Arcade is a website that lets you build old school 8-bit video games using blocks. In the above image, the game is running on a simulator on the left. In the middle is a list blocks you can use to build your game. On the right is where you connect your blocks to create your game.

This is a fantastic way to learn how to program. Blocks include…

  • Sprites (graphics)
  • Controller (input)
  • Game (game loop)
  • Music (audio)
  • Scene (background)
  • Info (score, player lives, timers)
  • Loops (for, for each, while)
  • Logic (if/then/else, comparisons, Boolean)
  • Variables
  • Math (basic math, random numbers, clamping, rounding)
  • Images
  • Functions
  • Arrays
  • Text (string operations)
  • Console (log file)

Here is the part that puts it over the top… Once you have your game ready, you can download it to standalone hardware and play your game without a computer.

The example above is called “Meowbit” and it goes for $40. There are other options listed under hardware on this page.

I know this is for kids, but I’d love to spend some time playing with this.

More here.

The Windows Package Manager: winget

Windows now has a package manager called “winget.” This means you can easily setup a box to have all the apps you want by running a script. Eventually winget will be part of Windows. You can try it out now from here: https://github.com/microsoft/winget-cli/releases

Not all the apps I want are there yet, but many are. They are adding more apps quickly.

Here is the current list of supported apps as of today (5/21/2020):

I created my own PowerShell script to setup a PC…

#Requires -RunAsAdministrator

# Install winget https://github.com/microsoft/winget-cli/releases
# In same order as 'winget search', using Id
winget install --exact --silent Canonical.Ubuntu
winget install --exact --silent EpicGames.EpicGamesLauncher
winget install --exact --silent Git.Git
winget install --exact --silent GitHub.GitLFS
winget install --exact --silent GitHub.cli
winget install --exact --silent Kitware.CMake
winget install --exact --silent Microsoft.Edge
winget install --exact --silent Microsoft.GitCredentialManagerforWindows
winget install --exact --silent Microsoft.PowerToys
winget install --exact --silent Microsoft.Powershell
winget install --exact --silent Microsoft.Skype
winget install --exact --silent Microsoft.Teams
winget install --exact --silent Microsoft.VisualStudio.Community
winget install --exact --silent Microsoft.VisualStudioCode
winget install --exact --silent Microsoft.WindowsSDK
winget install --exact --silent Microsoft.WindowsTerminal
winget install --exact --silent Microsoft.dotNetFramework
winget install --exact --silent Microsoft.dotnet
winget install --exact --silent Python.Python
winget install --exact --silent ScooterSoftware.BeyondCompare4
winget install --exact --silent SimonTatham.Putty
winget install --exact --silent Spotify.Spotify
winget install --exact --silent Valve.Steam
winget install --exact --silent WinSCP.WinSCP
winget install --exact --silent Zoom.Zoom

GitHub for iOS and Android

Now you can review pull requests on your phone. More here.

Windows Subsystem for Linux 2 supports GUI apps, GPU’s

You will be able to run Linux GUI apps side by side with Windows apps. Linux apps that require a GPU/CUDA will be supported with WSL2. More here.

WebView2

WebView2 is a new UI control that contains a chromium browser with support for WebGL2 that works on all supported versions of Windows. More here.

C# 9

One new feature in version 9 is you can write a simple app with less code. Here is how you code “hello world” now…

Same app in C# 9…

More here.

Codespaces

The idea behind Codespaces is great: one click on the upcoming “Codespaces” button in a GitHub repo and get a VS Code editor running in a browser with everything configured and ready to go for development and debugging. The Codespace VM can also run in Visual Studio 2019 or VS Code.

More here.

Microsoft Edge now on Linux

The new Microsoft Edge browser was shown running on Linux.

More here.

Windows Virtual Desktop

Windows Virtual Desktop (WVD) lets you package up an app and run it with the OS and hardware it needs in the cloud. Users can access it on their desktop as if it was locally installed. It can be used for running 3d apps like Maya, 3ds Max on underpowered machines.

More here.

WinUI 3

WinUI 3 is the latest/greatest UI toolkit for Windows. What is new is that it is decoupled from the OS so that you can use the latest UI controls with older OS’s. Also new, is this toolkit can be used by UWP, WPF, Windows Forms, and MFC. The idea is every Windows app should be able to access the latest UI components.

More here.

.NET MAUI

.NET MAUI (Multi-platform App UI) is Microsoft’s solution for cross platform UI development. This is going to replace Xamarin.Forms. Microsoft will support macOS, Windows, Android, and iOS. The “community” is supporting Linux as they have for Xamarin.Forms.

More here.

Fluid vs Fluent

I was confused. I knew “Fluent” was Microsoft’s UI design language. When I heard about “Fluid,” I thought it was the same thing because it is about UI and it is a similar word.

It isn’t the same thing. Fluid is about making web apps that support collaboration. Microsoft will use it in Office (Word, Excel, PowerPoint, etc.). It is open source.

More here.

Blazer

Blazer let’s you script web pages with C# instead of JavaScript via WebAssembly.

More here.

Access Windows API via Rust language

Rust is now a supported language for building system software (ie building OS’s). It is considered a safer language to use than C or C++, yet still has speed and predictable performance.

More here.

Windows Terminal 1.0

The 1.0 version of Windows Terminal was released. There is a lot to like. It is missing one feature that I use all the time: using Ctrl+Space in PowerShell to see parameters and the options for parameters. There is a bug report for this and it sounds like it is not a quick fix, so I may be waiting for a while before I switch to Windows Terminal.

More here.