AutoCAD Clipboard

Discussion in 'AutoCAD' started by Keven Corazza, Oct 21, 2004.

  1. Hi,

    I'm trying to find a way to insert some drawing entities on AutoCAD. I would
    like to be compatible with all AutoCAD so I cannot use ActiveX or something
    like that.

    I found two way: send messages to command lines with the commands that draw
    the entities but I don't like this solution because it is not so fast; a
    similar way is to write the drawing commands in a Script file and then tell
    to AutoCAD to run the script.

    Then I've tried to check what happens when AutoCAD copy the selected objects
    to a clipboard. I found several formats but one of this contain a text with
    the path of a temporary dwg file: this dwg file contain exactly the selected
    objects. Then I've tried to put, by code, in the clipboard a new format,
    with the same number, with the path of a my dwg file: when I've used the
    paste command in AutoCAD it paste my file.

    All well, but the problem is the number of the format in the clipboard. I've
    tried with AutoCAD 2002 and the format to use if 49880, with AutoCAD LT 2000
    is 49782.

    Someone of you knows which format number have to be used for the different
    AutoCAD versions ?

    Do you know other ways to export to AutoCAD directly ?

    Thank you in advance.

    Keven Corazza
     
    Keven Corazza, Oct 21, 2004
    #1
  2. Keven Corazza

    Ed Jobe Guest

    What kind of data, from what kind of program, to what program?
     
    Ed Jobe, Oct 21, 2004
    #2
  3. Of course I need drawing data, not image, metafile and similar things. I
    don't know how they save the data in the clipboard, I don't know if they
    put, for example, in the clipboard a copy of the temporary dwg.

    Keven.
     
    Keven Corazza, Oct 21, 2004
    #3
  4. Keven Corazza

    Ed Jobe Guest

    You only answered part of the question. You may not need to use the
    clipboard at all. List *all* (applications, versions, etc) your requirements
    so we can tell you the best method.
     
    Ed Jobe, Oct 21, 2004
    #4
  5. Where Ed is going is to not use the clipboard. If it is drawing entities
    you can use the CopyFrom method. If it is geometric data from say a
    spreadsheet [x/y coords] you draw the entity thru the API not SendCommand
    or scripts.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 21, 2004
    #5
  6. Sorry Ed - didn't see your reply =)

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 21, 2004
    #6
  7. I read somewhere that the Clipboard is only accurate
    up to 8 places I think. True???
     
    Paul Richardson, Oct 21, 2004
    #7
  8. I read somewhere that the Clipboard is only accurate
    I'm not sure but that rings a bell =)

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 22, 2004
    #8
  9. If you copy double-precision floating point numbers
    to the clipboard, they remain double precision floating
    point numbers (what AutoCAD uses), and if the
    medium you're pasting them into supports that same
    type, then there should be no loss of precision.

    If there is a loss, it's likely the fault of the application
    that copied the data to the clipboard, which could
    mean Excel for example, may not be treating values
    as doubles.
     
    Tony Tanzillo, Oct 22, 2004
    #9
  10. There is a misunderstood.

    I know that I am in the VBA forum but I cannot use VBA. I have my graphic
    application that read and write DXF-DWG through external libraries
    (OpenDWG). I don't know other forums where I ask this information but I hope
    that someone of you can help me.

    The problem is that I would like to offer to my customers a more fast way to
    put a drawing in AutoCAD without export file from my application and import
    in AutoCAD. I know that I can use VBA but I cannot because I would like to
    support all AutoCAD versions even LT.

    Now I'm trying to study what happens with clipboard to see if it is possible
    to put the drawing information in the clipboard and then paste them in
    AutoCAD.

    Well I've used this sample Delphi code to see the different format AutoCAD
    put in the clipboard after a copy on it.

    This is the code:

    for I := 0 to Clipboard.FormatCount-1 do
    ListBox1.Items.Add(IntToStr(Clipboard.Formats));


    The results are several formats everyone with one "ID" (we can call in this
    way...). With this ID I can see the contents of the clipboard. One this ID
    tell me the path of a DWG file that is exactly the DWG file with the
    elements selected.

    This is the code to get the data in the clipboard:

    ClipBoard.Open;
    try
    MyHandle :=
    Clipboard.GetAsHandle(StrToInt(ListBox1.Items[ListBox1.ItemIndex]));
    TextPtr := GlobalLock(MyHandle);
    MyString := StrPas(TextPtr);
    Memo1.Lines.Add(MyString);
    GlobalUnlock(MyHandle);
    finally
    Clipboard.Close;
    end;

    So I've tried to use the same ID to put in the clipboard the path of my DWG
    file and then execute the paste command in AutoCAD and it works! I can paste
    in AutoCAD my DWG!

    Well the problem that I notice is that this special ID is different for the
    different AutoCAD version and it is different from machine.

    The final question is: someone of you know which are the constant ("ID")
    used by AutoCAD to put the information in the Clipboard ?

    Another question is: this is the solution that I found but I'm asking if it
    is possible to use other formats in the clipboard to get/set directly the
    drawing information.

    Thank you for the attention.

    Keven Corazza
     
    Keven Corazza, Oct 22, 2004
    #10
  11. Okay Keven, but what is the overall process you are looking to accomplish?
    You already have drawings so what are you copy/pasting?

    This thread is steering you in the direction of using ObjectDBX to open the
    source drawing in DBX [non-graphic mode] and copying the geometry that way.
    You may also be able to do it with a similar method in OpenDWG, but its
    been a while since I've looked at it. You have more control and no possible
    memory limits as compared to the clipboard. The downside is that it won't
    work with LT but is iterfacing with LT a requirement or a desire? Any kind
    of interface with it is going to be cludgy and unreliable since you can
    only use DDE and SendKeys. So if LT is not required, then move forward with
    DBX and you can use any language not just VBA.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 22, 2004
    #11
  12. I need to work with AutoCAD LT because most of my customers use this
    version.

    But I'm not sure if you have understand what I want to obtain. I would like
    to create a solution that the customer select the drawing objects in my
    external graphic application (line, ...) and paste them to AutoCAD.

    I'm using OpenDWG to create DXF,DWG and I don't have problem on this sense.
    The problem is find a way to use to move dinamically the drawing from my cad
    system to AutoCAD, anytype of AutoCAD.

    Thank you.

    Keven.
     
    Keven Corazza, Oct 22, 2004
    #12
  13. Keven Corazza

    bcoward Guest

    Keven,

    Two of their projects give you everything your looking for.

    The OdxTest project exposes all objects that your looking for. Select your Line,yadaya from the listbox....

    Then look at the Converter project...between the lines you should see your solution.

    Good luck,

    Bob Coward
    CADS, Inc

    800-366-0946
     
    bcoward, Oct 22, 2004
    #13
  14. Thank you for the suggestion but I didn't find these examples. Could you
    send me please ?

    Thank you.

    Keven.


    your Line,yadaya from the listbox....
     
    Keven Corazza, Oct 22, 2004
    #14
  15. Keven Corazza

    Anne Brown Guest

    Keven -

    This is an Autodesk sponsored discussion group. Please go to an
    Open Drawing site for help with that software. It is not
    supported here.
     
    Anne Brown, Oct 22, 2004
    #15
  16. What is OpenDWG?
     
    CAD Programmer, Oct 26, 2004
    #16
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.