Open AutoCad usina ruby

is there a way to open AutoCad using ruby ​​is a specific file

From within SketchUp ?

UI::openURL("path/to/some.dwg")

You might also use try a %x execute string.

%x{acad.exe "path/to/some.dwg"}

And then there is a Wscript command using the Win32OLE class.

Something like this (untested.) Correct the paths if need be.
(Also if the user has changed the AutoCAD directory name or install disk the normal paths will not work.)


module Author
  module SomePlugin

    require 'win32ole'

    ACAD = File.join( ENV['PROGRAMFILES'], 'AutoCad', 'acad.exe' )

    def open_in_acad(pathname)
      shell = WIN32OLE.new("WScript.Shell")
      shell.Run( "#{ACAD} #{pathname}", 1, false)
    end

  end
end

REF: Run Method (Windows Script Host) | Microsoft Learn

1 Like