Has anyone come written any code (Lisp) to export a table to .csv?

Discussion in 'AutoCAD' started by Dan, Aug 4, 2004.

  1. Dan

    Dan Guest

    I am new to VB, and have not gotten far with that approach, so I am looking
    to lisp.
    I cannot seem to find a reference in AutoCAD to extract a
    table's data to a file beyond tableexport. I am using 2005. I would like
    to make this a
    seemless process to the user, which gets its name(.csv), and drawing path
    from the current drawing. Tableexport works well, but it is all manual, and
    I cannot turn off the dialog boxes for it.

    Thanks to everyone in sthis group, I have learned alot, and I have a long
    way to go.
     
    Dan, Aug 4, 2004
    #1
  2. Dan

    Dean McCarns Guest

    Dan;

    Quick Background:

    When you tag an object (e.g. a door) the function attaches an extension
    dictionary to that object. This extension dictionary contains (among other
    things) all of the information you see in the schedule.

    When you create a schedule, you are prompted to select objects for that
    schedule, so when you select objects it associates those objects with the
    schedule object and stores the entity ID with the schedule. IMPORTANT -
    entity ID's change every time the drawing is opened so if your thinking of
    creating a round trip data editor for schedules, use the Handle not the
    entity ID.

    What you need to do:

    Step 1: Get the list of objects that are associated with the schedule

    Example:
    (cdr ;<--- Removes firs item from list (which is a reference to model space)
    (vl-remove 'nil ;<--- Remove all nil values from list
    (mapcar
    '(lambda (x)
    (if (= (car x) 330) ;<--- If x is a dxf group 330.....
    (cdr x));<--- ...return ename otherwise return nil
    )
    (entget (car (entsel)));<--- creates entity data list of object you
    select
    )
    )
    )

    (Note: You can take this further by useing a filter to only select schedule
    objects)

    Step 2: Get the schedule data from the objects

    I have some code lying around that digs into objects, tests for an extension
    dictionary attached to them, test for the AEC_PROPERTY_SETS dictionary
    within the extension dictionary, gets a list of all the property sets
    defined in there and pumps out all the schedule values. For you, when you
    extract these values, create a single string with each value seperated by a
    "," (comma) and write that line to a .csv or .txt file.

    Remember this is an extension dictionary attached to an object.

    If your planning a round trip function, make sure you include both the
    object's (e.g. door) handle, the propertset definition handle and the
    schedules handle, this way you can test to ensure everything still exists
    when you put the information back into the drawing.

    Good luck, give me a call if you need further help (I'm not always on the
    NG)
     
    Dean McCarns, Aug 5, 2004
    #2
  3. Dan

    coachball8 Guest

    coachball8, Aug 5, 2004
    #3
  4. Dan

    Dan Guest

    I will look into it, thanks alot.

    Dan
     
    Dan, Aug 5, 2004
    #4
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.