Externally setting a block of text in AutoCAD

Discussion in 'AutoCAD' started by Michael Heumann, Nov 9, 2004.

  1. Hi,
    I have never worked with AutoCAD, but now a client needs me to develop
    an application that involves handling DWG files. What I need to do is
    open AutoCAD with some kind of template file and automatically set its
    label (which I understand is just a block of several text fields) to
    content provided outside.
    My question is: What is the smartest (and easiest) way of doing this?
    I understand AutoCAD has OLE Automation features. Can I manipulate a
    drawing from an external application through OLE? Another option
    might be AutoLISP. How could that work for me?
    I would really appreciate any helpful hint from someone who handles
    the programming aspect of AutoCAD rather than "just" the user's
    perspective.
    I've only been provided a standard user manual of AutoCAD (by the way,
    the version is 2000i), but that doesn't seem to cover these advanced
    features.
    Thanks,
    Michael.
     
    Michael Heumann, Nov 9, 2004
    #1
  2. You are asking a tall pile of questions, Michael,
    while giving only a rough sketch of the context.
    Better get familiar with the application a bit,
    check in the online Help under Customization,
    then come back to the group when you've got
    something put together.
    I don't know OLE at all but what you want may be
    possible through LISP and a script. You have to
    get way more specific.
     
    Michael Bulatovich, Nov 9, 2004
    #2
  3. Michael Heumann

    Cadalot Guest

    Mike

    OLE is Object Link and Embedment, where you might
    copy a section of a word docymnet or excell document.
    It a Windows function

    Sounds like he wants to fill in a drawing title block that
    has been created as a block with attributes from an
    external source.....

    I suggest he looks at blocks and attributes and then
    passing information form and two the drawing from
    an external source via LISP.

    I wrote an application for a company that did this to
    create a bill of materials taking information from basic
    symbols with attributes. The reversed engineered it so that
    they could run a lisp to create a drawing based on a
    TXT or CSV file of information

    Alan
     
    Cadalot, Nov 10, 2004
    #3
  4. I've got my own guess as to what he wants too, Alan, it
    closely matches yours. However he may also want other
    stuff, or something else. It sounds like he hasn't got to
    recognizing entity types yet, hence my comment.
    If that's so, it's a long road.....
     
    Michael Bulatovich, Nov 10, 2004
    #4
  5. First of all, thanks, Michael and Cadalot for your attempts at aiding
    me, in spite of my obvious cluelessness.
    In the meantime, I've advanced somewhat on the topic, so I think I can
    try to be a little more specific with my request.

    I have a drawing that contains several annotation objects (text
    entities?) which are grouped together in a block. Together they
    represent a label that is supposed to hold detailed information about
    the drawing, such as title, author, codes of all sorts etc.

    What I need to do is to programmatically set the values for these text
    objects. It would really help if any of you could tell me which
    AutoLISP instructions I need to access that block and the text objects
    within.

    Thanks for your help.
    Greetings,
    Michael.
     
    Michael Heumann, Nov 24, 2004
    #5
  6. There are two ways that text entities can be in a block:

    1) Plain old MTEXT or TEXT
    2) Attributes

    You access these differently. It sounds like you are trying to
    edit a title block. Many people use title blocks containing ATTRIBUTES,
    though
    some people like to split up the ATTRIBUTES in a separate BLOCK,
    and leave the other linework, logos, etc in another BLOCK.

    Enter the following at the command prompt in a drawing with one of your
    title blocks:

    (entget(car(entsel)))

    then hit enter and pick the titleblock. What do you see?
    --


    MichaelB
    www.michaelbulatovich.com



    MichaelB
    www.michaelbulatovich.com
     
    Michael Bulatovich, Nov 24, 2004
    #6
  7. According to what I was told by the people who made the file, the
    block consists of Attributes.

    Here's the output of what you requested:

    Command: (entget(car(entsel)))
    Select object: ((-1 . <Entity name: 259a4a8>) (0 . "INSERT") (330 .
    <Entity
    name: 259ac10>) (5 . "78D") (100 . "AcDbEntity") (67 . 0) (410 .
    "Model") (8 .
    "1") (100 . "AcDbBlockReference") (66 . 1) (2 . "ROT1") (10 20900.0
    125.0 0.0)
    (41 . 25.0) (42 . 25.0) (43 . 25.0) (50 . 0.0) (70 . 0) (71 . 0) (44 .
    0.0) (45
    .. 0.0) (210 0.0 0.0 1.0))

    "ROT1" is the name of the block, so I assume I did it correctly.
    Otherwise, the above honestly doesn't tell me much.
    I could provide a sample file if that's helpful.

    Thanks,
    Michael.
     
    Michael Heumann, Nov 25, 2004
    #7
  8. There are a couple of routines on my site that access and manipulate
    attributes.
    You could examine them and you should be able you figure out how to
    access yours through lisp. I right fairly clunky but easy to follow
    code, and I annotate it quite a bit to keep it straight in my own mind.
    You are welcome to them.

    The basic trick to getting at attributes is that you have to look for the
    *next* item in the database after the block that contains them.
     
    Michael Bulatovich, Nov 25, 2004
    #8
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.