+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Junior Member
    Using
    AutoCAD 2011
    Join Date
    Dec 2011
    Posts
    22

    Drawing lsp help for prompting circle overall 'diameter' & change as per new value input!

    Registered forum members do not see this ad.

    hi.. need help on creating lsp that can:

    > prompt selected circle overall diameter & change to new diameter if new value is inputed! (enter or right click) for no change

    i tried out the 'change' command for properties, but it only ask for the radius not the diameter...
    so need help on a lisp routine that can show/prompt/display diameter right beside the selected circle & if a new value is key in, the circle diameter changes instantly!

    thanks

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,089

    Default

    Code:
    (defun  c:test (/ cir ent z )
      (while (setq cir (ssget ":E:L" '((0 . "CIRCLE"))))
        (setq cur (* (cdr (assoc 40  (setq ent (entget (ssname cir 0))))) 2) )
        (redraw (ssname cir 0) 3)
        (setq
          z (cond
              ((getreal
                 (strcat
                   "\nEnter diameter[Enter to accept: <"
                   (rtos (setq z cur) 2 2)
                   ">: "
                   )
                 )
               )
              (z)
              )
          )
        (entmod
          (subst
            (cons 40 (/ z 2.0))
            (assoc 40 ent)
            ent
            )
          )
        )
      (princ)
      )
    Almost but not

  3. #3
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    5,985

    Default

    I didn't realize multiplying and dividing by 2 was so difficult.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,089

    Default

    Quote Originally Posted by alanjt View Post
    I didn't realize multiplying and dividing by 2 was so difficult.


    Could've been worse, the OP coud have ask to prompt for diameter value using Sapi.SpVoice

    "Enter Diameter or Enter to accept current" <female voice>

  5. #5
    Forum Deity Dadgad's Avatar
    Using
    AutoCAD 2012
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    3,131

    Wink sometimes, the best tool for setting a nail is a nail set

    Quote Originally Posted by alanjt View Post
    I didn't realize multiplying and dividing by 2 was so difficult.
    It could be, if you had your precision setting to 10 decimal places, I suppose, and were running custom made drill bits, or using a CNC laser. I use rather mundane metric sizes, and have precision in mms set to no decimal places,which makes it a lot easier. If you forget where you put the lisp, you can select a circle or circles, and find and change the diameter in the QUICKPROPERTIES palette, which I use all the time. Customize so that it shows whatever info you are after, or in the regular PROPERTIES dialog box, under DIAMETER. Using lisp for something like this seems a bit like an exterminator showing up in a tank for a termite problem, IMO. So many ways to go, and yet all roads lead to home.
    Volume and repetition do not validate opinions forged in the absence of thought.

  6. #6
    Full Member
    Using
    AutoCAD 2002
    Join Date
    Feb 2011
    Posts
    36

    Default

    Registered forum members do not see this ad.

    Code:
    (defun C:TEST11 ()
      (defun *error* (msg) (setq *error* nil) (princ))
      (setq cirdia (entsel "\nPick circle to change..."))
      (setq entdia (entget (car cirdia)))
      (setq diarad (cdr (assoc 40 entdia)))
      (setq diame (* diarad 2))
      (setq dia (getreal (strcat "\nEnter new diameter [current <"(rtos diame) ">]:")))
      (prompt "\nSelect circle to change...")
      (setq A (ssget (list (cons '0 "circle")(cons '40 diarad))))
      (setq B (sslength A))
      (setq X 0)
      (repeat B
        (setq NAME (ssname A X))
        (setq PARAM (entget NAME))
        (setq CHECK (cdr (assoc 0 PARAM)))
        (if (/= CHECK "CIRCLE")
          (progn (ssdel NAME A)
        (setq X (1- X)))
        ) ;_ end of if
        (setq X (1+ X))
      ) ;_ end of repeat
      (setq B (sslength A))
      (setq RAD (/ DIA 2))
      (setq NEWRAD (cons '40 RAD))
      (setq X 0)
      (repeat B
        (setq NAME (ssname A X))
        (setq PARAM (entget NAME))
        (setq PARAM (subst NEWRAD (assoc 40 PARAM) PARAM))
        (entmod PARAM)
        (setq X (1+ X))
      ) ;_ end of repeat
      (prompt (strcat "Selected object - Qty:"(rtos b) ""))
      (princ)
    )

Similar Threads

  1. Increase Arc/Circle Radius/Diameter
    By fcfcadd in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 23rd Nov 2012, 09:46 am
  2. Diameter circle with a centermark?
    By SFG13 in forum AutoCAD Beginners' Area
    Replies: 8
    Last Post: 26th Apr 2010, 09:45 pm
  3. Replies: 5
    Last Post: 3rd Dec 2009, 12:40 pm
  4. vl circle diameter
    By fuccaro in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 30th Jul 2009, 02:37 pm
  5. Block Not Prompting for Attribute Input
    By ksperopoulos in forum AutoCAD General
    Replies: 2
    Last Post: 14th Feb 2009, 10:49 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts