I needed a pipe flange with a square base, so I designed one. Glue a piece of plastic pipe into it and mount it to something else.
The design is parametric and can be adjusted to match individual requirements.
Note: This is not OpenSCAD. It's a program written in Go. The main library and code examples can be found here:
About Go: https://golang.org/