Can someone please help

Discussion in 'AutoCAD' started by WashCaps37, Oct 5, 2004.

  1. WashCaps37

    WashCaps37 Guest

    For some reason when using this routine it does not keep the last user inserted distance so everytime the command is activated the user would have to re-insert the distance. What would need to be added to so the user does not have to keep inserting the same distance every time the command is activated?

    Thanks for everyone's help!!!!!

    ; Function creates an offset to either side of the selected entity
    ; and erases the original.
    ;
    (defun C:DOF()
    (if(= parof nil)
    (setq offs(/ (getvar "viewsize") 10))
    )
    (princ "\nCurrent offset <")(princ offs)
    (setq answer(getdist ">: "))
    (if (/= answer 0.0)
    (setq offs answer)
    )
    (if(setq eset(ssget))
    (progn
    (setq cntr 0)
    (while (< cntr (sslength eset))
    (setq en(ssname eset cntr))
    (setq enlist(entget en))
    (setq pt(cdr(assoc 10 enlist)))
    (setq an(angle pt (cdr(assoc 11 enlist))))
    (if(= "LINE" (cdr(assoc 0 enlist)))
    (progn
    (command "offset" offs en
    (polar pt (+ an(/ pi 2.0)) 600.0)
    en
    (polar pt (- an(/ pi 2.0)) 600.0)
    ""
    )
    (entdel en)
    )
    )
    (setq cntr(+ cntr 1))
    )
    )
    (alert "No objects selected!")
    )
    (princ "\n ...DOF Complete! \n ")
    (princ)
    )
     
    WashCaps37, Oct 5, 2004
    #1
  2. WashCaps37

    Tom Smith Guest

    You need a global variable to store the last distance. You also need to
    localize all the other variables. Below I've used parof as the global.

    (defun C:DOF(/ offs eset cntr en enlist pt an)
    (if parof
    (setq offs parof)
    (setq offs(/ (getvar "viewsize") 10)))
    (princ "\nCurrent offset <")(princ offs)
    (initget 2)
    (setq offs (getdist ">: "))
    (if(setq eset(ssget))
    (progn
    (setq cntr 0)
    (while (< cntr (sslength eset))
    (setq en(ssname eset cntr))
    (setq enlist(entget en))
    (setq pt(cdr(assoc 10 enlist)))
    (setq an(angle pt (cdr(assoc 11 enlist))))
    (if(= "LINE" (cdr(assoc 0 enlist)))
    (progn
    (command "offset" offs en
    (polar pt (+ an(/ pi 2.0)) 600.0)
    en
    (polar pt (- an(/ pi 2.0)) 600.0)
    "")
    (entdel en)
    (setq parof offs)))
    (setq cntr(+ cntr 1))))
    (alert "No objects selected!"))
    (princ "\n ...DOF Complete! \n ")
    (princ))
     
    Tom Smith, Oct 5, 2004
    #2
  3. WashCaps37

    WashCaps37 Guest

    Tom,

    Thank you for helping with this particular problem. Your revised routine works the first time but when I activate the command again I am prompeted to select objects and after I select the object(s) to offset I receive this message in the command line.

    <Entity name: 7EF6CEA8>

    can you help me resolve this issue?

    Thanks again for all your help.
     
    WashCaps37, Oct 5, 2004
    #3
  4. WashCaps37

    Tom Smith Guest

    I only got that if the selection included things that weren't lines. The
    simplest fix is to filter the selection.

    (defun C:DOF(/ offs eset cntr en enlist pt an)
    (if parof
    (setq offs parof)
    (setq offs(/ (getvar "viewsize") 10)))
    (princ "\nCurrent offset <")(princ offs)
    (initget 2)
    (setq offs (getdist ">: "))
    (if (setq eset (ssget '((0 . "LINE"))))
    (progn
    (setq cntr 0)
    (while (< cntr (sslength eset))
    (setq
    en (ssname eset cntr)
    enlist (entget en)
    pt (cdr(assoc 10 enlist))
    an (angle pt (cdr(assoc 11 enlist))))
    (command "offset" offs en
    (polar pt (+ an(/ pi 2.0)) 600.0)
    en
    (polar pt (- an(/ pi 2.0)) 600.0)
    "")
    (entdel en)
    (setq cntr(+ cntr 1)))
    (setq parof offs))
    (alert "No objects selected!"))
    (princ "\n ...DOF Complete! \n ")
    (princ))
     
    Tom Smith, Oct 5, 2004
    #4
  5. WashCaps37

    WashCaps37 Guest

    Tom,

    I still have the same issue.
    <Entity name: 7EF6CEA8> now I occasionally receive <Entity name: 7EF5DE98> and <Entity name: 7EF68E98>. I'm not sure what this all means. I am just trying to offset lines.
    I'm not sure if it will make a difference or not but I am running ACAD 2004.
     
    WashCaps37, Oct 6, 2004
    #5
  6. WashCaps37

    Tom Smith Guest

    Sorry, I wasn't accomodating the user hitting return to accept the default
    distance. Also, I added an undo group so the whole operation cane be undone
    at once.

    (defun C:DOF(/ offs answer eset cntr en enlist pt an)
    (command "undo" "begin")
    (if parof
    (setq offs parof)
    (setq offs(/ (getvar "viewsize") 10)))
    (princ "\nCurrent offset <")(princ offs)
    (initget 2)
    (setq answer (getdist ">: "))
    (if answer
    (setq offs answer))
    (if (setq eset (ssget '((0 . "LINE"))))
    (progn
    (setq cntr 0)
    (while (< cntr (sslength eset))
    (setq
    en (ssname eset cntr)
    enlist (entget en)
    pt (cdr(assoc 10 enlist))
    an (angle pt (cdr(assoc 11 enlist))))
    (command "offset" offs en
    (polar pt (+ an(/ pi 2.0)) 600.0)
    en
    (polar pt (- an(/ pi 2.0)) 600.0)
    "")
    (entdel en)
    (setq cntr(+ cntr 1)))
    (setq parof offs))
    (alert "No objects selected!"))
    (princ "\n ...DOF Complete! \n ")
    (command "undo" "end")
    (princ))
     
    Tom Smith, Oct 6, 2004
    #6
  7. WashCaps37

    WashCaps37 Guest

    That did it Tom. Incredible!!!!! I appreciate you helping me out.
     
    WashCaps37, Oct 6, 2004
    #7
  8. WashCaps37

    Tom Smith Guest

    No prob!
     
    Tom Smith, Oct 6, 2004
    #8
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.