Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Update Title Block Lisp Problem

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

    Default Update Title Block Lisp Problem

    Good Afternoon!

    I have a lisp that I use to update our title blocks. I'm trying to add a way to update each layout with the correct rev level (that I'm getting through an sql query). I've got just about everything, but I can't figure out how to update each page's attribute with the correct rev level Can someone show me how to update these? I appreciate any help

    This is what I use to get the rev level:

    Code:
    (if
        (and
          (setq
            ss (ssget "_x" '((0 . "INSERT") (2 . "*BORDER*") (66 . 1)))
          )
        )
         (progn
    
    
           ;; Get page_no attribute values from blocks
           (vlax-for x (setq ss (setq acDoc
                                       (vla-get-activeselectionset
                                         (vla-get-activedocument
                                           (vlax-get-acad-object)
                                         )
                                       )
                                )
                       )
             (foreach att (vlax-invoke x 'getattributes)
               (if (= "PAGE_NO" (vla-get-tagstring att))
                 (progn
                   (setq pageNo (atoi (vla-get-textstring att)))
                   (setq data (cons (cons x pageNo) data))
                 )
               )
             )
           )
    
    
    ;; Put revision attribute values into blocks - separated out because elvis has page numbers and descriptions as one record in his db. derp.
    (foreach item data
    
    
    ;;; for drawings that can have more than one page number
    (cond
      ((or
         (= abb "PD")
         (= abb "WD")
         (= abb "CHL"))
       (setq fld11	(strcat "SELECT level FROM revisions WHERE (item LIKE '%"fld1"%') AND (document = '"fld7">pg "(vl-princ-to-string (cdr item))"') ORDER BY level DESC")))
    
    
    ;;; for drawings that only have one page  
      ((or
         (= abb "HL")
         (= abb "CL")
         (= abb "LP"))
       (setq fld11 (strcat "SELECT level FROM revisions WHERE (item LIKE '%"fld1"%') AND (document = '"fld7"') ORDER BY level DESC")))
    
    
    ;;; for drawings with various numbers after the drawing name (ks1, ks2, ks3, etc.)  
      ((or
         (= abb "KS")
         (= abb "KE")
         (= abb "KM"))
       (setq fld11	(strcat "SELECT level FROM revisions WHERE (item LIKE '%"fld1"%') AND (document = '"abb">"abb2"') ORDER BY level DESC")))
      )	; end cond
      
    ;;;
    	 
             (if (setq
    	       adoValue	(caadr (ADOLISP_DoSQL ConnectionObject fld11))
    	     )
    	   (foreach att	(vlax-invoke (car item) 'getattributes)
    	     (if (= "REV" (vla-get-tagstring att))
    	       (if (/= nil adoValue)
    		 (and
    		   (prompt (strcat "\nPage No: " (vl-princ-to-string (cdr item)) ", " "Rev No: " (itoa adoValue)))(princ)
    		   (vla-put-textstring att adoValue))
                       ;;  somewhere in here is where I believe i need to update the block, but I don't know how <sad panda face>
    		 (vla-put-textstring att 0)
    	       )
    	     )
    	   )
    	 )
           )
           (*error* nil)
         )
      )
    Last edited by stusic; 2015-05-22 at 07:44 PM.

  2. #2
    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

    Additionally, the
    Code:
    (prompt (strcat "\nPage No: " (vl-princ-to-string (cdr item)) ", " "Rev No: " (itoa adoValue)))(princ)
    is getting the information like it should, just don't know why
    Code:
    (vla-put-textstring att adoValue))
    isn't working like (I think) it should.

    2015-05-22_1607.png

  3. #3
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: Update Title Block Lisp Problem

    What's the data type of the TextString property? What data type are you trying to push into it?

  4. #4
    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

    The textstring variable att is a attribute value (a number or nil, maybe stored as a string?) and I'm trying to send it a string (adoValue). Does that help?

  5. #5
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: Update Title Block Lisp Problem

    Are you certain? Check your (prompt ...) call - you are using (itoa adoValue) while your (vla-put-TextString ...) call does not. Have a look at the data type on the TextString property documentation

  6. #6
    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

    Weird. Left Friday and my code was iterating through all the page numbers and retrieving all the correct revision levels; today, it's just bringing back the page number for whatever the curretn layout is and bringing back the revision level for that page.

    So this:
    Code:
    (vlax-for x (setq ss (setq acDoc
                                       (vla-get-activeselectionset
                                         (vla-get-activedocument
                                           (vlax-get-acad-object)
                                         )
                                       )
                                )
                       )
             (foreach att (vlax-invoke x 'getattributes)
               (if (= "PAGE_NO" (vla-get-tagstring att))
                 (progn
                   (setq pageNo (atoi (vla-get-textstring att)))
                   (setq data (cons (cons x pageNo) data))
                 )
               )
             )
           )
    is bringing back this:
    2015-05-26_1019.png

    Then if I change layouts, I get odd results (not just for the current page as a bove, but ofr the curretn page, other pages, page 6 repeated 4 times, etc). So even before I try and get the right data type, I need to make sure I'm running through the blocks correctly. I don't know why this doesn't work anymore... From my Watch list, it appears to be iterating through the blocks correctly (each vla-object has a different handle), but it's still returning incorrect page numbers. Wtf.

  7. #7
    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

    2015-05-26_1253.png

    Why in the world would it be grabbing these attributes from these seemingly random order of blocks? Shouldn't it iterate through each one? I mean, it repeats some goes to others, doesn't get all of them... Grr.

  8. #8
    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

    If I just open the drawing and run the program, it will iterate through 10 blocks (there are 10 drawings, this block is in the title block in paperspace), but will list whichever layout I'm on 10 times. If I change to another layout, then run the routine again, it'll add that to the selection set (still only iterating through 10 blocks, but will replace one of them with the new tab block. If I activate each layout tab, then it will add those to the selection set. I don't understand.

  9. #9
    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 fixed the problem with the attributes not updating properly (becuase I'm dumb and used "and" instead of the "progn" I should have), but I still can't figure out this weird "we're not going to count it as a part of the selection set unless you activate the layout tab" debacle.

    For reference, here's my code that looks alright to me:

    Code:
    (if
        (and
          (setq
            ss (ssget "_x" '((0 . "INSERT") (2 . "*BORDER*") (66 . 1)))
          )
        )
         (progn
    
    
           ;; Get page_no attribute values from blocks
           (vlax-for x (setq ss (setq acDoc
                                       (vla-get-activeselectionset
                                         (vla-get-activedocument
                                           (vlax-get-acad-object)
                                         )
                                       )
                                )
                       )
             (foreach att (vlax-invoke x 'getattributes)
               (if (= "PAGE_NO" (vla-get-tagstring att))
                 (progn
                   (setq pageNo (atoi (vla-get-textstring att)))
                   (setq data (cons (cons x pageNo) data))
                 )
               )
             )
           )
    
    
    ;; Put revision attribute values into blocks - separated out because elvis has page numbers and descriptions as one record in his db. derp.
    (foreach item data
    
    
    ;;; for drawings that can have more than one page number
    (cond
      ((or
         (= abb "PD")
         (= abb "WD")
         (= abb "CHL"))
       (setq fld11	(strcat "SELECT level FROM revisions WHERE (item LIKE '%"fld1"%') AND (document = '"fld7">pg "(vl-princ-to-string (cdr item))"') ORDER BY level DESC")))
    
    
    ;;; for drawings that only have one page  
      ((or
         (= abb "HL")
         (= abb "CL")
         (= abb "LP"))
       (setq fld11 (strcat "SELECT level FROM revisions WHERE (item LIKE '%"fld1"%') AND (document = '"fld7"') ORDER BY level DESC")))
    
    
    ;;; for drawings with various numbers after the drawing name (ks1, ks2, ks3, etc.)  
      ((or
         (= abb "KS")
         (= abb "KE")
         (= abb "KM"))
       (setq fld11	(strcat "SELECT level FROM revisions WHERE (item LIKE '%"fld1"%') AND (document = '"abb">"abb2"') ORDER BY level DESC")))
      )	; end cond
      
    ;;;
    	 
             (if (setq
    	       adoValue	(caadr (ADOLISP_DoSQL ConnectionObject fld11))
    	     )
    	   (foreach att	(vlax-invoke (car item) 'getattributes)
    	     (if (= "REV" (vla-get-tagstring att))
    	       (if (/= nil adoValue)
    		 (progn
    		   (prompt (strcat "\nPage No: " (vl-princ-to-string (cdr item)) ", " "Rev No: " (itoa adoValue)))(princ)
    		   (vla-put-textstring att adoValue))
    		 (vla-put-textstring att 0)
    	       )
    	     )
    	   )
    	 )
           )
           (*error* nil)
         )
      )

  10. #10
    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

    Can you share an example drawing with the layouts set up the way you need them...

    Maybe show a finished version too.

    I would avoid using the selection set method... IMHO

    Iterate through the layouts collection and iterate through the items in the block (objects) collection looking for AcDbBlockReferences.

    Check the effective names.

    etc...

    I can play with it if you post them.
    AutomateCAD

Page 1 of 2 12 LastLast

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
  •