How to run code from clipboard to command line

Discussion in 'AutoCAD' started by James Maeding, Jan 6, 2004.

  1. I want to grad the text from the clipboard and run it at the command line.
    I use the (DOS_CLIPBOARD) function of doslib to get the string, then how can I run it at the command line?
    I was thinking (eval (read (dos_clipboard))) but that did not work.
    This must be easy but (command ....) does not work obviously.
    I cant seem to get my brain to click on how to do this.
    thanks
    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 6, 2004
    #1
  2. That depends on what's in the clipboard.

    AutoCAD commands? A Script file? LISP code?
     
    Tony Tanzillo, Jan 6, 2004
    #2
  3. James Maeding

    akdrafter Guest

    James,

    I use clickie which as the ability to copy path names and more to the clip board with a right click of the mouse. Works great for copying path names to the clipboard without having to type the entire path. I also use clip clear which places an icon on your taskbar(next to the clock) that will show you if something is actually sitting in the clipboard. Red X if there is something in the clipboard and just a plain clip board if there is not. Links to both pasted below. Hope this helps.

    http://defoort.free.fr/clickie/

    http://www.moonsoftware.com/freeware.asp

    Thing is with AutoCAD is that you have to right click on the command line to do a paste because if you just hit ctrl+V to paste, AutoCAD sees any spaces as an "Enter".

    "Catch" Ya Later,
    AKDRAFTER
     
    akdrafter, Jan 6, 2004
    #3
  4. Some smart person recommended to me on the phone (shame on you RUDY) that I write the text to a temp lisp, then load it.
    Wish I had thought of that.

    The second cool idea he had was to defin a function within the RR using the clipboard text, like this:

    (defun c:RR ()
    (defun temp()
    (eval (read (dos_clipboard)))
    )
    (temp)
    (princ)
    )

    This is a great idea, but I do not know how to implement it, the (eval (read (dos_clipboard))) will likely not work.
    Anyone know how to defin the body of a lisp function using a variable to contain the code.
    This takes a real understanding of how lisp works, obviously I am not at the top of the mountain yet.
    thx
    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 7, 2004
    #4
  5. lisp code.

    Also, is there any way to detect when the sendcommand is done?
    My program loses focus to acad when it does the sendcommand, I would like it to stay on top even though anaother app is
    recieving commands.
    thx

    "Tony Tanzillo" <tony.tanzillo at caddzone dot com>
    |>That depends on what's in the clipboard.
    |>
    |>AutoCAD commands? A Script file? LISP code?

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 7, 2004
    #5
  6. hi James,

    i just downloaded doslib and did a little sample:

    Command: (defun c:test () (alert "hello"))
    C:TEST

    Command: (apply (read (dos_clipboard "c:test")) nil)

    htms

    I write the text to a temp lisp, then load it.
    (read (dos_clipboard))) will likely not work.
     
    Luis Esquivel, Jan 7, 2004
    #6
  7. actually this work for me:

    _$ (dos_clipboard "(defun c:test () (alert \"hello\"))")
    "(defun c:test () (alert \"hello\"))"
    _$ (eval (read (dos_clipboard)))
    C:TEST
    _$ (apply (eval (read (dos_clipboard))) nil)
     
    Luis Esquivel, Jan 7, 2004
    #7
  8. James Maeding

    TCEBob Guest

    Less an answer than a question.

    Why would one need to copy from dos?

    I assume that the computer runs Acad -- which implies Windows.

    Or what am I missing?

    rs
     
    TCEBob, Jan 7, 2004
    #8
  9. James Maeding

    Rudy Tovar Guest

    James, I think you should have mentioned, to everyone, that you wrote this
    in VB for a custom application.
    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi


    I write the text to a temp lisp, then load it.
    (read (dos_clipboard))) will likely not work.
     
    Rudy Tovar, Jan 7, 2004
    #9
  10. Jason Piercey, Jan 7, 2004
    #10
  11. nice tip Luis, I hadn't thought of apply.

    People are getting confused on what I am doing.
    I simply had a VB prog set some text on the clipboard, easy.

    Hard part (until Luis blew this out of the water) was getting acad to run that code at some later time.
    I was not trying to get my VB app to run the code, that would not be a good idea because I did not know which acad
    session the user would want to run the code in.
    Assuming he wanted the active document is not realistic.

    I had just completed the code to make a temp lisp from the clipboard and that worked, but that apply code is too slick.
    After writing all this, I could have had the VB app just write the code to a lisp instead of the clipboard.
    The fact is though, sometimes people will use that code to paste into a text editor, so I like the clipboard as a common
    spot to plop the text.

    thx all

    James Maeding <>
    |>I want to grad the text from the clipboard and run it at the command line.
    |>I use the (DOS_CLIPBOARD) function of doslib to get the string, then how can I run it at the command line?
    |>I was thinking (eval (read (dos_clipboard))) but that did not work.
    |>This must be easy but (command ....) does not work obviously.
    |>I cant seem to get my brain to click on how to do this.
    |>thanks
    |>James Maeding
    |>Civil Engineer/Programmer

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 7, 2004
    #11
  12. James Maeding

    Doug Broad Guest

    Knowing little about your application, its hard to comment but as one
    who does a lot of cutting and pasting, it might be inconvenient to
    use an application that overwrote graphical or OLE information with
    program data pasted to the clipboard. Would'nt in cause less user
    interference to use a temporary file (read in temp directory) to handle
    the i/o or inter-language communication? Its a piece of cake to
    use (load "myfile")
     
    Doug Broad, Jan 7, 2004
    #12
  13. good...

    even i had tried to get rid of the programming habit, been hard... what i am
    doing now is to combine vb with vlisp and i can run lisp from vb or
    viceversa, but basically my goal is to use vb dialogs...

    have fun,
    luis.
     
    Luis Esquivel, Jan 7, 2004
    #13
  14. funny you mention that.
    I have found the ObjectDCL to completely revolutionize my lisp programming.
    It makes lisp act like the structure of VB.
    I have used it for large applications and it works really well.
    It costs like $200 to buy the editor and you can distrib the arx to make it work for free.

    I have looked into using vb dialogs with lisp but its too much of a pain to have the vb dialog modify my lists in lisp.
    For example, I did a tool to deal with cogo figures. The figures are lists of line and arc data.
    I want the dialog to be able to modify , add, or delete a list item while it is open.
    That takes a lot of converting around. THe ODCL gives me all the advantages of a GUI activex dialog editor and It work
    seamlessly with lisp. I am suprised how few people use the ODCL program, it allows me to write progs that exceed the
    capabaility of VB.

    "Luis Esquivel" <>
    |>good...
    |>
    |>even i had tried to get rid of the programming habit, been hard... what i am
    |>doing now is to combine vb with vlisp and i can run lisp from vb or
    |>viceversa, but basically my goal is to use vb dialogs...
    |>
    |>have fun,
    |>luis.
    |>
    |>
    |>>
    |>> People are getting confused on what I am doing.
    |>> I simply had a VB prog set some text on the clipboard, easy.
    |>
    |>> James Maeding
    |>> Civil Engineer/Programmer
    |>

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 7, 2004
    #14
  15. Nice shots, Luis. BTW, it should be capitalized "Copyright".


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | James Maeding,
    |
    | > funny you mention that.
    | > I have found the ObjectDCL to completely revolutionize my lisp
    | programming.
    | > It makes lisp act like the structure of VB.
    | > I have used it for large applications and it works really well.
    | > It costs like $200 to buy the editor and you can distrib the arx to make
    | it work for free.
    | >
    | > I have looked into using vb dialogs with lisp but its too much of a pain
    | to have the vb dialog modify my lists in lisp.
    | > For example, I did a tool to deal with cogo figures. The figures are
    | lists of line and arc data.
    | > I want the dialog to be able to modify , add, or delete a list item
    while
    | it is open.
    | > That takes a lot of converting around. THe ODCL gives me all the
    | advantages of a GUI activex dialog editor and It work
    | > seamlessly with lisp. I am suprised how few people use the ODCL
    program,
    | it allows me to write progs that exceed the
    | > capabaility of VB.
    |
    | i use that program too, but i am more to do something like the image
    | attached, and i know that chad will be able to provide that type of
    dialogs
    | too.
    |
    |
    |
     
    R. Robert Bell, Jan 7, 2004
    #15
  16. thank you Roberto i am still on diapers with this stuff!
     
    Luis Esquivel, Jan 7, 2004
    #16
  17. If you are on diapers, I'm on umbilical cord... ;^)

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | thank you Roberto i am still on diapers with this stuff!
    |
    |
    | > Nice shots, Luis. BTW, it should be capitalized "Copyright".
    | >
    | >
    | > --
    | > R. Robert Bell, MCSE
    | > www.AcadX.com
    |
    |
    |
     
    R. Robert Bell, Jan 7, 2004
    #17
  18. Actually, I think ODCL cannot do the titles on the side like that.
    Those had a nice flare to them.
    Can VB or VBA do that? I had not seen properties to switch the title bar location.

    "Luis Esquivel" <>
    |>James Maeding,
    |>
    |>> funny you mention that.
    |>> I have found the ObjectDCL to completely revolutionize my lisp
    |>programming.
    |>> It makes lisp act like the structure of VB.
    |>> I have used it for large applications and it works really well.
    |>> It costs like $200 to buy the editor and you can distrib the arx to make
    |>it work for free.
    |>>
    |>> I have looked into using vb dialogs with lisp but its too much of a pain
    |>to have the vb dialog modify my lists in lisp.
    |>> For example, I did a tool to deal with cogo figures. The figures are
    |>lists of line and arc data.
    |>> I want the dialog to be able to modify , add, or delete a list item while
    |>it is open.
    |>> That takes a lot of converting around. THe ODCL gives me all the
    |>advantages of a GUI activex dialog editor and It work
    |>> seamlessly with lisp. I am suprised how few people use the ODCL program,
    |>it allows me to write progs that exceed the
    |>> capabaility of VB.
    |>
    |>i use that program too, but i am more to do something like the image
    |>attached, and i know that chad will be able to provide that type of dialogs
    |>too.
    |>

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 7, 2004
    #18
  19. i think not not sure [i am doing this in vb], and you do it by making a bmp
    region first and some other custom controls [as i said i'm still learning,
    and my idea is to update all my dialog boxes] ... :)

    "James Maeding"
    location.
     
    Luis Esquivel, Jan 7, 2004
    #19
  20. I wonder how VB.net will affect all this.
    Has anyone written a good book on using .net with acad?
    I am not quite sure how it all ties together. In VB, there is a type library you ref in the VB project.
    It gives you access to acad's object model.
    Does .net somehow do it differently?
    I was told you can use C functions alongside your VB functions.
    Any good tutorials out there on getting started with .net?

    "Luis Esquivel" <>
    |>i think not not sure [i am doing this in vb], and you do it by making a bmp
    |>region first and some other custom controls [as i said i'm still learning,
    |>and my idea is to update all my dialog boxes] ... :)
    |>
    |>"James Maeding"
    |>> Actually, I think ODCL cannot do the titles on the side like that.
    |>> Those had a nice flare to them.
    |>> Can VB or VBA do that? I had not seen properties to switch the title bar
    |>location.
    |>
    |>

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jan 7, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.