Skip to content

Instantly share code, notes, and snippets.

@moloneymb
moloneymb / Utilities.SerDes.XML.fsx
Created April 12, 2023 18:22
Utilities/Utilities.SerDes.XML.fsx
module Utilities.SerDes.XML
// Licence: Apache 2.0
// Author: Matthew Moloney
open System.Reflection
open Microsoft.FSharp.Reflection
open System
open System.Text
open System.IO
open System.Net
@moloneymb
moloneymb / Utilities.SerDes.JS.fsx
Created April 12, 2023 18:17
Utilities/Utilities.SerDes.JS.fsx
module Utilities.SerDes.JS
// Licence: Apache 2.0
// Author: Matthew Moloney
// TODO - maybe use https://github.com/Tarmil/FSharp.SystemTextJson
open System
open System.Text
open System.IO
open System.Net
@moloneymb
moloneymb / Utilities.SerDes.Bin.fsx
Created April 12, 2023 18:16
Utilities/Utilities.SerDes.Bin.fsx
module Utilities.SerDes.Bin
// Licence: Apache 2.0
// Author Matthew Moloney
open System.Reflection
open Microsoft.FSharp.Reflection
open System
open System.Text
open System.IO
open System.Net
open System.Net.Sockets
module Clippy
// MIT License
open System
open System.Runtime.InteropServices
open System.Text
module Native =
[<DllImport("kernel32.dll")>]
extern IntPtr GlobalAlloc(uint64 uFlags, UIntPtr dwBytes);
module TensorFlow.FSharp.HDF5ReaderWriter
// Originally from https://github.com/DeepMLNet/DeepNet/blob/master/Tensor/Tensor/HDF5.fs
// Apache 2.0 licence
// NOTE: invalidOpf may be useful to get rid of the need of the backpipe and sprintf
// NOTE: perhaps re-introduce record support
// WARN: There appears to be issues running on Ubuntu 18.04
// It is recommended to avoid H5 where possible
module TensorFlow.FSharp.ImageWriter
// This is a lightweight library for saving bitmap files in order to view the output of image base machine learning
// The point of this is is have minimal dependencies for examples
// This should probably be replaced with built in tensorflow operations
// There seems to be some issues with the generated PNG files where is some applications they show up as empty
#nowarn "9"
open System
  1. Download the Mantis zip file from https://dl.dropboxusercontent.com/u/157820459/Mantis.zip
  2. Unblock the Mantis zip file before extraction http://blogs.msdn.com/b/delay/p/unblockingdownloadedfile.aspx
  3. Extract the folder where ever you'd like
  4. Update the Mantis.addin file to replace the AddIn Assembly location to point to Tsunami.IDEDesktop.dll in the extracted folder
  5. Copy the Mantis.addin file to "C:\ProgramData\Autodesk\Revit\Addins\2016\Mantis.addin"
  6. Run Revit, open file, and start Mantis from the Add-Ins Ribbon
  7. To test copy the F# code from https://gist.github.com/moloneymb/4561a548a3378bc2775f into the shell. Select all text and run selected (Run button or Alt+Enter). Once the code has run a new shape should appear in 3D Views -> CSGTree
  8. For help or more advanced functionality please feel free to reach out to me at moloneymb (twitter, gmail or skype)
// Based on the SDK Sampl GeometryCreation_BooleanOperations
// This is testing code. Many improvements can be made before use in real work
#r @"C:\Program Files\Autodesk\Revit 2016\RevitAPI.dll"
#r @"C:\Program Files\Autodesk\Revit 2016\RevitDBAPI.dll"
#r @"C:\Program Files\Autodesk\Revit 2016\RevitAPIUI.dll"
#r @"C:\Program Files\Mantis\Tsunami.IDEDesktop.dll"
open Autodesk.Revit
open Autodesk.Revit.UI
namespace Tsunami.Server
open System
open System.IO
open System.Linq
open System.Net
open System.Net.Sockets
open System.Text
open System.Threading
open System.Runtime.Serialization
/**
* See if the element (name|label|id) is greater than the % of the window
*
* @Then /^the element "([^"]*)" should be "([^"]*)" percent or greater than the window$/
*/
public function theElementShouldBePercentOrGreaterThanTheWindow($arg1, $arg2)
{
//1. make sure the target exists
//2. get the height of the target
//3. compare it to the window height