ATTEDIT & DDATTE REDEFINITION AGAIN

Discussion in 'AutoCAD' started by thenov, Oct 18, 2004.

  1. thenov

    thenov Guest

    I want to REDEFINE the ATTEDIT and DDATTE commands to do some things BEFORE running these command. I HAVE been able to get the ATTEDIT command REDEFINED but it only works the 1st time it is run. After that is reverts back to the standard ATTEDIT command. Furthermore it seems as if the ATTEDIT and DDATTE conflict. If I REDEFINE 1 the other reverts back to the standard command. Has anyone ever been abel to SUCCESSFULLY REDEFINE both the ATTEDIT and DDATTE commands simultaneously? Any thoughts or ideas this subject would be greatly appreciated. Thanks!
     
    thenov, Oct 18, 2004
    #1
  2. thenov

    Jeff Mishler Guest

    I dunno........the following works for me in 2002....

    (command "undefine" "ddatte")
    (command "undefine" "attedit")
    (defun c:ddatte ()
    (alert "\nCommand DDATTE undefined....")
    )
    (defun c:attedit ()
    (alert "\nCommand ATTEDIT undefined....")
    )
     
    Jeff Mishler, Oct 18, 2004
    #2
  3. thenov

    thenov Guest

    The code you supply DOES work. However as soon as I use either the DDATTE or ATTEDIT command in the REDEFINED version it BREAKS the redefinition and only works once.
     
    thenov, Oct 18, 2004
    #3
  4. thenov

    OLD-CADaver Guest

    As was pointed out in the previous thread, those commands are defined in an ARX that must be unloaded first. Your problem will continue, if you subsequently reload that ARX by calling those commands in the redefinition.
     
    OLD-CADaver, Oct 18, 2004
    #4
  5. thenov

    Jeff Mishler Guest

    Post the code you are using......it will help to determine what steps you
    are taking.....please don't describe it as you've already done that. I have
    modified the sample code to run the original attedit and it works just
    fine......
     
    Jeff Mishler, Oct 18, 2004
    #5
  6. thenov

    thenov Guest

    Since these commands are ARX and not core AutoCAD I can NOT do what I want. Again I just want to redefine them to do some stuff BEFORE I call them in the REDEFINITION. According to what you are saying this CAN'T be done. I have tried unloading the ARX in the REDEFINITION but the problem persists. Sounds like I am out of luck. Thanks for your help.
     
    thenov, Oct 18, 2004
    #6
  7. thenov

    thenov Guest

    (command "undefine" "attedit")
    (defun C:ATTEDIT (/ noll filter ss idx ename elist kind)
    (princ "\nOCSD ATTEDIT - OCSD Tagging Program Blocks will be Filtered Out!") ; print message
    (defun noll (ss / i d ename) ; remove objects on locked layers
    (setq i 0) ; set counter
    (setq d 0) ;set counter
    (while (and ss (setq ename (ssname ss i))) ; while a sel set
    (if (acet-layer-locked (cdr (assoc 8 (entget ename)))) ; if on a locked layer
    (progn ; begin remove
    (ssdel ename ss) ; remove ent from sel set
    (setq d (1+ d)) ; add 1 to removed counter
    ) ; end remove
    (setq i (1+ i)) ; add 1 to sel set counter
    ) ; end if a locked layer
    ) ; end while a sel set
    (if (/= 0 d) ; if some were removed
    (princ (acet-str-format "%1 %2 on a locked layer.\n" d ; print messsage
    (if (< 1 d) "were" "was"))) ; print message
    ) ; end is some were found
    ss ; get next in sel set
    ) ; end noll defun
    (acet-error-init '(("CMDECHO" 0) T)) ; if error reset command echo
    (setq filter (list (cons 410 ; start make sel set filter
    (if (and (= 0 (getvar "TILEMODE")) (/= 1 (getvar "CVPORT"))) "Model" ; if model space
    (getvar "CTAB") ; get layout tab
    ) ; end and
    ) ; end if model space
    '(-4 . "<NOT") ; begin not
    '(-4 . "<AND") ; begin and
    '(0 . "INSERT") ; block insert
    '(2 . "Valve_Tag_Info,Equip_Tag_Info,Instr_Tag_Info,Instr_Tag_Info_Ns") ; OCSD blocks
    '(-4 . "AND>") ; end and
    '(-4 . "NOT>") ; end not
    '(-4 . "<OR") ; begin or
    '(-4 . "<AND") ; begin and
    '(0 . "INSERT") ; any block insert only
    '(66 . 1) ; block with attributes only
    '(-4 . "AND>") ; end and
    '(-4 . "OR>") ; end or
    ) ; end filter list
    ) ; setq for filter
    (if (not (and (= 1 (logand 1 (getvar "PICKFIRST"))) (setq ss (noll (ssget "_I" filter))))) ; if not locked layer and pass filter
    (setq ss (ssget "_:L" filter)) ; get sele set
    ) ; end if
    (if ss ; if a selection set
    (progn ; begin
    (setq idx -1) ; set index
    (acet-ui-progress "Editing:" (sslength ss)) ; dsiaply progress bar
    (sssetfirst) ; get first item
    (redraw) ; redraw the screen
    (while (setq ename (ssname ss (setq idx (1+ idx)))) ; begin while an entity
    (redraw ename 3) ; redraw entity as highlighted
    (redraw) ; redraw screen
    (setq elist (entget ename) kind (cdr (assoc 0 elist))) ; get type of entity
    (command "._attributeedit.ddatte" ename) ; call command from ARX
    (entupd ename) ; midufy entiity
    (redraw ename 4) ; redraw entity as normal
    (acet-ui-progress -1) ; set progress percentage
    ) ; end while an entity
    (acet-ui-progress) ; update progress bar
    (sssetfirst nil ss) ; set first to nil
    ) ; end progn
    ) ; end if a sel set
    (acet-error-restore) ; on error restore settings
    (princ "\nOCSD ATTEDIT - Complete.") ; print complete message
    (princ) ; exit cleanly
    ) ; end defun
     
    thenov, Oct 18, 2004
    #7
  8. thenov

    thenov Guest

    (command "undefine" "attedit")
    (defun C:ATTEDIT (/ noll filter ss idx ename elist kind)
    (princ "\nOCSD ATTEDIT - OCSD Tagging Program Blocks will be Filtered Out!") ; print message
    (defun noll (ss / i d ename) ; remove objects on locked layers
    (setq i 0) ; set counter
    (setq d 0) ;set counter
    (while (and ss (setq ename (ssname ss i))) ; while a sel set
    (if (acet-layer-locked (cdr (assoc 8 (entget ename)))) ; if on a locked layer
    (progn ; begin remove
    (ssdel ename ss) ; remove ent from sel set
    (setq d (1+ d)) ; add 1 to removed counter
    ) ; end remove
    (setq i (1+ i)) ; add 1 to sel set counter
    ) ; end if a locked layer
    ) ; end while a sel set
    (if (/= 0 d) ; if some were removed
    (princ (acet-str-format "%1 %2 on a locked layer.\n" d ; print messsage
    (if (< 1 d) "were" "was"))) ; print message
    ) ; end is some were found
    ss ; get next in sel set
    ) ; end noll defun
    (acet-error-init '(("CMDECHO" 0) T)) ; if error reset command echo
    (setq filter (list (cons 410 ; start make sel set filter
    (if (and (= 0 (getvar "TILEMODE")) (/= 1 (getvar "CVPORT"))) "Model" ; if model space
    (getvar "CTAB") ; get layout tab
    ) ; end and
    ) ; end if model space
    '(-4 . "<NOT") ; begin not
    '(-4 . "<AND") ; begin and
    '(0 . "INSERT") ; block insert
    '(2 . "Valve_Tag_Info,Equip_Tag_Info,Instr_Tag_Info,Instr_Tag_Info_Ns") ; OCSD blocks
    '(-4 . "AND>") ; end and
    '(-4 . "NOT>") ; end not
    '(-4 . "<OR") ; begin or
    '(-4 . "<AND") ; begin and
    '(0 . "INSERT") ; any block insert only
    '(66 . 1) ; block with attributes only
    '(-4 . "AND>") ; end and
    '(-4 . "OR>") ; end or
    ) ; end filter list
    ) ; setq for filter
    (if (not (and (= 1 (logand 1 (getvar "PICKFIRST"))) (setq ss (noll (ssget "_I" filter))))) ; if not locked layer and pass filter
    (setq ss (ssget "_:L" filter)) ; get sele set
    ) ; end if
    (if ss ; if a selection set
    (progn ; begin
    (setq idx -1) ; set index
    (acet-ui-progress "Editing:" (sslength ss)) ; dsiaply progress bar
    (sssetfirst) ; get first item
    (redraw) ; redraw the screen
    (while (setq ename (ssname ss (setq idx (1+ idx)))) ; begin while an entity
    (redraw ename 3) ; redraw entity as highlighted
    (redraw) ; redraw screen
    (setq elist (entget ename) kind (cdr (assoc 0 elist))) ; get type of entity
    (command "._attributeedit.ddatte" ename) ; call command from ARX
    (entupd ename) ; midufy entiity
    (redraw ename 4) ; redraw entity as normal
    (acet-ui-progress -1) ; set progress percentage
    ) ; end while an entity
    (acet-ui-progress) ; update progress bar
    (sssetfirst nil ss) ; set first to nil
    ) ; end progn
    ) ; end if a sel set
    (acet-error-restore) ; on error restore settings
    (princ "\nOCSD ATTEDIT - Complete.") ; print complete message
    (princ) ; exit cleanly
    ) ; end defun
     
    thenov, Oct 18, 2004
    #8
  9. thenov

    Jeff Mishler Guest

    try replacing this line:
    (command "._attributeedit.ddatte" ename) ; call command from ARX

    with this:
    (initdia)
    (command "_.attedit" ename)
     
    Jeff Mishler, Oct 18, 2004
    #9
  10. thenov

    thenov Guest

    Thanks for the response but it did not work. That is what I originally had.
     
    thenov, Oct 19, 2004
    #10
  11. thenov

    thenov Guest

    So you are telling me that I am SOL since there commands come from an ARX and are not core AutoCAD commands.
     
    thenov, Oct 19, 2004
    #11
  12. thenov

    OLD-CADaver Guest

    No not at all, you just can't re-call that same ARX in your re-definition because it will over-write your re-definition. That said you have a couple of options, (the gurus will show even more I'm sure). One option would be instead of redefining, make a new command function (with a new name, using the ARX) to accomplish your task, then replace the old function name with the new one in your menu and PGP. Another option is re-build a new ATTEDIT dialog interface so that you don't have to re-call the program's.
     
    OLD-CADaver, Oct 19, 2004
    #12
  13. thenov

    Jeff Mishler Guest

    OK, ina addition to the last modification, add this to the beginning of your
    code....your code works everytime for me with these changes.....

    (if (not (member (arx) (list "attedit.arx")))
    (arxload "attedit.arx")
    )
    (command "undefine" "attedit")
     
    Jeff Mishler, Oct 19, 2004
    #13
  14. thenov

    OLD-CADaver Guest

    ahhh, cool, didn't think about undefining it every time. It was one of my linear days.
     
    OLD-CADaver, Oct 19, 2004
    #14
  15. thenov

    thenov Guest

    Thanks Jeff! You the Man!. My only remaining glitch is that I have to load my program twice in order for it to work. If I only load it once the ATTEDIT reverts back to the standard AutoCAD command. Either way many thanks! I owe you one. By the way this method works fine for BOTH ATTEDIT and DDATTE.
     
    thenov, Oct 20, 2004
    #15
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.