Verify Attribute

Discussion in 'AutoCAD' started by ghiggins457, Mar 3, 2004.

  1. ghiggins457

    ghiggins457 Guest

    Bob,
    Yes I did and I am getting the same thing. It is telling me that there is no block by that name and there is one in the drawing by that name.
     
    ghiggins457, Mar 4, 2004
    #21
  2. ghiggins457

    ECCAD Guest

    Greg,
    I'm working on it..
    Bob
     
    ECCAD, Mar 4, 2004
    #22
  3. (while (setq ent (entget (entnext (cdr (car ent)))))

    entget will puke when entnext returns nil.

    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Mar 4, 2004
    #23
  4. Forgot to paste it in:

    (defun c:unverify (/ bname ent);revised to use standard lisp vs
    AvtiveX
    (initdia 1)
    (setq bname (getstring t "\nBlock name to reset 'verify'
    property?:"))
    (if (tblsearch "block" bname)
    (progn
    (setq ent (tblobjname "block" bname))
    (while ent
    (setq ent (entget ent))
    (if (and
    (= (cdr (assoc 0 ent)) "ATTDEF")
    (= (logand (cdr (assoc 70 ent)) 4) 4)
    )
    (progn
    (setq ent (subst (cons 70 (- (cdr (assoc 70 ent)) 4))
    (assoc 70 ent)
    ent
    )
    )
    (entmod ent)
    )
    )
    (setq ent (entnext (cdr (car ent))))
    )
    )
    (princ "\nInvalid block name, try again.....")
    )
    (princ)
    )
    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Mar 4, 2004
    #24
  5. ghiggins457

    ECCAD Guest

    Greg,
    I modified Jeff's routine:
    ;; Jeff's routine, modified..
    ;; Bob Shaw
    ;;
    ;; Define DXF function
    ;;
    (defun dxf (code elist)
    (cdr (assoc code elist))
    ); end function dxf
    ;;
    (defun c:unverify ();revised to use standard lisp vs AvtiveX
    (setq ss (ssget "X")); get all the drawing entities
    (if (/= ss nil)
    (progn
    (setq c 0 b (sslength ss))
    (repeat b
    (setq ent (ssname ss c))
    (setq ent (entget ent))
    ;;
    ;; Check out BLOCKS only..
    ;;
    (if (and
    (= "INSERT" (cdr (assoc 0 ent))) ; case of BLOCKS
    (/= (cdr (assoc 66 ent)) nil); with Attrib's following
    ); end and
    (progn
    (setq en (entget (entnext (dxf -1 ent)))); sub-entity
    (setq abn (cdr (assoc 0 en))); name of item
    (if (= "ATTRIB" abn)
    (progn
    (while
    (and
    (setq ent (entget (entnext (cdr (car ent)))))
    (/= (cdr (assoc 0 ent)) "SEQEND"))
    (setq ent (subst (cons 70 0)(assoc 70 ent) ent))
    (entmod ent)
    ); end while
    ); end progn
    ); end if
    ); end progn
    ); end if
    (setq c (+ c 1))
    ); end repeat
    ); end progn
    ); end if
    (princ)
    ); end function
    ------------
    To mofify your blocks, open a blank drawing, and insert all the offending blocks. Then, load this lisp and type: unverify
    at the command prompt. When done, do a 'list' on the blocks, and look at the 'flags' portion of the Attributes listed, they should show all 'normal'. If happy, Wblock the blocks back to the disk.

    Next, we need to work on your .mns file..
    Bob
     
    ECCAD, Mar 4, 2004
    #25
  6. ghiggins457

    Jeff Mishler Guest

    Good catch, Ken. This made me wonder why I didn't see any errors when I
    tested it. Turns out another user had been on my computer and changed my
    command lines down to 2. I hadn't noticed that and, of course, the error
    scrolled out of view.....but the routine still worked.

    Thanks,
    Jeff
     
    Jeff Mishler, Mar 4, 2004
    #26
  7. ghiggins457

    ECCAD Guest

    Jeff, Ken,
    The tblobject returns 'block' info, not the attrib (70 . 4) ..
    So, I reworked the routine to just work on inserts..works fine in R2002. We'll see if it blows in LT.
    Bob
     
    ECCAD, Mar 4, 2004
    #27
  8. ghiggins457

    Jeff Mishler Guest

    Bob,
    I step through the block definition (entnext) until an attribute
    definition is found and then change that. Mine works, with Ken's
    suggestion, in R2002. I have no idea why this doesn't work in LT, I've
    never used, or even seen, LT.

    Yours will only find the attribute reference and will do nothing for
    future insertions, I believe. If he wants to change the source
    drawing(s), then my code would need to be changed to get the actual
    attdef entities in the drawing instead of the block def.

    Does LT use the block table? Other than the drawing not having the block
    he's trying to fix, I can't think of any other reason for it to return
    "block not found"......

    Jeff

    R2002. We'll see if it blows in LT.
     
    Jeff Mishler, Mar 4, 2004
    #28
  9. ghiggins457

    ECCAD Guest

    Jeff,
    I tried your example, and it didn't seem to return anything but (70 . 0) for any sub-entity, gave me a message about numberp or such. So, I just went to the block inserts themselves, modified, wblocked. Should fix it. He E-Mailed and said it is OK, but is woried about further inserts..

    we'll get to the bottom of it.

    Bob
     
    ECCAD, Mar 4, 2004
    #29
  10. ghiggins457

    Jeff Mishler Guest

    Bob,
    The "numberp" you were getting was due to the way I was (entget
    (entnext))'ing, as Ken pointed out.
    As modified, it will only affect attdefs that actually have the verify
    property enabled.

    How do you wblock the "modified" block? It seems to me you'd need to
    explode it first and edit the attdef, not the attref.....which is what
    mine was doing in the first place by modifying the block
    definition......granted, it doesn't change the value of any peviously
    inserted block's attributes, but they don't matter since they are
    already there.

    Try exploding one of the blocks your routine changes......the exploded
    attribute definition will be back to a "verify" mode........

    Does my logic make any sense?

    Jeff


    0) for any sub-entity, gave me a message about numberp or such. So, I
    just went to the block inserts themselves, modified, wblocked. Should
    fix it. He E-Mailed and said it is OK, but is woried about further
    inserts..
     
    Jeff Mishler, Mar 5, 2004
    #30
  11. ghiggins457

    ECCAD Guest

    Jeff,
    Much to my suprise, yup, exploding the block reveals that the ATTDEF reverts back to 'Verify' flag. Bummer. I guess I'm more used to just batch processing the darn blocks, and messing with the 'base' definition .dwg. I guess we'll have to go into the table to modify them. Painful. Tomorrow.

    Bob
     
    ECCAD, Mar 5, 2004
    #31
  12. ghiggins457

    Jeff Mishler Guest

    OK, Bob,
    Here's my revised and well commented lisp. It does work in R2002. If it
    continues to not function with LT, then the add-on must not support some
    of the normal lisp functions. I've looked at the website for the add-on
    Greg said he's using and they don't mention anything about unsupported
    functions, so without being able to actually try it this will be about
    the best I can provide......

    To "fix" the drawings on disk, wblock out the block (the block by name,
    not selected entities.....) after running the lisp.

    I just had another thought......if all attributes are wanting to be
    revised in all blocks, no operator entry is required and we could
    eliminate one source of possible error. I've included a second lisp that
    does this......

    Jeff

    (defun c:unverify (/ bname ent) ;revised to use standard lisp vs
    ActiveX
    (initdia 1) ;don't allow null input
    (setq bname (getstring t "\nBlock name to reset 'verify' property?:
    "))
    (if (tblsearch "block" bname) ;check to see if it's a valid block
    name
    (progn ;it is valid, carry on
    (setq ent (tblobjname "block" bname)) ;get the block definition
    (while ent ;go until ent is nil
    (setq ent (entget ent)) ;step through each entity in the block
    (if (and ;look for attribute entity
    (= (cdr (assoc 0 ent)) "ATTDEF")
    (= (logand (cdr (assoc 70 ent)) 4) 4) ;is it set to verify?
    )
    (progn ;OK, it is an attribute and it's verify property is set
    ;subtract 4 from the dxf code 70 value, leaving other values
    intact,
    ;and subst it back in
    (setq ent (subst (cons 70 (- (cdr (assoc 70 ent)) 4))
    (assoc 70 ent) ent))
    (entmod ent) ;change it!
    ) ;end progn
    ) ;end if
    (setq ent (entnext (cdr (car ent)))) ;get the next entity in the block
    definition
    ) ;end while
    ) ;end progn
    (princ "\nInvalid block name, try again.....") ;block name not
    found in the table
    ) ;end if
    (princ) ;exit quietly
    ) ;end function


    (defun c:unverify-ALL (/ ent) ;revised to use standard lisp vs ActiveX
    (while (setq ent (tblnext "block" (not ent)))
    (setq ent (cdr (assoc -2 ent)));get the block definition
    (while ent ;go until ent is nil
    (setq ent (entget ent)) ;step through each entity in the block
    (if (and ;look for attribute entity
    (= (cdr (assoc 0 ent)) "ATTDEF")
    (= (logand (cdr (assoc 70 ent)) 4) 4) ;is it set to verify?
    )
    (progn ;OK, it is an attribute and it's verify property is set
    ;subtract 4 from the dxf code 70 value, leaving other values
    intact,
    ;and subst it back in
    (setq ent (subst (cons 70 (- (cdr (assoc 70 ent)) 4))
    (assoc 70 ent) ent))
    (entmod ent) ;change it!
    ) ;end progn
    ) ;end if
    (setq ent (entnext (cdr (car ent)))) ;get the next entity in the block
    definition
    ) ;end while
    (setq ent t)
    ) ;end while
    (princ) ;exit quietly
    ) ;end function



    reverts back to 'Verify' flag. Bummer. I guess I'm more used to just
    batch processing the darn blocks, and messing with the 'base' definition
    ..dwg. I guess we'll have to go into the table to modify them. Painful.
    Tomorrow.
     
    Jeff Mishler, Mar 5, 2004
    #32
  13. ghiggins457

    ghiggins457 Guest

    Jeff,
    Thanks man. That worked. I did the unverify-ALL routine and it worked fine and when I wblocked the block and inserted it into a new drawing, the verify routine was turned off. Thanks everyone for your help. I appreciate it. Maybe one day, I'll be able to return the favor.

    Greg
     
    ghiggins457, Mar 5, 2004
    #33
  14. ghiggins457

    Jeff Mishler Guest

    I'm glad we finally got it!

    Happy to have been of help,
    Jeff

    fine and when I wblocked the block and inserted it into a new drawing,
    the verify routine was turned off. Thanks everyone for your help. I
    appreciate it. Maybe one day, I'll be able to return the favor.
     
    Jeff Mishler, Mar 5, 2004
    #34
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.