Results 1 to 4 of 4

Thread: Batch change Block Attributes

  1. #1
    Member
    Join Date
    2012-01
    Posts
    2
    Login to Give a bone
    0

    Default Batch change Block Attributes

    Hello,

    I have on every drawing a Block with the Attribute "Date". I created a Lisp to find this block and change the date to today.
    This works very well.
    Code:
    (defun C:td (/ ss p )
    
    (setq cdate_val (rtos (getvar "CDATE") 2 0))
    (setq YYYY (substr cdate_val 1 4)
            M    (substr cdate_val 5 2)
            D    (substr cdate_val 7 2)
    )
    (setq adate(strcat YYYY "-" M "-" D))
    
    
    (if
    (ssget "_x" '((0 . "INSERT")))
    
    
    (vlax-map-collection (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
    (function (lambda (b) 
    (foreach at (vlax-invoke b 'getattributes)
    
    
    (if 
      (eq (vla-get-tagstring at) "DATE")
      (vla-put-textstring at adate)
    )
    
    
    )))))
    (vla-delete ss)(princ)
    )
    But for this solution i must open every file.

    So i had the idea to create a batch file to open the drawings in the core-console and run the lisp/scr
    My batch file
    Code:
    echo off
    
    :: Path to AutoCAD core console
    set accoreexe="C:\Program Files\Autodesk\AutoCAD 2020\accoreconsole.exe"
    
    
    :: Path the directory to process
    set "source=C:\Users\robocop1989\Documents\Test"
    
    
    :: Path to the script to run
    set script="C:\Users\robocop1989\Documents\Autocad\test.scr"
    
    
    FOR /f "delims=" %%f IN ('dir /b "%source%\*.dwg"') DO %accoreexe% /i "%source%\%%f" /s %script%
    :: comment the following to automatically close the console when batch ends
    pause
    the script file
    Code:
    (load "C:/Users/robocop1989/Documents/Autocad/TODAY.lsp")
    td
    Filedia
    0
    save
    
    Filedia
    1
    I think the problems are the "vlx" or "vla" comments in the list, because other lisp without this, are works.
    Must i load something else in the script file?

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Batch change Block Attributes

    Make sure you have
    Code:
    (vl-load-com)
    either in your code or in acaddoc.lsp for those vl functions to work.

    While date fields aren't automatically updated you can code them in a selection set and update them with the updatefield command.

  3. #3
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: Batch change Block Attributes

    accoreconsole will not run any of the VL commands.

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Batch change Block Attributes

    Have a look at using attedit.

Similar Threads

  1. 2013: Batch extraction of title block attributes to excel
    By robechandler167079 in forum AutoCAD General
    Replies: 1
    Last Post: 2015-04-28, 07:29 PM
  2. 2009: Need help: Batch editing block with attributes
    By J. Grouchy in forum AutoCAD 3D (2007 and above)
    Replies: 3
    Last Post: 2011-10-13, 04:25 PM
  3. attributes in block attributes
    By t_goofbeer in forum AutoLISP
    Replies: 8
    Last Post: 2009-09-17, 08:46 PM
  4. Replies: 21
    Last Post: 2007-03-20, 02:03 PM
  5. Extract Dynamic Block Attributes, values change as Block changes
    By dave.buckberry in forum Dynamic Blocks - Technical
    Replies: 11
    Last Post: 2006-09-05, 04:38 PM

Tags for this Thread

Posting Permissions

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