<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7129577880637583040</id><updated>2011-08-02T18:32:45.957-04:00</updated><category term='IronRuby'/><category term='welcome'/><category term='Ruby'/><category term='AutoCAD'/><category term='Rspec'/><title type='text'>There must be an easier way!</title><subtitle type='html'>Ideas, experiences, rantings, ravings and general hysteria from a Ruby noob</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-2452626790265921945</id><published>2009-11-21T15:14:00.002-05:00</published><updated>2009-11-21T15:14:45.749-05:00</updated><title type='text'>Moving my blog</title><content type='html'>I had decided to move my blog to &lt;a href="http://davidkblackmon.com/"&gt;davidkblackmon.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This blog will stay up for a while, but all new post will be on the new site.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-2452626790265921945?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/2452626790265921945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/11/moving-my-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/2452626790265921945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/2452626790265921945'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/11/moving-my-blog.html' title='Moving my blog'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-2802649671403452281</id><published>2009-11-10T12:45:00.000-05:00</published><updated>2009-11-10T12:45:09.740-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AutoCAD'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='IronRuby'/><title type='text'>TIRADE (The IronRuby Autocad Development Environment)</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;b&gt;Here is a sneak-peek at TIRADE (&lt;/b&gt;don't get me started)&lt;b&gt; &lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_ybitcanW8FQ/Svmi_UKSR8I/AAAAAAAAAA8/7BuTGfoeDo0/s1600-h/tirade.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_ybitcanW8FQ/Svmi_UKSR8I/AAAAAAAAAA8/7BuTGfoeDo0/s320/tirade.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TIRADE stands for The IronRuby Autocad Development Environment.&lt;br /&gt;&lt;br /&gt;TIRADE extends my work on &lt;a href="http://github.com/davidbl/acadhelper"&gt;acadhelper&lt;/a&gt; and allows instant (or at least very rapid) gratification and enjoyment of Ruby goodness when extending AutoCAD with IronRuby.&lt;br /&gt;&lt;br /&gt;TIRADE runs modelessly, integrates RSpec and Test::Unit testing directly (slowly, but directly), has syntax highlighting and will soon have (hopeably) code completion for the acadhelper wrappers and methods.&lt;br /&gt;&lt;br /&gt;I used the &lt;a href="http://www.icsharpcode.net/OpenSource/SD/"&gt;ICSharpCode TextEditor&lt;/a&gt; control (with some local modifications) as the editor control and used the open source &lt;a href="http://sourceforge.net/projects/dockpanelsuite/"&gt;DockPanel Suite&lt;/a&gt; that very closely matches the Visual Studio docking that we all know and love.&lt;br /&gt;&lt;br /&gt;After a bit more testing, I hope to release TIRADE on the world.&amp;nbsp; Stay tuned&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-2802649671403452281?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/2802649671403452281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/11/tirade-ironruby-autocad-development.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/2802649671403452281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/2802649671403452281'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/11/tirade-ironruby-autocad-development.html' title='TIRADE (The IronRuby Autocad Development Environment)'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_ybitcanW8FQ/Svmi_UKSR8I/AAAAAAAAAA8/7BuTGfoeDo0/s72-c/tirade.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-3086548814224306768</id><published>2009-10-28T14:09:00.000-04:00</published><updated>2009-10-28T14:59:13.780-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AutoCAD'/><category scheme='http://www.blogger.com/atom/ns#' term='IronRuby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rspec'/><title type='text'>Testing using IronRuby and Rspec in a Hosted Environment</title><content type='html'>Using IronRuby, I have been working on some &lt;a href="http://github.com/davidbl/IronRuby-Autocad-Helper"&gt;helpers and wrappers so I can use Ruby as a development language for AutoCAD&lt;/a&gt;.  Things are going well with the project, but I needed some way to run Rspec tests.  Since IronRuby is running in-process with AutoCAD, I could not just type&lt;br /&gt;&lt;pre&gt; &lt;code&gt;&lt;br /&gt;spec path/to/spec_file.rb -c -f nested&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;like one would when testing pure Ruby code.  What I needed was a way to pass that command line string to an IronRuby engine that was running in the AutoCAD process.  After a bit of digging and a bit of testing,  I found that if I had a Ruby file consisting of&lt;br /&gt;&lt;br /&gt;&lt;pre&gt; &lt;code&gt;&lt;br /&gt;require 'rubygems'&lt;br /&gt;$0="c:/ironruby-0.9.0/lib/IronRuby/gems/1.8/bin/spec"&lt;br /&gt;ARGV &amp;lt&amp;lt "acad_spec.rb" &amp;lt&amp;lt "-c" &amp;lt&amp;lt "-f" &amp;lt&amp;lt "nested"&lt;br /&gt;gem 'rspec', "&amp;gt= 0"&lt;br /&gt;load 'spec'&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;I could pass it to ir.exe and get the same result as running spec .... from the command line.&lt;br /&gt;&lt;br /&gt;So I fired up my Visual Studio and came up with &lt;a href="http://gist.github.com/220667"&gt;this&lt;/a&gt;. Right now, the Rspec options are hard-coded, but I plan to allow the tester to enter those options from the AutoCAD command-line.&lt;br /&gt;&lt;br /&gt;When I netload this code into AutoCAD, I can browse to my Rspec file, pick it and run it.  I used the AllocConsole from kernel32 so I could open a command console from AutoCAD and get the colored output that I &lt;a href="http://ezrway.blogspot.com/2009/10/ironruby-and-rspec-with-color.html"&gt;blogged about earlier this week&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Also new in this code is the setting of the IronRuby search paths.  I hard coded the basic search paths from ir.exe.config into a 'custom' xml file that can be edited separately from ir.exe.config.  The config.xml file looks like&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt; &lt;a href="http://gist.github.com/220691"&gt;this&lt;/a&gt; (blogger ate the xml tags so I used the gist).  That link also has the simple Ruby files that the Rspec file uses.&lt;br /&gt;&lt;br /&gt;The format of config.xml was mostly controlled by the fact the Ruby#CreateEngine#SetSearchPaths requires a ICollection and a linq query was the first method that popped into my head.  (There is most probably a better/cleaner way so please let me know if you have one.)&lt;br /&gt;&lt;br /&gt;Here is the &lt;a href="http://gist.github.com/220693"&gt;simple spec file&lt;/a&gt;.   And here is a screen shot of the console window output&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ybitcanW8FQ/SuiRksFyWvI/AAAAAAAAAA0/c7rUaj70uDM/s1600-h/acad-rspec.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 296px;" src="http://3.bp.blogspot.com/_ybitcanW8FQ/SuiRksFyWvI/AAAAAAAAAA0/c7rUaj70uDM/s320/acad-rspec.jpg" alt="" id="BLOGGER_PHOTO_ID_5397724212900289266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is just proof-of-concept stage right now, but I thought someone might be interested.  If you are following along with the AutoCAD project,  I will update the C# code there after I have done a bit more testing.&lt;br /&gt;&lt;br /&gt;Next up,  I plan to try to mock AutoCAD using flexmock.&lt;br /&gt;&lt;br /&gt;Stay Tuned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-3086548814224306768?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/3086548814224306768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/10/testing-using-ironruby-and-rspec-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/3086548814224306768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/3086548814224306768'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/10/testing-using-ironruby-and-rspec-in.html' title='Testing using IronRuby and Rspec in a Hosted Environment'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_ybitcanW8FQ/SuiRksFyWvI/AAAAAAAAAA0/c7rUaj70uDM/s72-c/acad-rspec.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-7320103690697551255</id><published>2009-10-26T15:04:00.001-04:00</published><updated>2009-10-26T15:45:54.250-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='IronRuby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rspec'/><title type='text'>IronRuby and RSpec with color</title><content type='html'>So I'm using Rspec to test some IronRuby code on my Vista box.  I tried the --colour switch only to be told that I needed to install the win32console gem.  No biggie right?  I installed that gem and was told something about something about something, I don't even remember it all and can't find my notes now.&lt;br /&gt;&lt;br /&gt;The thing that I do remember is that I still could not get color output from Rspec.  So I did some googling (or is it googleing?) and found iron-term-ansicolor.rb in  &lt;a href="http://github.com/hotgazpacho/iron-term-ansicolor/"&gt;this github repo by hotgazpacho .  &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So I gave that a try.  It worked well in ir, but still wouldn't work with Rspec.  hotgazpacho was opening Kernel#puts but it appeared that I needed to open IO#write to get console.exe to show the colored output. ( I use &lt;a href="http://console.sourceforge.net/"&gt;console.ex&lt;/a&gt;&lt;a href="http://console.sourceforge.net/"&gt;e&lt;/a&gt; when I runs tests on my Vista box.  It is great).&lt;br /&gt;&lt;br /&gt;So, using the iron-term-ansicolor.rb code as a guide, I hacked together this code&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px 20px 20px;"&gt;&lt;br /&gt;&lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; text-align: left;"&gt;require 'mscorlib'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;## add the trailing m  because some of the rspec output spans multiple lines&lt;br /&gt;ANSI_REGEXP = /\e\[(.+?)m(.+?)(?=(\e\[0m|\z))/m&lt;br /&gt;SsC=System::ConsoleColor&lt;br /&gt;&lt;br /&gt;class IO&lt;br /&gt;alias_method :original_write, :write&lt;br /&gt;&lt;br /&gt;def write(*args)&lt;br /&gt;    count = 0&lt;br /&gt;    args.each do |arg|&lt;br /&gt;&lt;br /&gt;    fg_color = System::Console.ForegroundColor&lt;br /&gt;    bg_color = System::Console.BackgroundColor&lt;br /&gt;&lt;br /&gt;   ##dkb&lt;br /&gt;    if ANSI_REGEXP.match(arg)&lt;br /&gt;      data = extract_ansi_data(arg)&lt;br /&gt;    else&lt;br /&gt;      data = {:text =&gt; arg}&lt;br /&gt;    end  &lt;br /&gt;&lt;br /&gt;    System::Console.ForegroundColor = data[:foreground] || fg_color&lt;br /&gt;    System::Console.BackgroundColor = data[:background] || bg_color&lt;br /&gt;    count = original_write(data[:text])&lt;br /&gt;    System::Console.BackgroundColor = bg_color&lt;br /&gt;    System::Console.ForegroundColor = fg_color&lt;br /&gt;  end&lt;br /&gt;  count&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;private&lt;br /&gt;def extract_ansi_data(arg)&lt;br /&gt;  fg_color_map =    Hash[30,SsC.Black,31,SsC.Red,32,SsC.DarkGreen,33,SsC.DarkYellow,34,SsC.DarkBlue,35,SsC.DarkMagenta,&lt;br /&gt;                 36,SsC.DarkCyan,37,SsC.Gray]&lt;br /&gt;  bg_color_map = Hash[40,SsC.Black,41,SsC.DarkRed,42,SsC.DarkGreen,43,SsC.DarkYellow,44,SsC.DarkBlue,45,SsC.DarkMagenta,&lt;br /&gt;                 46,SsC.DarkCyan,47,SsC.Gray]&lt;br /&gt;  matches = ANSI_REGEXP.match(arg)&lt;br /&gt;  fg_color = fg_color_map[matches[1].to_i] || System::Console.ForegroundColor&lt;br /&gt;  bg_color = bg_color_map[matches[1].to_i] || System::Console.BackgroundColor&lt;br /&gt;  { :foreground =&gt; fg_color, :background =&gt; bg_color,:text =&gt; matches[2]}&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;(Save this code somewhere in the IronRuby load path)&lt;br /&gt;&lt;br /&gt;Then,  I dove into the rspec code and in rspec-1.2.9\lib\spec\runner\options.rb  I made this small change to the def colour=  method (about line 191)&lt;br /&gt;&lt;div style="margin: 5px 20px 20px;"&gt;&lt;br /&gt;&lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; text-align: left;"&gt;&lt;br /&gt;  ##comment out the line below&lt;br /&gt;  #require 'Win32/Console/ANSI' ;\&lt;br /&gt;  ## add this line&lt;br /&gt;     require 'dkb-iron-term-ansicolor'  #or whatever you name the code above&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;With these 2 changes,  I can use the -c option of Rspec to get the glorious green/red output when testing my IronRuby code.  There may be a better, cleaner way, but I did a bit of searching and could not find it.  This way seems to work, plus it gave me a good excuse to dig into the Rspec code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-7320103690697551255?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/7320103690697551255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/10/ironruby-and-rspec-with-color.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/7320103690697551255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/7320103690697551255'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/10/ironruby-and-rspec-with-color.html' title='IronRuby and RSpec with color'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-34643154003806702</id><published>2009-08-19T07:15:00.000-04:00</published><updated>2009-08-19T07:39:40.339-04:00</updated><title type='text'>Ruby on the AutoCAD Command line</title><content type='html'>Using IronRuby,  a bit of C# code and a great deal of aid from&lt;a href="http://blog.tomasm.net/2009/04/15/python-says-hello-to-ruby/"&gt; this post&lt;/a&gt;,  I was able to create an interactive Ruby interpreter for the AutoCAD command line.&lt;br /&gt;&lt;br /&gt;This part of my effort to bring some Ruby love to AutoCAD.  The main part of my efforts can be found on &lt;a href="http://github.com/davidbl/IronRuby-Autocad-Helper/tree/master"&gt;github&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The code for the REPL is available there, so I won't post it here.  But here is a little movie show Ruby and AutoCAD playing well together.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object width="459" height="381" class="BLOG_video_class" id="BLOG_video-ae1c2daad0f67096" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v8.nonxt7.googlevideo.com/videoplayback?id%3Dae1c2daad0f67096%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330149232%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D2C8DD1F87EB77E9CFC6EC04E207E4B48425497B7.78140E45BDEEA793EAAC77D44898C2FB8919CBA4%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Dae1c2daad0f67096%26offsetms%3D5000%26itag%3Dw160%26sigh%3DdW0Dfk_m2Kfj5ie1Wpa5Qb60H7s&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="459" height="381" bgcolor="#FFFFFF"flashvars="flvurl=http://v8.nonxt7.googlevideo.com/videoplayback?id%3Dae1c2daad0f67096%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330149232%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D2C8DD1F87EB77E9CFC6EC04E207E4B48425497B7.78140E45BDEEA793EAAC77D44898C2FB8919CBA4%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Dae1c2daad0f67096%26offsetms%3D5000%26itag%3Dw160%26sigh%3DdW0Dfk_m2Kfj5ie1Wpa5Qb60H7s&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-34643154003806702?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=ae1c2daad0f67096&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/34643154003806702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/08/ruby-on-autocad-command-line.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/34643154003806702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/34643154003806702'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/08/ruby-on-autocad-command-line.html' title='Ruby on the AutoCAD Command line'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-2744501386053144884</id><published>2009-08-17T14:19:00.000-04:00</published><updated>2009-08-17T14:53:05.706-04:00</updated><title type='text'>Ruby and AutoCAD via IronRuby</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Inspired by a blog post by Kean Walmsley  &lt;/span&gt;&lt;a style="font-family: arial;" href="http://through-the-interface.typepad.com/through_the_interface/2009/04/using-ironruby-inside-autocad.html"&gt;here&lt;/a&gt;&lt;span style="font-family:arial;"&gt;, I have been working on some wrapper and helper functions for driving AutoCAD using Ruby.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;IronRuby and Kean's loader function gives the AutoCAD developer full access to the managed API.  But any that has coded against that API knows it can be verbose and lead to some not-so-readable code, like the C# code below.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;[CommandMethod("AddLine")]&lt;br /&gt;public static void AddLine()&lt;br /&gt;{&lt;br /&gt;// Get the current document and database&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;  Document acDoc = Application.DocumentManager.MdiActiveDocument;&lt;br /&gt;Database acCurDb = acDoc.Database;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;  // Start a transaction&lt;br /&gt;using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())&lt;br /&gt;{&lt;br /&gt; // Open the Block table for read&lt;br /&gt; BlockTable acBlkTbl;&lt;br /&gt; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;      // Open the Block table record Model space for write&lt;br /&gt; BlockTableRecord acBlkTblRec;&lt;br /&gt; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],&lt;br /&gt;                  OpenMode.ForWrite) as BlockTableRecord;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;       // Create a line that starts at 5,5 and ends at 12,3&lt;br /&gt; Line acLine = new Line(new Point3d(5, 5, 0), new Point3d(12, 3, 0));&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;      acLine.SetDatabaseDefaults();&lt;br /&gt;&lt;br /&gt;// Add the new object to the block table record and the transaction&lt;br /&gt; acBlkTblRec.AppendEntity(acLine);&lt;br /&gt; acTrans.AddNewlyCreatedDBObject(acLine, true);&lt;br /&gt; // Save the new object to the database&lt;br /&gt; acTrans.Commit();&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;  }&lt;/span&gt;&lt;/pre&gt;&lt;pre class="codeLine"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In Ruby, using my AcadHelper module,that code becomes&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;def line_example&lt;br /&gt;line = create_line [1,1], [2,4,5]&lt;br /&gt;line.add_to_model_space&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div style="text-align: left;"&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Add in a begin-rescue-end block and it still only 8 lines of, in my opinion, very readable code&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="codeLine"&gt;&lt;br /&gt;def line_example&lt;br /&gt;begin&lt;br /&gt;  line = create_line [1,1], [2,4,5]&lt;br /&gt;  line.add_to_model_space&lt;br /&gt;rescue Exception =&gt; e&lt;br /&gt;  puts_ex e&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;I hope Ruby catches on as development option for AutoCAD. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;As a long-time AutoLISP hacker, I love having an interpreted language to use for development.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Ruby offers that, along with full access to the API and the beauty and power of Ruby&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;I have posted an initial verision of my AcadHelper.rb on &lt;/span&gt;&lt;a style="font-family: arial;" href="http://github.com/davidbl/IronRuby-Autocad-Helper/tree/master"&gt;github&lt;/a&gt;&lt;span style="font-family:arial;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;And development continues. I will be updated everything as time allows.  I have added auto-loading&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt; of functions, create_text and create_mtext functions, Editor.GetEntity helper,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;an exception and backtrace print helper.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Next on the list is selection sets. If anyone wants to help out or has ideas, please let me know&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2 class="module-header"&gt;&lt;br /&gt;&lt;/h2&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-2744501386053144884?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/2744501386053144884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/08/ruby-and-autocad-via-ironruby.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/2744501386053144884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/2744501386053144884'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/08/ruby-and-autocad-via-ironruby.html' title='Ruby and AutoCAD via IronRuby'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7129577880637583040.post-3781780924068813433</id><published>2009-05-24T11:55:00.001-04:00</published><updated>2009-05-24T12:02:42.363-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='welcome'/><title type='text'>First blog post</title><content type='html'>This is my first post on my new blog, &lt;span style="font-style: italic;"&gt;There must be an easier way!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It would seem that everyone except me has a blog these days.  &lt;br /&gt;&lt;br /&gt;Well world, your wait is over.  Your suffering can cease.  You will now have access to my every rant, rave, crazy idea and hare-brained scheme. &lt;br /&gt;&lt;br /&gt;The entire web-connected world can now join my darling wife in her (heretofore lonely) enjoyment of the bountiful harvest that regularly spews forth from my over-fertile (and over-fertilized) mind.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7129577880637583040-3781780924068813433?l=ezrway.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ezrway.blogspot.com/feeds/3781780924068813433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ezrway.blogspot.com/2009/05/first-blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/3781780924068813433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7129577880637583040/posts/default/3781780924068813433'/><link rel='alternate' type='text/html' href='http://ezrway.blogspot.com/2009/05/first-blog-post.html' title='First blog post'/><author><name>David K. Blackmon</name><uri>http://www.blogger.com/profile/12781319978344272984</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
