Results 1 to 6 of 6

Thread: .NET and Autocad. How to load script from .net app?

  1. #1
    Member
    Join Date
    2010-06
    Posts
    2
    Login to Give a bone
    0

    Question .NET and Autocad. How to load script from .net app?

    1) Added custom toolbar in autocad
    2) Added custom button in autocad.

    Let's say I want that when the user clicks the custom button, a dialogue appears on screen and the user has to punch in the X and Y coordinates for the 2 points of a simple line. When the user clicks ok, using the values entered, a drawing of a line appears inside Autocad.

    I've done this with AutoLisp. But the project I'll have to work on is a bit more complex and requires a somewhat larger amount of user input, so what i want to do is design my dialogues and message-boxes inside a simple c# application.

    The way I thought about the problem is this:
    The custom button opens my application
    The user enters the neccesary data.
    When the user clicks ok, a script is generated from a template and then that script is run in autocad displaying the line.
    How can I get the generated script from my app ( an usual lsp script) to load and run in autocad?

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,743
    Login to Give a bone
    0

    Default Re: .NET and Autocad. How to load script from .net app?

    You would just use C# to create the entity. No need to try to pass scripts back to lisp. In the ObjectARX SDK (see the resources at the top of this forum), there is a sample project called ElipseJig. Just change the entity type from an elipse to a line. This sample will show you how to get user input, create a jig to show a 'rubberband' between the two points and create the entity.

    Also, when you use the .NET api for acad, you create an autocad command with the <CommandMethod> attribute (see the sample). You can then use the cui to add the command to a toolbar.
    C:> ED WORKING....

  3. #3
    Active Member Kerry Brown's Avatar
    Join Date
    2006-08
    Location
    Brisbane : GMT+10
    Posts
    87
    Login to Give a bone
    0

    Default Re: .NET and Autocad. How to load script from .net app?

    Something that Ed missed :
    When the user clicks ok, a script is generated from a template and then that script is run in autocad displaying the line.
    How can I get the generated script from my app ( an usual lsp script) to load and run in autocad?
    Why do you want to create a script and run it from AutoCAD. ?
    Are you sure that's what you want to do, or are you just getting your termonology confused ?

    When you start running different processes you will need to consider and account for syncronicity between processes, which is another issue alltogether.
    another Swamper

  4. #4
    Member
    Join Date
    2010-06
    Posts
    2
    Login to Give a bone
    0

    Default Re: .NET and Autocad. How to load script from .net app?

    Quote Originally Posted by Kerry Brown View Post
    Something that Ed missed :


    Why do you want to create a script and run it from AutoCAD. ?
    Are you sure that's what you want to do, or are you just getting your termonology confused ?

    When you start running different processes you will need to consider and account for syncronicity between processes, which is another issue alltogether.
    1) The project I'll be working on requires a lot of user input. I have to make the user experience feel continuous. I can't let the user enter value after value after value with the command line in Autocad because it's impossible to follow. Using simple Autolisp with DCL to make some sort of dialogues appear isn't a good idea because they can't be nested and I don't want the user to have dialogue after dialogue popping up on screen. Modularity is an issue.So I want to use C# to design and manage the user interface and input.
    Why use a script generated from a template? Because this way I won't have any problems regarding compatibility with a whole lot of Autocad previous versions. Lisp scripts are recognized since the fell of Rome. And the only command from my app to Acad is to be a command to run the script. That's it.

    2) Synchronizing? Yeah, it could be a problem, but the fact is none of the apps (Acad and my app) running would wait one for another. The user clicks on a button, my app opens..but until he clicks ok inside my app, he can use Autocad without any issues doing anything he wants.

  5. #5
    AUGI Addict sinc's Avatar
    Join Date
    2004-02
    Location
    Colorado
    Posts
    1,986
    Login to Give a bone
    0

    Default Re: .NET and Autocad. How to load script from .net app?

    So let me get this straight...

    You want to use .NET so you can use Windows Forms instead of DCL. But you also want your app to work in every version of Autocad. So you are trying to write an external app that runs Lisp scripts inside of Autocad. Is that correct?

    The first problem I see is that Autocad didn't have a .NET interface until the 2005 release, with a significant revamp in the 2007 version. So I'm not sure how you plan on getting your .NET app to run Lisp inside of earlier versions of Autocad... Have you tackled that issue?

    If you end up with an app that can only be used in Autocad 2005 (or 2007) and later, then you can simply use .NET to draw your lines, and you have no need for all the Lisp scripting.

  6. #6
    Woo! Hoo! my 1st post
    Join Date
    2011-11
    Posts
    1
    Login to Give a bone
    0

    Default Re: .NET and Autocad. How to load script from .net app?

    I have created a program in the past that follows the same thought process as what your trying to do. I had created a door program for autocad LT. i had to use this process because the office was running LT and i could ont use LISP only macro and scripts

    step one: add custom Button in autocad
    in order for your custom button to open my application the programming language to use here is a Macro
    mine looked like this:
    ^C^C_AI_STARTAPP;C:/RDM-Door/RDM-Door.exe;\;^C^C_script;"C:/RDM-Door/Run_Script.scr";

    Here's an explanation of how this macro works:

    ^C^C= works as a double escape (clears the command line for new input)
    _AI_STARTAPP; = used to start up external program (my custom .net program)

    C:/RDM-Door/RDM-Door.exe; = location of my visual basic .exe application (need to replace with your path(At this point user clicks the custom button, a dialogue appears on screen)

    \; = now this is the important part, \ is used to wait for user input (user will input on new custom dialogue on screen) Once all user input is complete there needs to be a "finish" button on your program that will export the user input to a .scr file (I had used notepad for .scr file) now your script file has been created

    Remember AutoCad is still waiting for user input because of the "\", all you need to do now is press enter on your keyboard, this will push the Macro to the next step which is to read your .scr file

    C^C_script;"C:/RDM-Door/Run_Script.scr"; = clears command line for new input, reads script in file location from output of custom program

    Let me know if you would like to see the exported .scr file and the export to .scr coding for .net

Similar Threads

  1. Batch/Script automation of Autocad
    By jason.145418 in forum AutoLISP
    Replies: 25
    Last Post: 2014-05-26, 07:23 PM
  2. Opening Autocad LT from script
    By jitesh789 in forum AutoLISP
    Replies: 0
    Last Post: 2010-07-01, 10:04 AM
  3. Script AUTOCAD 2007LT
    By dleray in forum Français - AutoCAD / AutoCAD LT - Général
    Replies: 2
    Last Post: 2007-07-12, 06:32 AM
  4. Execute AutoCAD through a VB Script file (.vbs)?
    By abdulhuck in forum VBA/COM Interop
    Replies: 5
    Last Post: 2007-02-22, 06:16 AM
  5. AutoCAD 2002 freezes as Windows is preparing to load AutoCAD
    By lance_lie in forum AutoCAD General
    Replies: 4
    Last Post: 2006-08-07, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •