Lisp routine to Label an alignment with MTEXT attached Leader

Discussion in 'AutoCAD' started by markmcclure, Mar 18, 2005.

  1. markmcclure

    markmcclure Guest

    This Lisp routine Labels an alignment with MTEXT attached Leader of 2 lines like STA:10+22 then 54.33 RT or LT

    I just put this together and it seems to work well... I found all of the information from these groups so I will give this back

    [pre]
    ;;Compiled from
    ;;Jeff Mishler (http://discussion.autodesk.com/thread.jspa?messageID=4313970)
    ;;Along with other various sources
    ;;Thanks, Mark McClure 3-17-05

    ;;As described to Jeff Mishler by "Sinc" at theswamp.org
    (if (member "aeccapp.arx" (arx))
    ; import the Land type library
    ; this should only be done once, so first check to see if a
    ; constant defined by the type library already exists...
    (if (= nil vll-kCurve)
    (vlax-import-type-library
    :tlb-filename "landauto.tlb"
    :methods-prefix "vll-"
    :properties-prefix "vll-"
    :constants-prefix "vll-"
    ) ;_ vlax-import-type-library
    ) ;_ if
    )




    (defun c:staoff (/ ACADOBJ AECCALIGN AECCALIGNS AECCAPP AECCDOC AECCPROJ
    AECCUTIL CURALIGNNAME
    ERR OFF PT1 PTLIST QLIST STA STASTR XY2EN LR)
    (and (setq pt1 (getpoint "\nSelect point to label station/offset: "))
    (setq acadObj (vlax-get-acad-object))
    (setq aeccApp (vla-getInterfaceObject acadObj "Aecc.Application"))
    (setq aeccDoc (vla-get-activedocument aeccApp));use of vll-get-activedocument causes error!?!
    (setq aeccUtil (vlax-get aeccDoc "utility"));use of vll-get-utility causes error!?!
    (setq aeccProj (vll-get-activeProject aeccApp))
    (setq aeccAligns (vll-get-alignments aeccProj))
    (setq CurAlignName (vll-get-currentalignment aeccAligns))
    (setq aeccAlign (vll-item aeccAligns curalignname))
    (setq xy2en (vll-xytoeastnorth aeccUtil (vlax-3d-point pt1)))
    (setq ptList (vlax-safearray->list (vlax-variant-value xy2en)))
    (vll-stationoffset aeccAlign (car ptList) (cadr ptList) 'sta 'off 'dir)
    )
    (if sta
    (progn
    (setq staStr (vll-doubletostaformat aeccAligns sta))
    ;(alert (strcat "\nThe selected point is at Station: " staStr " with an offset of: " (rtos off)))

    (if (/= 0 off)
    (if (> 0 off)
    (setq LR " LT")
    (setq LR " RT")
    )
    (setq LR " RT") ;Change this for the case of the offset being 0
    )
    (command "leader"
    pt1

    pause
    ""
    (strcat "STA: " staStr)
    (strcat (rtos (abs off)) LR)
    ""
    )

    )
    )
    (setq qList '(ACADOBJ AECCALIGN AECCALIGNS AECCAPP AECCDOC AECCPROJ AECCUTIL))
    (foreach x qlist
    (setq err (vl-catch-all-apply 'vlax-release-object (list (eval x))))
    (set x nil)
    )
    (princ)
    )
    [/pre]
     
    markmcclure, Mar 18, 2005
    #1
  2. is this intended to deal with the bad object releasing lisp has been giving Jeff and I?
    It seems like this is doing the same thing as with the vlax type calls.

    If you were just trying to show an example, I don't mean to dig beyond the baiscs.
    I have never seen this approach though to accessing the LDT API.
    thx


    markmcclure <>
    |>This Lisp routine Labels an alignment with MTEXT attached Leader of 2 lines like STA:10+22 then 54.33 RT or LT
    |>
    |>I just put this together and it seems to work well... I found all of the information from these groups so I will give this back
    |>
    |>[pre]
    |>;;Compiled from
    |>;;Jeff Mishler (http://discussion.autodesk.com/thread.jspa?messageID=4313970)
    |>;;Along with other various sources
    |>;;Thanks, Mark McClure 3-17-05
    |>
    |>;;As described to Jeff Mishler by "Sinc" at theswamp.org
    |>(if (member "aeccapp.arx" (arx))
    |> ; import the Land type library
    |> ; this should only be done once, so first check to see if a
    |> ; constant defined by the type library already exists...
    |> (if (= nil vll-kCurve)
    |> (vlax-import-type-library
    |> :tlb-filename "landauto.tlb"
    |> :methods-prefix "vll-"
    |> :properties-prefix "vll-"
    |> :constants-prefix "vll-"
    |> ) ;_ vlax-import-type-library
    |> ) ;_ if
    |> )
    |> (set x nil)
    |> )
    |> (princ)
    |> )
    |>[/pre]

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Mar 18, 2005
    #2
  3. markmcclure

    Jeff Mishler Guest

    Hi James,
    I have used this method off and on in my routines. I use when I remember
    to.....what's nice about it is that in the VLIDE 'good' properties and
    methods get highlighted, just like (vla-get-color) so that
    (vll-get-currentalignment) is recognised by the editor as a valid function.

    It does not affect the releasing requirements........it DOES make the code
    somewhat easier to read.
     
    Jeff Mishler, Mar 18, 2005
    #3
  4. got it, learning new stuff all the time :)

    "Jeff Mishler" <>
    |>Hi James,
    |>I have used this method off and on in my routines. I use when I remember
    |>to.....what's nice about it is that in the VLIDE 'good' properties and
    |>methods get highlighted, just like (vla-get-color) so that
    |>(vll-get-currentalignment) is recognised by the editor as a valid function.
    |>
    |>It does not affect the releasing requirements........it DOES make the code
    |>somewhat easier to read.

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Mar 18, 2005
    #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.