Access Point Database with ALisp

Discussion in 'AutoCAD' started by rdi, Jan 10, 2004.

  1. rdi

    rdi Guest

    We use LDD (Acad 2k4) to import cogo points (among other things of course).
    I'd like to know if it's possible to access the point database from
    AutoLisp. If not can I use VBA to do it? One of the things I'd like to do
    is to get the coords of specified points.

    TIA
     
    rdi, Jan 10, 2004
    #1
  2. rdi

    Jeff Mishler Guest

    Here's a little snip to get you started. This will list the N/E of
    individually input point numbers. You can expand from this into what you
    want. This was written for ALD3, but I think it will still work with
    ALD2004.

    HTH,
    Jeff

    (defun aecPt_coords (/ ACADOBJ AECAPP AECPROJ POINT POINTS PT#)
    (setq acadobj (vlax-get-acad-object)
    aecapp (vla-getinterfaceobject acadobj "Aecc.Application")
    aecproj (vlax-get aecapp "ActiveProject")
    )
    (setq points (vlax-get aecproj "CogoPoints")
    )
    (while (setq pt# (getint "\nPoint # to extract N/E's: "))
    (setq point (vla-item points (itoa pt#)))
    (princ (strcat "\nNorthing: " (rtos (vlax-get point "Northing"))
    "\tEasting: " (rtos (vlax-get point "Easting"))))
    )
    (princ)
    )
     
    Jeff Mishler, Jan 10, 2004
    #2
  3. Hi,

    This is very straightforward in either VBA or lisp.

    There is sample code for VBA supplied with the software and maybe for Lisp,
    but I've never looked.

    Bear in mind that the APIs supplied by Autodesk are very, very slow and if
    you want to do anything meaningful like processing more than 10 points at a
    time, it would probably pay you to use ADO ActiveX in VBA. DAO also works
    very well, but programming gurus keep saying Microsoft is abandoning it.
    ..

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Jan 10, 2004
    #3
  4. rdi

    John Uhden Guest

    You could look at an example posted on Cadlantic'c Freebies page.
     
    John Uhden, Jan 10, 2004
    #4
  5. rdi

    rdi Guest

    Jeff, Laurie and John:

    Thanks to all of you for the assist. I'll try this info on Monday.
     
    rdi, Jan 11, 2004
    #5
  6. rdi

    RDI Guest

    I tried Jeff and John's suggestions. I appreciate the time that everyone
    took to reply. But I have a couple of concerns. The code that Jeff
    provided is running VERY slow (I asked for the coords for ONE point and it
    took like 15-20 seconds. And I'm on a Dual Pentium P4 with 1 GB of ram and
    more than 50GB free HD space--so I doubt it's the speed of the PC. In
    addition to the speed, it seems to be returning WRONG information. I asked
    for the coords for point #563. It returned Northing: 518103.61
    Easting: 1990070.63 Elevation: 59.41. However If I ID on the node in my
    drawing OR use "List Points" from the menu, this point has the coords of X =
    1990083.89 Y = 518057.73 Z = 59.67 (LIST Points DOES return the same
    coords).

    When I run the code from John's web site, it returns (0.0 0.0 0.0) for the
    same point number--although it is VERY fast. The code from John's page is
    as follows:
    ;downloaded from the "Freebies" second of www.cadlantic.com
    (defun EastNorthToXY (p / AeccApp AeccDocs AeccDoc AeccUtil)
    (if (not *acad*)(setq *acad* (vlax-get-acad-object)))
    (if
    (and
    (setq AeccApp (vl-catch-all-apply 'vla-getinterfaceobject (list
    *acad* "aecc.application")))
    (not (vl-catch-all-error-p AeccApp))
    (setq AeccDocs (vl-catch-all-apply 'vlax-get (list AeccApp
    "Documents")))
    (not (vl-catch-all-error-p AeccDocs))
    (setq AeccDoc (vla-item AeccDocs 0))
    (setq AeccUtil (vl-catch-all-apply 'vlax-get (list AeccDoc
    "Utility")))
    (not (vl-catch-all-error-p AeccUtil))
    (vlax-method-applicable-p AeccUtil "EastNorthToXy")
    )
    (vlax-invoke AeccUtil "EastNorthToXy" p)
    )
    )
     
    RDI, Jan 12, 2004
    #6
  7. rdi

    RDI Guest

    PS
    I'll probably EVENTUALLY get around to trying this in VBA--but I haven't
    tried anything in VBA yet and I was hoping this would be a little "quickie"
    (somethign that I don't have to learn a new language to be able to make it
    happen). I HAVE used VB.Net (but not previous versions) so VB is not
    TOTALLY foreign to me--but still.
     
    RDI, Jan 12, 2004
    #7
  8. rdi

    John Uhden Guest

    The EastNorthToXY function converts a coordinate list in the form of '(E N [Z]),
    not a point number.
    Anyway, my apologies. The ActiveX method doesn't like integers in the
    coordinates. This oughta do it...
    (defun EastNorthToXY (p / AeccApp AeccDocs AeccDoc AeccUtil)
    (if (not *acad*)(setq *acad* (vlax-get-acad-object)))
    (if
    (and
    (setq p (mapcar 'float p))
    (setq AeccApp (vl-catch-all-apply 'vla-getinterfaceobject (list *acad*
    "aecc.application")))
    (not (vl-catch-all-error-p AeccApp))
    (setq AeccDocs (vl-catch-all-apply 'vlax-get (list AeccApp
    "Documents")))
    (not (vl-catch-all-error-p AeccDocs))
    (setq AeccDoc (vla-item AeccDocs 0))
    (setq AeccUtil (vl-catch-all-apply 'vlax-get (list AeccDoc "Utility")))
    (not (vl-catch-all-error-p AeccUtil))
    (vlax-method-applicable-p AeccUtil "EastNorthToXy")
    )
    (vlax-invoke AeccUtil "EastNorthToXy" p)
    )
    )
     
    John Uhden, Jan 13, 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.