error message in routine.....help???

Discussion in 'AutoCAD' started by Steve Harrington, Aug 4, 2004.

  1. I was forwarded the attached lisp routine that is supposed to help me
    increment station text by a constant
    amount. I am receiving an error when attempting to execute the routine.
    After I start the routine, I input my variables then select the objects to
    be altered I receive the following error:

    no function definition: VLAX-ENAME->VLA-OBJECT

    Can anyone help me out here?
    The code is atached below


    ;; getFormattedText
    ;; receives a real number and returns a string in civil station notation
    ;; i.e. 1000.00 = 10+00.00
    (defun getFormattedText (s / stext hundredPlace returnList)
    ;; convert number to string
    (setq stext (rtos s 2 *roundingPrecision*))
    ;; format text
    (cond
    ((< s 10)
    (setq stext (strcat "0+0" stext))
    )
    ((< s 100)
    (setq stext (strcat "0+" stext))
    )
    (T
    (if (= *roundingPrecision* 0)
    (setq hundredPlace 2)
    (setq hundredPlace (+ *roundingPrecision* 3))
    ); if
    (setq stext
    (strcat
    (substr stext 1 (- (strlen stext) hundredPlace))
    "+"
    (substr stext (- (strlen stext) (1- hundredPlace))
    ) ;_ end of strcat
    ) ;_ end of setq
    )
    )
    ) ;_ end of cond
    (setq stext (strcat *stationPrefix* stext))
    ) ;_ end of defun


    ;; convert a selection set to a list of vla-objects
    (defun ss->list ( ss / i e v returnList )
    (setq i 0)
    (repeat (sslength ss)
    (setq e (ssname ss i)
    v (vlax-ename->vla-object e)
    returnList (cons v returnList)
    i (1+ i)
    )
    )
    returnList
    ) ;end



    ;; AddStation.lsp
    ;; routine asks for user selection of station text
    ;; and adds user-specified amount to each station
    (defun c:AddStation ( / tmp ssText lstText vlaText strStation reaStation
    reaNewStation strNewStation)
    ;; get station prefix preference
    (if (null *stationPrefix*) (setq *stationPrefix* "STA: "))
    (setq tmp (getstring (strcat "\nStation prefix <" *stationPrefix* "> :
    ")))
    (if (/= tmp "") (setq *stationPrefix* tmp))
    ;; get rounding precision preference
    (if (null *roundingPrecision*) (setq *roundingPrecision* 0))
    (setq tmp (getint (strcat "\nRounding precision for station text <" (itoa
    *roundingPrecision*) "> : ")))
    (if tmp (setq *roundingPrecision* tmp))
    ;; get adjust amount
    (if (null *reaAdjust*) (setq *reaAdjust* 0.0))
    (setq tmp (getreal (strcat "\nAmount by which to adjust all stations <"
    (rtos *reaAdjust* 2 *roundingPrecision*) "> : ")))
    (if tmp (setq *reaAdjust* tmp))
    ;; get station text
    (prompt "\nSelect station text...")
    ;; filter selection for text and mtext
    ;; and convert to a list of vlaobjects
    (setq ssText (ssget '((0 . "TEXT,MTEXT")))
    lstText (ss->list ssText))
    ;; cycle through every station text
    (foreach vlaText lstText
    ;; get text string
    (setq strStation (vla-get-textstring vlaText)
    ;; trim prefix from string
    strStation (vl-string-left-trim *stationPrefix* strStation)
    ;; remove "+" sign
    strStation (vl-string-subst "" "+" strStation)
    ;; convert to number
    reaStation (atof strStation)
    ;; adjust by user-specified amount
    reaNewStation (+ reaStation *reaAdjust*)
    ;; convert number to civil notation
    strNewStation (GetFormattedText reaNewStation))
    ;; edit text with new station string
    (vla-put-textstring vlaText strNewStation)
    ); foreach
    (princ)
    ); defun
     
    Steve Harrington, Aug 4, 2004
    #1
  2. Try adding to the beginning, or typing in at the
    command line, (vl-load-com)
     
    Jason Piercey, Aug 4, 2004
    #2
  3. Steve Harrington

    MP Guest

    add (vl-load-com) at top of routine

     
    MP, Aug 4, 2004
    #3
  4. thanks for the quick response guys.
    please excuse my ignorance, but I am a novice when it comes to autolisp and
    code. Where should I place vl-load-com into the code to achieve the desired
    results. I tried to load it from the command line but I received the
    no-command response from autocad. Oh, btw, I am using 2002. Thanks in
    advance for your assistance.

    Steve
     
    Steve Harrington, Aug 4, 2004
    #4
  5. Typing it in won't give you a "response" but, did
    the routine work after that?

    As far as placing in the code, at the very top of the
    ..lsp file type in (vl-load-com) and save it. Reload
    the file and all should be well.
     
    Jason Piercey, Aug 4, 2004
    #5
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.