Problem with Hot TIp Harry Lisp 1939

Discussion in 'AutoCAD' started by swu, Jul 16, 2004.

  1. swu

    swu Guest

    I'm having a problem with thie cadalyst lisp routine. When ran it, it allows me to select entities but then gives me the following error:

    ActiveX Server returned the error: unknown name: Length

    Any advice would be appreciated . . .

    Code:
    ;;CADALYST 04/04 Tip1939: LL.LSP Length of Linear Objects (c) 2004 Will DeLoach

    (vl-load-com)

    (defun c:ll (/ sset num llen)

    (vl-load-com)

    (setq sset (ssget '((0 . "LINE,LWPOLYLINE")))
    num 0
    llen 0
    )
    (if sset
    (progn
    (repeat (sslength sset)
    (setq llen
    (+ llen
    (vla-get-length (vlax-ename->vla-object (ssname sset num)))
    )
    )
    (setq num (1+ num))
    )
    (setq num (rtos num 2 0)
    llen (rtos llen 4)
    )
    (alert (strcat num " line lengths = " llen))
    )
    )
    )

    Thanks in advance, Scott
     
    swu, Jul 16, 2004
    #1
  2. swu

    ECCAD Guest

    Swu,
    I just made a .lsp called harry.lsp - with the code.
    Checked it out. Ran just fine in R2002.

    Bob
     
    ECCAD, Jul 16, 2004
    #2
  3. Previous to AutoCAD 2005 (maybe it was 2004)
    polylines do not have a length property.
     
    Jason Piercey, Jul 16, 2004
    #3
  4. swu

    swu Guest

    Thanks for your reply. I tried the code again, it works for me in paperspace, not in model space though. Any ideas?

    Land Desktop 3 on Map 2002, Win 2000
     
    swu, Jul 16, 2004
    #4
  5. swu

    swu Guest

    Good call, I was using a line in paperspace so it worked, pline doesn't work. Thanks for pointing that out.
     
    swu, Jul 16, 2004
    #5
  6. swu

    Jeff Mishler Guest

    Give this a try. I've modified it to work with 2002.
    Jeff

    (defun c:ll (/ sset num llen obj)
    (vl-load-com)
    (setq sset (ssget '((0 . "LINE,LWPOLYLINE")))
    num 0
    llen 0
    version (atof (getvar "ACADVER") );; added for check purposes
    )
    (if sset
    (progn
    (repeat (sslength sset)
    (setq obj (vlax-ename->vla-object (ssname sset num)))
    (setq llen
    (+ llen
    (if (or (= (vla-get-objectname obj) "AcDbLine")
    (>= version 16.0));;added check for version 2004+
    (vla-get-length obj)
    (vlax-curve-getdistAtParam obj
    (vlax-curve-getEndParam obj));; added code for pre-2004 to work on
    plines
    )
    )
    )
    (setq num (1+ num))
    )
    (setq num (itoa num);;modified for Integer
    llen (rtos llen);; modified to use current unit format & prec.
    )
    (alert (strcat num " line lengths = " llen))
    )
    )
    (princ);added for quiet exit
    )

    --
    For additional help, try out www.cadvault.com
    remove USES from email address to reply
    work. Thanks for pointing that out.
     
    Jeff Mishler, Jul 16, 2004
    #6
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.