Sometimes you just need to ease back into work after a few weeks off. So today I decided to have a go at integrating DogeSharp – a programming language on top of of .NET inspired by Dogescript – into AutoCAD. There was absolutely no reason to do so, other than to cause myself some amusement. Which is actually a pretty good reason, now that I think about it.
For those of you who – like me – are almost completely unaware of Internet memes such as Doge, this was apparently a big one in 2013 and all started with this blog post. Although as the meme has since grown big enough for advertisers and politicians to jump on the bandwagon, at this point it seems to be well past its prime.
But programmers don’t necessarily care about such mundane things as external validation. And we often look at things on a different timescale. Code can end up having a surprising lifespan – it can be used once and then disappear or it can stay around forever – and as we all know this sadly isn’t necessarily based on its quality. Who knows what tomorrow will bring… why not write code in a language that causes you and the people around you some entertainment? (I’m not actually advocating this, of course… apart from anything else, the ADN team won’t thank me if they end up having to provide support for Doge[script|Sharp]. :-)
The Dogescript and DogeSharp languages make use of the usual Dogesque words: so, such, much, many, very, wow, amaze, plz, etc. Here’s some code I ended up getting working to builds a functional AutoCAD command (I saved this code in a file named AutoCAD.ds):
[such CommandMethod many "DOGE"]
very TestCommand so void much static much public
such doc Application.DocumentManager.MdiActiveDocument
such ed doc.Editor
such num plz NumFunc;
plz ed.WriteMessage many "wow – such amaze ... ";
plz ed.WriteMessage many plz num.ToString;
very NumFunc so long much static
such rand gimme Random;
such num plz rand.Next;
I did have to work around one minor quirk: I ended up making multiple calls to WriteMessage() as the formatting string didn’t get passed through as expected. No big deal, though.
I did have to make a minor change to the DogeSharp code to allow classes to be public and so visible to AutoCAD, but I’m told this will be fixed soon . This has now been fixed. Thanks, Ruan!)
Here are the command-line arguments I added to the DogeSharp samples’ build.bat to build the desired AutoCAD-DS.dll (after copying AcMgd.dll, AcDbMgd.dll and AcCoreMgd.dll from the ObjectARX SDK’s inc folder into DogeSharp’s Samples\Libs folder):
echo Building AutoCAD sample
%dsc% AutoCAD.ds /target:library /out:AutoCAD-DS.dll /reference:Libs\AcDbMgd.dll /reference:Libs\AcCoreMgd.dll
/reference:Libs\AcMgd.dll /reference:System.dll /preservetranslated
The %dsc% system variable resolves to the dsc.exe executable built by the DogeSharp project… the DSC tool isn’t truly integrated into the VS project environment, but as build.bat gets executed as a post-build step (or rather a pre-build step on the chained Samples project), everything gets launched from within Visual Studio.
I mean to say, what’s not to like about a command-line tool that populates the VS output with such cool ASCII art? :-)
1> Building AutoCAD sample
1> ▄ ▄
1> ▌▒█ ▄▀▒▌
1> ▌▒▒█ ▄▀▒▒▒▐
1> many D#
1> very c Ruan Pearce-Authers
1> much programming
1> such language
1> very translating...
1> much translation: AutoCAD.ds
1> so forwarding: /target:library
1> very references: Libs\AcDbMgd.dll, Libs\AcCoreMgd.dll, Libs\AcMgd.dll, System.dll
1> such translated, wow
1> many compiling...
1> such compiled, wow
1> many time, such elapsed, so milliseconds: 451
1> many success: AutoCAD-DS.dll
1> Samples -> Z:\GitHub\DogeSharp\Samples\bin\Debug\Samples.dll
When NETLOADed into AutoCAD, AutoCAD-DS.dll defines the DOGE command that prints a message and a random number:
wow - such amaze . . .1391841392
If you do end up messing around with DogeSharp, please do pass on any feedback/suggestions to the author, Ruan Pearce-Authers.