New ArcDim?

Discussion in 'AutoCAD' started by SARCZAR, Aug 2, 2004.

  1. SARCZAR

    SARCZAR Guest

    Does anyone have a newer version or different version of this lisp. It used to work great but since upgrading to 2004 it only works about half the time. What happens is instead of dimensioning the arc it does the inverse of it. anyone know if the way you draw the arc is a factor? here's the lisp if anyone can see a problem with it.

    ; ARCDIM.LSP VS 1.0 MARCH 10 1995
    ; MEASURES THE LINEAR LENGTH OF ARCS AND DIMENSIONS THE ARC TO THE

    (defun dtr (x)
    (* pi (/ x 180.00))
    )

    (defun rtd (y)
    (/ (* 180 y) pi)
    )

    (defun right ()
    (setq ang1 (angle ep cen)
    ang2 (angle ep1 cen)
    ang (- ang1 ang2)
    arclen (abs(* rad ang))
    )
    )

    (defun left ()
    (setq ang (- a1 a2))
    (setq arclen (abs(* rad ang)))
    )

    ;_______________________________________________________________________

    (defun C:arcdim (/ ang1 ang2 ang arclen rad pick_pt pick_ang
    cen pick_pt extpt1 extpt2 extpt3 extpt4 ep a1 a2 ep1 e6 e7 ent4 temp_pt1
    temp_pt2 temp_pt3 temp_pt4 e1 e2 e3 e4 text_ang th txt1 txt e5 ep1a epa
    ep1a1 epa1 search type)

    (setvar "cmdecho" 0)
    (setvar "blipmode" 0)
    (setq cn (entsel "\nSelect arc to dimension: "))
    (setq dn (car cn))
    (setq aw (entget dn))
    (setq type (cdr(assoc 0 aw)))
    (if (= type "ARC")
    (progn
    (setq a1 (cdr (assoc 50 aw)))
    (setq a2 (cdr (assoc 51 aw)))
    (setq cen (cdr (assoc 10 aw))
    rad (cdr (assoc 40 aw)))
    (setq ep (polar cen (cdr (assoc 50 aw)) rad)
    ep1 (polar cen (cdr (assoc 51 aw)) rad))
    (if (< a1 a2) (left)
    (right)
    )
    (prompt "\nEnter dimension location: ")
    (command "dim" "angular" "" cen ep ep1 pause (rtos arclen) pause "exit")

    )
    (prompt "\nThe Selected entity was not an arc ")
    )
    (setvar "clayer" "0")
    (setvar "cmdecho" 1)
    (setvar "blipmode" 1)

    (princ)
    )
    (princ "\nType arcdim to envoke the command: ")
     
    SARCZAR, Aug 2, 2004
    #1
  2. SARCZAR

    Jürg Menzi Guest

    Hi SARCZAR

    Try this one:
    Code:
    (defun C:ArcLen ( / CurRad DimObj *Error* NewDim OldCmd)
    (vl-load-com)
    (setq OldCmd (getvar "CMDECHO"))
    (defun *error* (Msg)
    (setvar "CMDECHO" OldCmd)
    (if Msg (princ Msg))
    (princ)
    )
    (setvar "CMDECHO" 1)
    (command "_.DIM1" "_.ANG" pause pause "" "")
    (setvar "CMDECHO" 0)
    (setq DimObj (vlax-ename->vla-object (entlast))
    CurRad (distance
    (vlax-get DimObj 'AngleVertex)
    (vlax-get DimObj 'ExtLine1EndPoint)
    )
    NewDim (* CurRad (vla-get-Measurement DimObj))
    )
    (vla-put-TextOverride DimObj (rtos NewDim))
    (vla-Update DimObj)
    (*Error* nil)
    )
    
    Cheers
     
    Jürg Menzi, Aug 2, 2004
    #2
  3. SARCZAR

    Jürg Menzi Guest

    And this one is a little bit more 'professional':

    Code:
    (defun C:ArcLen ( / CurEnt CurObj CurRad ExLoop DimObj *Error* NewDim OldCmd)
    (vl-load-com)
    (setq OldCmd (getvar "CMDECHO"))
    (defun *error* (Msg)
    (setvar "CMDECHO" OldCmd)
    (if Msg (princ Msg))
    (princ)
    )
    (while (not ExLoop)
    (initget " ")
    (setq CurEnt (entsel "\nSelect Arc: "))
    (cond
    ((eq CurEnt "") (setq ExLoop T))
    (CurEnt
    (setq CurObj (vlax-ename->vla-object (car CurEnt)))
    (if (eq (vla-get-ObjectName CurObj) "AcDbArc")
    (progn
    (setvar "CMDECHO" 0)
    (princ "\nDimension line position: ")
    (command "_.DIM1" "_.ANG" CurEnt pause "" "")
    (setq DimObj (vlax-ename->vla-object (entlast))
    CurRad (distance
    (vlax-get DimObj 'AngleVertex)
    (vlax-get DimObj 'ExtLine1EndPoint)
    )
    NewDim (* CurRad (vla-get-Measurement DimObj))
    ExLoop T
    )
    (vla-put-TextOverride DimObj (rtos NewDim))
    (vla-Update DimObj)
    )
    (princ "selected object is not an Arc. ")
    )
    )
    ((princ "1 selected, 0 found. "))
    )
    )
    (*Error* nil)
    )
    
    Cheers
     
    Jürg Menzi, Aug 2, 2004
    #3
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.