Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Update Title Block Lisp Problem

  1. #11
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Update Title Block Lisp Problem

    Thanks Peter, at this point I'll take any help I can get

    I've attached an example drawing. I'm not sure how much you can do with it though, as it does a ton of sql queries to get all the info. The page numbers are gotten through fields that just look at the layout tab name. The revs are gotten through an sql query.

    As far as the lisp goes, the main revision code starts at line 373. Please don't laugh at me for this crazy code.

    Thanks for your help Peter.
    Attached Files Attached Files

  2. #12
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,103
    Login to Give a bone
    0

    Default Re: Update Title Block Lisp Problem

    Quote Originally Posted by stusic View Post
    Thanks Peter, at this point I'll take any help I can get

    I've attached an example drawing. I'm not sure how much you can do with it though, as it does a ton of sql queries to get all the info. The page numbers are gotten through fields that just look at the layout tab name. The revs are gotten through an sql query.

    As far as the lisp goes, the main revision code starts at line 373. Please don't laugh at me for this crazy code.

    Thanks for your help Peter.
    <-- just because, but not for your crazy code.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #13
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Update Title Block Lisp Problem

    Okay, I'm a dummy again. I realized that the fields that make the value for the PAGE_NO attribute weren't updating. Once the layout was made active, the fields updated, so the lisp then worked correctly for those layouts that had been activated. Once I removed the fields, everything works fine each time. The problem I have now is to figure out how to update (or remove) the fields on every layout before this part of the code runs. I know I can use UPDATEFIELD, but that only works for the current layout - any way to updatre fields across all layouts?

  4. #14
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Update Title Block Lisp Problem

    OK Stusic, I wrote this general sql query like function for getting and changing Attributes in specified blocks in specified layouts with specified tagstrings and specified textstrings.

    All of the fields accept WildCards.

    Bon Apetite...

    P=



    Code:
    ;___________________________________________________________________________________________________________ 
    ; Written By: Peter Jamtgaard copyright 2015 All rights reserved
    ; Function to query a drawing database for blocks, layout, attribute tagstrings, and attribute textstrings
    ; Returning a list of sublists for the query (like an sql statement using 'Like')
    ;___________________________________________________________________________________________________________
    
    (defun C:Stusic ()
     (foreach lstOfSublists (BlockRecords "BORDER - B - LAND*" "3,4,5" "*" "*")
      (foreach lstSublist lstOfSublists
       (print lstSublist)
      )
      (print "")
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Changes the Revision attribute to be +1 on all layouts
    ;___________________________________________________________________________________________________________
    
    (defun C:Revisions (/ intRevision objAttribute strTextString)
     (foreach lstOfSublists (BlockRecords "BORDER - B - LAND*" "*" "REVISION" "*")
      (foreach lstSublist (cddr lstOfSublists)
       (and
        (setq objAttribute  (caddr lstSublist))
        (setq strTextString (vla-get-textstring objAttribute))
        (setq intRevision   (1+ (atoi strTextString)))
        (setq strTextString (itoa intRevision))
        (while (< (strlen strTextString) 2)(setq strTextString (strcat "0" strTextString)))
        (errortrap '(vla-put-textstring objAttribute strTextString))
       )
      )
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Changes the Drawnby attribute to be Fred Jones on sheets 3,4,5 in the BORDER - B - LAND* Blocks
    ;___________________________________________________________________________________________________________
    
    (defun C:Stusic3 ()
     (BlockFieldsPut "BORDER - B - LAND*" "3,4,5" "DRAWNBY" "*" "FRED JONES") 
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Returns a list of sublists for a specified BlockName, Layout, TagString and TextString as wildcards
    ;___________________________________________________________________________________________________________
    
    (defun BlockFields (strWCBlockName strWCLayout strWCTagString strWCTextString / lstOfSublists)
     (if (setq lstOfSublists (BlockRecords strWCBlockName strWCLayout strWCTagString strWCTextString))
      lstOfSublists   
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Changes a TextString for a specified BlockName, Layout, TagString and TextString as wildcards
    ;___________________________________________________________________________________________________________
    
    
    (defun BlockFieldsPut (strWCBlockName strWCLayout strWCTagString strWCTextString strNewTextString)
     (foreach lstOfSublists (BlockRecords strWCBlockName strWCLayout strWCTagString strWCTextString)
      (foreach lstSublist (cddr lstOfSublists)
       (vla-put-textstring (caddr lstSublist) strNewTextString)
      )
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Returns a list of sublists specified BlockName, Layout, TagString and TextString including as 
    ; (see Stusic above)
    ;___________________________________________________________________________________________________________
    
    
    
    (defun BlockRecords (strWCBlockName 
                         strWCLayout 
                         strWCTagString
                         strWCTextString
                         / 
                         lstAttributeSublists 
                         lstLayoutInformation 
                         lstReturn 
                         objItem 
                         objLayout 
                         objThisDrawing
                         strBlockName)
     (setq objThisDrawing   (vla-get-activedocument (vlax-get-acad-object)))
     (vlax-for objLayout (vla-get-layouts objThisDrawing)
      (vlax-for objItem (vla-get-block objLayout)
       (and (wcmatch (strcase (vla-get-name objLayout)) (strcase strWCLayout))
            (wcmatch (vla-get-objectname objItem) "AcDbBlockReference,AcDbMInsertBlock") 
            (wcmatch (strcase (setq strBlockName (vla-get-name objItem))) (strcase strWCBlockName))
            (setq lstAttributeSublists (AttributeSublists objItem))
            (setq lstAttributeSublists (AttributeFilter lstAttributeSublists strWCTagString strWCTextString))  
            (setq lstLayoutInformation (list "LAYOUT" (vla-get-name objLayout) objLayout))
            (setq lstBlockInformation  (list "BLOCK"  strBlockName objItem))
            (setq lstAttributeSublists (sortlistofsublistsbyitem  lstAttributeSublists 0))
            (setq lstAttributeSublists (cons lstBlockInformation  lstAttributeSublists)) 
            (setq lstAttributeSublists (cons lstLayoutInformation lstAttributeSublists))
            (setq lstReturn (cons lstAttributeSublists lstReturn))       
       )
      )
     )
     (reverse lstReturn)
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Sorts a list of sublists by a specified item
    ;___________________________________________________________________________________________________________
    
    
    (defun sortListofSublistsbyItem (lstOfSublists intItem)
     (vl-sort lstOfSublists '(lambda (X Y) (< (nth intItem X) (nth intItem Y))))
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Filters attributes by wildcard specification
    ;___________________________________________________________________________________________________________
    
    
    (defun AttributeFilter (lstOfSublists strWCTagString strWCTextString / lstOfSublists2 lstSublist)
     (foreach lstSublist lstOfSublists
      (if (and (wcmatch (strcase (car  lstSublist)) strWCTagString)
               (wcmatch (strcase (cadr lstSublist)) strWCTextString)
          )
       (setq lstOfSublists2 (cons lstSublist lstOfSublists2))
      )
     )
     (reverse lstOfSublists2)
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Returns a list of sublists for a block including each attribute 
    ; Each sublist includes '(strTagstring strTextstring objAttribute)
    ;___________________________________________________________________________________________________________
    
    
    (defun AttributeSubLists (objSelection / objAttribute)
     (if (= (vla-get-hasattributes objSelection) :vlax-true)
      (mapcar '(lambda (objAttribute) (list (strcase (vla-get-tagstring  objAttribute))
                                            (vla-get-textstring  objAttribute)
                                            objAttribute
                                      )
               )
               (vlax-invoke objSelection "getattributes")
      )
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Standard Error Trap
    ;___________________________________________________________________________________________________________
    
    
    (defun ErrorTrap (symFunction / objError result)
     (if (vl-catch-all-error-p
          (setq objError (vl-catch-all-apply
                         '(lambda (X)(set X (eval symFunction)))
                          (list 'result))))
      nil
      (if result result 'T)
     )
    )
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2015-05-30 at 07:38 AM.
    AutomateCAD

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 5
    Last Post: 2013-05-18, 01:44 PM
  2. update title block in multiple tabs
    By peter.shoemark in forum AutoLISP
    Replies: 1
    Last Post: 2011-11-14, 02:48 PM
  3. Update Title Block data in numerous drawing files
    By rer2003mcbs.66431 in forum AutoLISP
    Replies: 3
    Last Post: 2007-05-29, 01:58 PM
  4. How to fill in a Title Block w/ Lisp
    By GreyHippo in forum AutoLISP
    Replies: 24
    Last Post: 2006-01-26, 05:59 PM
  5. Replies: 9
    Last Post: 2005-01-25, 02:31 AM

Posting Permissions

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