How to calculation length of arc

Discussion in 'AutoCAD' started by Adesu, May 25, 2004.

  1. Adesu

    Adesu Guest

    I've create a lisp program about calculation length of arc,with command
    "list",any other suggest to calculate it,can you give me sample and thanks a
    lot for your reply.
    Best regards
    Ade Suharna


    ; Ale is stand for to calculation length of arc
    ; Design by Ade Suharna
    ; May 21, 2004
    (defun c:ale ()
    (command "setvar" "cmdecho" "0")
    (command "limmax" (list 120 80))
    ;----------------------------------------------------
    (setq p1 (getpoint "\nCLICK FIRST POINT: "))
    (setq p2 (getpoint "\nCLICK SECOND POINT: "))
    (setq p3 (getpoint "\nCLICK THIRD POINT: "))
    ;----------------------------------------------------
    (command ".arc" p1 p2 p3 "")
    (command ".list" (ssget) "")
    ;----------------------------------------------------
    (command "setvar" "cmdecho" "1")
    (princ)
    )
     
    Adesu, May 25, 2004
    #1
  2. Adesu

    Jürg Menzi Guest

    Adesu

    If you on A2k+, then this code will work:

    ; Ale is stand for to calculation length of arc
    ; Design by Ade Suharna
    ; May 21, 2004
    (defun c:ale ( / p1 p2 p3 CurObj ArcLen) ;localize var's
    (vl-load-com)
    (setvar "cmdecho" 0) ;Why 'command'?
    (command "limmax" (list 120 80)) ;Why 'limmax'???
    ;----------------------------------------------------
    (setq p1 (getpoint "\nCLICK FIRST POINT: "))
    (setq p2 (getpoint "\nCLICK SECOND POINT: "))
    (setq p3 (getpoint "\nCLICK THIRD POINT: "))
    ;----------------------------------------------------
    (command "_.arc" p1 p2 p3) ;"" restarts the command
    (setq CurObj (vlax-ename->vla-object (entlast))
    ArcLen (vlax-curve-getDistAtParam
    CurObj
    (vlax-curve-getEndParam CurObj)
    )
    )
    (princ (strcat "\nLength of Arc: " (rtos ArcLen)))
    ;----------------------------------------------------
    (setvar "cmdecho" 1) ;Why 'command'?
    (princ)
    )

    Cheers
     
    Jürg Menzi, May 25, 2004
    #2
  3. Adesu

    Jürg Menzi Guest

    Adesu

    This piece of code works for most objects:
    <snip>
    (setq CurObj (vlax-ename->vla-object (entlast))
    ArcLen (vlax-curve-getDistAtParam
    CurObj
    (vlax-curve-getEndParam CurObj)
    )
    )
    <snip>

    For Arcs only, 'ArcLength' is enough:
    <snip>
    (setq CurObj (vlax-ename->vla-object (entlast)))
    (princ
    (strcat
    "\nLength of Arc: " (rtos (vla-get-ArcLength CurObj))
    )
    )
    <snip>

    Cheers
     
    Jürg Menzi, May 25, 2004
    #3
  4. Adesu

    Tom Smith Guest

    I've create a lisp program about calculation length of arc,with command
    Length of an arc = radius * included angle

    (defun arclen (edata / radius startang endang inclang)
    (setq
    radius (cdr (assoc 40 edata))
    startang (cdr (assoc 50 edata))
    endang (cdr (assoc 51 edata)))
    (if (> startang endang)
    (setq endang (+ endang (* 2 pi))))
    (setq inclang (- endang startang))
    (* radius inclang))

    After you place the arc, you can find its length from (arclen (entget
    (entlast)))
     
    Tom Smith, May 25, 2004
    #4
  5. Adesu

    TCEBob Guest

    Jürg,

    Thanks for the code. I'm still getting comfortable with vla commands and it will
    help. I sent a simpler Autolisp to Adesu, with a lot of comments, in the
    assumption that he is just beginning to learn to program.

    rs
     
    TCEBob, May 25, 2004
    #5
  6. Adesu

    Jürg Menzi Guest

    TCEBob
    As well a beginner should make itself familiar with the methods of ActiveX.
    On the one hand ActiveX is an useful bridge to VB(A) and on the other hand
    makes it sense to be of use *all* possibilities of LISP *and* VisualLISP.
    <sig>

    Cheers
     
    Jürg Menzi, May 25, 2004
    #6
  7. Adesu

    TCEBob Guest

    Sensei,

    I see that you are correct and beg only to ask: how can the student learn to run
    until he has mastered walking? The Way to Vla and Vba is made clearer after
    finding Autolisp. Also the help files on Vla are directed at the Masters and
    baffle the novice.

    Truly, the vlax code that you presented is superior to plain Autolisp, in that
    it works more generally. But it also does more than Adesu asked for. Let's get
    him -- and other starters -- to learn how to put together a program and how to
    use functions instead of relying on "command."

    rs
     
    TCEBob, May 25, 2004
    #7
  8. Adesu

    Tom Smith Guest

    Truly, the vlax code that you presented is superior to plain Autolisp, in
    that
    Which is why I gave him exactly what he asked, a formula for length of an
    arc and a simple implementation of it to address his question. He doesn't
    care about getting the length of any and all things -- just an arc -- and he
    didn't ask for a journey into VBA or for exploring the maximal possibilities
    of vlisp.

    I agree that however wonderful ActiveX may be, you need to learn the basics
    of lisp programming first, without unnecessary confusion.
     
    Tom Smith, May 25, 2004
    #8
  9. This is a public forum. Some posters respond with info that
    may go beyond an original request in order to provide some
    semblance of completeness as they see it. I see nothing
    wrong with that (as long as the original question is
    addressed). In fact, in the long run it goes farther towards
    making this forum a knowledge base than partial or
    incomplete answers might. Just ignore what you consider
    superfluous. Kudos to Bob and Juerg for reaching higher.

    /imo
     
    michael puckett, May 25, 2004
    #9
  10. Adesu

    Tom Smith Guest

    Kudos to Bob and Juerg for reaching higher.

    Point taken, but I believe I was only reinforcing the same opinion that Bob
    expressed. The code Bob posted was functionally identical to mine, using
    vanilla lisp -- not disceribly "higher" except that he took the time to
    comment every line.

    Completeness has a virtue -- when I contribute a suggestion I usually try to
    go beyond the bare minimum of the question in suggesting other areas that
    might be improved. In this case I didn't rewrite the poster's (c:ale) but
    instead showed him a general-purpose arc length function he could call from
    it. Based on my opinion that abstracting out a function is usually a better
    approach to lisp than putting everything in one long BASIC-like procedural
    sequence.

    On the other hand, not blowing away a novice is also a good thing. Give 'em
    the short answer first, I'd say, & then we can extemporize on more
    complicated scenarios. I've learned a lot from the "side" discussions here
    as well.
     
    Tom Smith, May 25, 2004
    #10
  11. Adesu

    TCEBob Guest

    I like to think that "higher" refers to my ongoing struggle to become more
    fluent in vlax and not to the extravagant commenting in the stuff I gave to
    Adesu.

    rs
     
    TCEBob, May 25, 2004
    #11
  12. Adesu

    btlsp Guest

    btlsp, May 25, 2004
    #12
  13. Adesu

    btlsp Guest

    btlsp, May 25, 2004
    #13
  14. Adesu

    Tom Smith Guest

    I like to think that "higher" refers to my ongoing struggle to become more
    Probably. I don't have the time for more than a back-burner struggle with
    it, not an ongoing effort. I continue to keep an eye out for a good solid
    case, in my realm, where vlax is actually needed, either for functionality
    or for speed that I can't achieve with vanilla methods. Otherwise, as you
    mentioned, the baffling "help" alone is so frustrating that on the odd
    occasion when I grapple with it I usually give up in short order.

    I have two candidates in mind for rewriting, one an object-splitter-upper
    functions where I've been forced to use a hack to make it work-- a clever
    one if I do say so, but still a hack. The other is a "squiggling" routine
    for renderings which is deeply recursive and could use a major speed boost
    if possible. Next time I have the opportunity to delve deeply into
    programming -- rather than just getting a routine working ASAP -- I'll
    tackle one of those.
     
    Tom Smith, May 25, 2004
    #14
  15. We are all trying to get more fluent <well most of us anyway> :)
     
    michael puckett, May 25, 2004
    #15
  16. Sounds like we all support the same essential idea here :)
     
    michael puckett, May 25, 2004
    #16
  17. Adesu

    Adesu Guest

    1.(command "limmax" (list 120 80)) ;Why 'limmax'??? ---> my cad set limmax
    in 12.0000,9.0000
    2.(vl-load-com) ---> this here I start applicated from (c:xxx) to
    (vl-load-com)
    3.(setq CurObj (vlax-ename->vla-object (entlast))
    ArcLen (vlax-curve-getDistAtParam CurObj
    (vlax-curve-getEndParam CurObj) ) ) ----> this here I got problem to
    interpreting it !,not yet familiar
    4.I sent a simpler Autolisp to Adesu, with a lot of comments, in the
    assumption that he is just beginning to learn to program. ---> I need a
    simple Autolisp with little (not a lot) of comments,problem in language to
    interpreting
    5.As well a beginner should make itself familiar with the methods of
    ActiveX. --->It's Ok and good idea,thanks
     
    Adesu, May 26, 2004
    #17
  18. Adesu

    OLD-CADaver Guest

    Deja Vu all over again, Michael??? :)
     
    OLD-CADaver, May 26, 2004
    #18
  19. Different players; Notice I'm still on the same team :)
     
    michael puckett, May 26, 2004
    #19
  20. Adesu

    OLD-CADaver Guest

    <<Different players; Notice I'm still on the same team :)>>

    Notice I'm in the stands (rootin' fer you) on this one. Learned my lesson the hard way 5 years ago. ;-)
     
    OLD-CADaver, May 26, 2004
    #20
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.