Monday, October 6, 2008

Starting Hydraflow within Civil 3D

By default you have to double-click the hydraflow application you wish to start via a shortcut - usually on the desktop. For some, this is very acceptable, either they don't use Civil 3D and only use Hydraflow, or they use Civil 3D and don't care about Hydraflow.

If you're in the middle and your inside of Civil 3D wanting to open Hydraflow, you have to minimize Civil 3D before launching Hydraflow. I'll offer a quick tip to fix that, here is how I'm opening Hydraflow within Civil 3D.

First, there is no command for Hydraflow, let alone seperate commands for each extension. Knowing AutoCAD, we know that in order to do anything, a command is needed to execute the action you want to take. As mentioned, Civil 3D has nothing in the way of Hydraflow commands, so we're starting from the ground. A little (little should be stressed here) programming is in order to define the commands needed to launch Hydraflow within Civil 3D.

If you're not LISP savvy, and I'm not, you can search around online to find resources to help you along, a great resource for everything lisp and CAD Management is Robert Green's site http://www.cad-manager.com/ . Check it out when you can, for now I'll copy my code here so you can just paste it into a notepad file and get moving.

Once we tell Civil 3D (via lisp) to define our new commands, we can create commands in the CUI that reference our lisp commands.

The lisp code I used for Storm Sewers is as follows:

(defun c:hstm ()
(startapp "\"C:\\Program Files\\Hydraflow Storm Sewers Extension for AutoCAD Civil 3D 2009\\Storm2009.exe\"")
(princ)
)

Line by line definitions:

Line 1: Defun = Define Function, we're defining a command, that command is HSTM, that is what I called it, you can call it whatever you want.

Line 2 & 3: AutoCAD already has a command called startapp for Start Application, use this to navigate to the .exe file you want to run.

Line 4 & 5: Needed to to close the lisp. You'll always see the (princ) at the end of a lisp. I don't know why, it's just always there! If you know, leave a comment and fill me in!

I followed this format with each extension, giving me three new commands. Here are the other lisp files:

Hydrographs:

(defun c:hydro ()
(startapp "\"C:\\Program Files\\Hydraflow Hydrographs Extension for AutoCAD Civil 3D 2009\\Hydro2007.exe\"")
(princ)
)

Express:

(defun c:hexp ()
(startapp "\"C:\\Program Files\\Hydraflow Express Extension for AutoCAD Civil 3D 2009\\HydraflowExpress.exe\"")
(princ)
)

Once those are created and loaded (I just loaded them into my Startup suite, so each drawing that opens loads them) you have a choice. You can run the commands as they are, limiting you to entering the commands at the command line, or you can make buttons out of them and add them to a menu. I've added mine to a Hydro menu I created. Since the command list won't show the newly created commands, you'll have to add them.


I've pasted the contents of the storm sewers command above. From that, hopefully you can figure the other two out. Once there is a command is there, you can add it to a toolbar or menu or even a ribbon panel.







1 comment:

Anonymous said...

(defun c:whyprinc ()
(princ "\nSomething Printed to Commandline.")
)


(defun c:hereswhy ()
(princ "\nSomething Printed to Commandline.")
(princ)
)