+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Full Member Millsy29's Avatar
    Computer Details
    Millsy29's Computer Details
    Operating System:
    Windows xp professional
    Using
    MEP 2009
    Join Date
    Jul 2010
    Location
    Manchester
    Posts
    28

    Default Automatically Update Title block lisp HELP!

    Registered forum members do not see this ad.

    Hi everyone,

    i have a lisp routine that i would like to alter to become more automated.

    ;* -------------------------- SUBROUTINE ------------------------------
    (defun NEWSYSTEM ()
    (cond
    ((= tagname "DRGNUM")(setq newdata drawingno))
    ((= tagname "CADFILE")(setq newdata cadfile))
    ((= tagname "REV")(setq newdata rev))
    (T nil)
    )
    )
    ;* -------------------------- MAIN PROGRAM ------------------------------

    (defun C:UPN (/ cadfile cadfilelen drawingno drawingrev drawingrevlen
    rev field savefilename tagname newdata)
    (setq cadfile (getvar "DWGNAME"))
    (setq cadfilelen (strlen cadfile))
    (setq drawingno (substr cadfile 1 (- cadfilelen 6)))
    (setq drawingrev (substr cadfile 1 (- cadfilelen 4)))
    (setq drawingrevlen (strlen drawingrev))
    (setq rev (substr drawingrev drawingrevlen))
    (setq field (entget (car (nentsel))))
    (setq savefilename (cdr (assoc 1 field)))
    (setq tagname (cdr (assoc 2 field)))
    (NEWSYSTEM)
    (setq field (subst (cons 1 newdata) (assoc 1 field) field))
    (entmod field);modify database
    (entupd (cdr (caddr field)));update entity without regen
    (princ)
    )

    this allows me to select the title block attributes and change accordingly to the file name. (not trying to teaching you to suck eggs)

    Now what i want it to do as all the title block is to search for block "A0-Sheet" "A1-Sheet" "A3-Sheet" then find "cadfile" attribute and automatically change and so of for the drawing no. and rev.

    Can anybody help me with this?

    Millsy

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    Haven't got anything to test it on...

    Code:
    (defun c:upn ( / ss )
      ;; © Lee Mac 2010
    
      (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "A#-Sheet") (66 . 1))))
        (
          (lambda ( i / file l dwg rev e el )
            (setq file (getvar 'DWGNAME) l (strlen file))
    
            (setq dwg (substr file 1 (- l 6))
                  rev (substr file (- l 4) 1))
    
            (while (setq e (ssname ss (setq i (1+ i))))
              (while
                (not
                  (eq "SEQEND"
                    (cdr
                      (assoc 2
                        (setq el
                          (entget
                            (setq e
                              (entnext e)
                            )
                          )
                        )
                      )
                    )
                  )
                )
                (cond
                  (
                    (eq "DRGNUM" (cdr (assoc 2 el)))
    
                    (Update (SubstDXF 1 dwg el))
                  )
                  (
                    (eq "CADFILE" (cdr (assoc 2 el)))
    
                    (Update (SubstDXF 1 file el))
                  )
                  (
                    (eq "REV" (cdr (assoc 2 el)))
    
                    (Update (SubstDXF 1 rev el))
                  )
                )
              )
            )
          )
          -1
        )
      )
    
      (princ)
    )
    
    (defun SubstDXF ( code value elist )
      ;; © Lee Mac 2010
      (entmod
        (subst
          (cons code value) (assoc code elist) elist
        )
      )
    )
    
    (defun Update ( elist )
      ;; © Lee Mac 2010
      (entupd
        (cdr (assoc -1 elist))
      )
    )
    Last edited by Lee Mac; 15th Jul 2010 at 05:15 pm.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Full Member Millsy29's Avatar
    Computer Details
    Millsy29's Computer Details
    Operating System:
    Windows xp professional
    Using
    MEP 2009
    Join Date
    Jul 2010
    Location
    Manchester
    Posts
    28

    Default

    it works the cad file changes and drawing no. changes but the rev comes out as - instead of A could this be its looking at the wrong part of the file name?

    Example file name below:
    302039-01M0201-003-A.dwg

    Also this comes up at the end????

    ; error: An error has occurred inside the *error* functiontoo many arguments

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    Quote Originally Posted by Millsy29 View Post
    it works the cad file changes and drawing no. changes but the rev comes out as - instead of A could this be its looking at the wrong part of the file name?

    Example file name below:
    302039-01M0201-003-A.dwg

    Also this comes up at the end????

    ; error: An error has occurred inside the *error* functiontoo many arguments
    Yeah, I was about to ask for an example filename actually

    Not sure about the *error* - that is something to do with an unlocalised error handler in another routine you are running as mine does not have an error handler.

    Updated code.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Full Member Millsy29's Avatar
    Computer Details
    Millsy29's Computer Details
    Operating System:
    Windows xp professional
    Using
    MEP 2009
    Join Date
    Jul 2010
    Location
    Manchester
    Posts
    28

    Default

    BEAUITFUL PATRICK!!!!



    WORKS LIKE A CHARM!

    thanks a million

    Millsy

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    Registered forum members do not see this ad.

    Excellent - nice one
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Update title block attributes in multiple drawings
    By t357 in forum AutoLISP, Visual LISP & DCL
    Replies: 142
    Last Post: 12th Dec 2016, 09:38 am
  2. Lisp routine use csv to update title block attributes - on ctab
    By HRae in forum AutoLISP, Visual LISP & DCL
    Replies: 116
    Last Post: 16th Feb 2014, 12:06 am
  3. Update the attribute title block
    By andy_gs in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 4th May 2010, 04:22 am
  4. can you set tables to automatically update?
    By zoso190 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 25th Jun 2009, 04:18 am
  5. Title Block Update
    By eddablin in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 18th Apr 2009, 01:35 pm

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