Kean Walmsley

July 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Twitter Updates

    follow me on Twitter



    « Using F# to simulate hardware behaviour | Main | Mardi Gras, Super Tuesday and F# »

    January 31, 2008

    Adding aliases for custom AutoCAD commands

    I had an interesting question come in by email and thought I'd share it via this post. To summarise the request, the developer needed to allow command aliasing for their custom commands inside AutoCAD. The good news is that there's a standard mechanism that works for both built-in and custom commands: acad.pgp.

    acad.pgp is now found in this location on my system:

    C:\Documents and Settings\walmslk\Application Data\Autodesk\AutoCAD 2008\R17.1\enu\Support\acad.pgp

    We can edit this text file to add our own command aliases at the end:

    NL,  *NETLOAD

    MCC, *MYCUSTOMCOMMAND

    Here we've simply created an alias for the standard NETLOAD command (a simple enough change, but one that saves me lots of time when developing .NET modules) and for a custom command called MYCUSTOMCOMMAND. If I type NL and then MCC at the AutoCAD command-line, after saving the file and re-starting AutoCAD, I see:

    Command: NL

    NETLOAD

    Command: MCC

    Unknown command "MYCUSTOMCOMMAND".  Press F1 for help.

    Now the fact that MCC displays an error is fine - I don't actually have a module loaded that implements the MYCUSTOMCOMMAND command - but we can see that it found the alias and used it (and the MYCUSTOMCOMMAND name could also be used to demand-load an application, for instance).

    TrackBack

    TrackBack URL for this entry:
    http://www.typepad.com/services/trackback/6a00d83452464869e200e5500f1aed8834

    Listed below are links to weblogs that reference Adding aliases for custom AutoCAD commands:

    Comments

    Mr. Walmsley,
    I hope you don’t mind if I post this question for you. I'm the CAD Manager of a Civil Engineering firm. We're currently using Civil 3D 2008 and Land Desktop Companion 2008 with service pack 2. An employee that used to work with us still helps out when available. He is a programmer. He has written an application which he installed on the 2002 products and upgraded to the 2006 products. He has come across a problem trying to tweak this application and get it to work with our 2008 products. Programming is not my strong point. Is there anyway I could email you the document where he describes in programming language his issues, and hopefully you can lead us in the right direction? I'm not sure how to attach it here. Any help is greatly appreciated.

    Thanks
    Jason

    Hi Jason,

    Frankly, I doubt I'll be able to help: I have little to no knowledge of either LDT or Civil 3D development.

    The best source of help is likely to be the Civil 3D Customization Discussion Group, or the ADN website - where you can submit your questions if you happen to be an ADN member.

    You can certainly email me the document, in case I happen to be able to help off the top of my head, but unfortunately I don't have the luxury of being able to spend time working on this type of issue, myself.

    Regards,

    Kean

    Good morning Kean.

    You can also use the REINIT command to reload the PGP file after you change it. I use this command quite a lot, which saves me from closing all my drawings and restarting Autocad after I make some changes.

    Have a good day.

    Jason

    Very cool - thanks for the tip, Jason!

    Kean

    Mr. Walmsley,
    Thanks for your quick response. I have posted on the dicussion group and am waiting for responses. I totally understand you not having enough time to dig in to this problrm. I still appreciate your feedback. Even though programming is not my strong point, I think you have an interesting blog. Again, thanks. Take it easy.

    Jason

    Starting in 2006?, the pgp file can be edited from Express/ Tools/ Command Alias Editor. Not only does this allow edits on the fly, but when the ap closes it updates your current session. Also changes made to your pgp in a text editor do not migrate to new versions, saving time in getting started out of the box. Personally I find it much easier to use. The Command Alias Editor also allows you to scroll lists of available commands and abbreviatons/ aliases to add/ modify/ or remove.

    Interesting - thanks, Clint.

    Kean

    hellllllllllo

    Verify your Comment

    Previewing your Comment

    This is only a preview. Your comment has not yet been posted.

    Working...
    Your comment could not be posted. Error type:
    Your comment has been posted. Post another comment

    The letters and numbers you entered did not match the image. Please try again.

    As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

    Having trouble reading this image? View an alternate.

    Working...

    Post a comment

    Feed & Share

    Search