How to convert a block with views content into code? I'm running into limitations of views. For example, I would like to add additional logic and formatting to a view shown in a block.
Is there a good way of taking the existing SQL and formatting from the view to create a custom module?

For example:
I want to show a table with taxonomy terms, including their hierarchy. Parent terms will have links to one one, children terms will have links to a different view. 
For children terms I want to show the number of nodes with that term, the number of comments, etc.
This can currently not be done using views or would be rather complex to setup.    

Rather than starting from scratch writing a module is there a good way to use a similar view and reuse the query and the formatting?
You could also use something like this:

$view = views_get_view('view_name');
$view-&gt;set_display('block_display_name'); 
$view-&gt;set_arguments(array($arg1, $arg2)); //only if you need arguments
$view-&gt;execute();
foreach($view-&gt;result as $res) {
  // extra stuff here
}