Circumference Dimension

Discussion in 'AutoCAD' started by Charliep, Jun 4, 2004.

  1. Charliep

    Charliep Guest

    Does any one have a routine that will dimension for a Circumference that you would share?

    I know that the circumference can be obtained in the properties box, however it would be nice if it were associative.

    By the way I use A2K4

    Thanks in advanced.
     
    Charliep, Jun 4, 2004
    #1
  2. Charliep

    TCEBob Guest

    Well, you probably don't want a circular dimension line all around the circle,
    so how about a leader with the number attached:

    (defun C:circu( / circ circrad circumstr) ;dimension circumference
    (setq circ (entsel "\nSelect a Circle: "))
    (setq circrad (cdr(assoc 40(entget(car circ)))))
    (setq circumstr (strcat "Circumference = " (rtos(* 2 pi circrad))))
    (setq p1(getpoint "Arrow point: "))
    (setq p2(getpoint p1 "Dimension location: "))
    (command "qleader" p1 p2 circumstr "")
    (princ))

    No safeguards.

    rs
     
    TCEBob, Jun 4, 2004
    #2
  3. Charliep

    TCEBob Guest

    Actually, I like this just a bit better:

    (defun C:circu( / circumstr) ;dimension circumference
    (setq circumstr (strcat "Circumf. = "
    (rtos(* 2 pi (cdr(assoc 40
    (entget(car(entsel "\nSelect a Circle: "))))))))
    )
    (command "leader" (getpoint "Arrow point: ")
    (getpoint (getvar "lastpoint") "Dimension location: ")
    "" circumstr "")
    (princ))

    rs
     
    TCEBob, Jun 4, 2004
    #3
  4. Charliep

    Doug Broad Guest

    Charlie,
    This should work most of the time. Be sure to set dimassoc = 2.

    (defun c:circum( / )
    ;;D. C. Broad, 6/5/2004 - Circumference dimension
    (command "dim1" "rad" pause "Circ: <>" "exit")
    (command "dimoverride" "dimlfac" (* 2 pi)
    "" "last" "")
    (Princ))
     
    Doug Broad, Jun 5, 2004
    #4
  5. Excelente Doug....

     
    José Luis Garcia Galán, Jun 5, 2004
    #5
  6. Charliep

    Doug Broad Guest

    Thank you José.
     
    Doug Broad, Jun 6, 2004
    #6
  7. Charliep

    Jürg Menzi Guest

    Hi Doug

    Excellent idea... may be improved a little bit:

    (defun C:Circum ( / OldCmd OldDas)
    ;;D. C. Broad, 6/5/2004 - Circumference dimension
    (setq OldDas (getvar "DIMASSOC")
    OldCmd (getvar "CMDECHO")
    )
    (setvar "DIMASSOC" 2) ;ensure associative dim
    (setvar "CMDECHO" 1) ;ensure prompts
    (command "_.DIM1" "_RAD" pause "" pause ;drag dim to position
    "_.DIMOVERRIDE" "DIMPOST" "Circ: <>" ;remove 'R' from dim
    "DIMLFAC" (* 2 pi)
    "" "_LAST" ""
    )
    (setvar "DIMASSOC" OldDas)
    (setvar "CMDECHO" OldCmd)
    (princ)
    )

    Cheers
     
    Jürg Menzi, Jun 6, 2004
    #7
  8. Charliep

    Doug Broad Guest

    Excellent changes Juerg. I added some final polishing:
    Thanks!

    Code:
    
    (defun c:circum( /  oce oda *error*)
    ;;D. C. Broad, 6/5/2004 Circumference of a circle
    ;;With changes designed by Juerg Menzi on 6/6/2004
    ;;Dimassoc should be set to 2
    (setq oce (getvar "cmdecho")
    oda (getvar "dimassoc"))
    
    (defun *error* (msg)
    (setvar "cmdecho" oce)
    (setvar "dimassoc" oda)
    (if msg (princ msg))
    (princ))
    
    (setvar "cmdecho" 1)
    (setvar "dimassoc" 2)
    
    (command "_.dim1" "_.rad" pause "" pause)
    (setvar "cmdecho" 0)
    (command "_.dimoverride" "dimlfac" (* 2 pi)
    "dimpost" "Circ: <>"
    "" "_last" "")
    
    (*error* nil))
    
    
     
    Doug Broad, Jun 6, 2004
    #8
  9. Charliep

    Jürg Menzi Guest

    Hi Doug

    Good points...
    - Normally I never use this kind of error handler because I've one in my
    common functions:
    (defun...
    (MeStartProc '("SYSVAR1"... "SYSVARn")) ;stores sysvars etc...
    ...Code
    (MeEndProc)
    )
    For a standalone function you've chosen the correct way.
    - Suppressing prompts for "_.dimoverride" - as it must be.

    Cheers
     
    Jürg Menzi, Jun 7, 2004
    #9
  10. Charliep

    Charliep Guest

    Many thanks to all who offered solutions. I have not tried all of the options that you gave me, but the ones I have tried have been what I needed.
    Again THANKS!!!!
     
    Charliep, Jun 7, 2004
    #10
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.