
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I am in a desperate need of a LISP routine to do the following.
I have a folder with .dwg files. These are old versions of the documents, and I need to import blocks and attribute values from them to the current drawing.
When the user types the command to start the lisp in the current drawing, the following things should happen:
1. Ask user for folder path (command line, no GUI)
2. Lisp tries to find a match of current document name to a drawing found in the folder -> If match found then continue, otherwise present user with an error.
3. Find all blocks where the name starts with "REV." from the folder document (REV.A, REV.B....), insert them to the current drawing. IMPORTANT, the position must match!
4. From the folder file, copy this list of attributes from a block named "A4" to the current drawing (current drawing also contains a block "A4", but I can't copy the whole block. I need only certain attributes to be updated!)
A list of attribute names in block "A4" that needs to be copied from the folder drawing -> Active drawing DRAWN DATE REV REV_A DATE_A DRAWN_A REV_B DATE_B DRAWN_B REV_C DATE_C DRAWN_C REV_D DATE_D DRAWN_D REV_E DATE_E DRAWN_E REV_F DATE_F DRAWN_F
This is the Code that I have so far (i think everything is correct until i try to copy the REV.A block). This script lacks the copying of all blocks and attribute transfer of block A4
;----------------------------------------------------------------------------- ;Update current drawing with source drawing (get attributes from block A4, and copy ;all blocks that start with REV. ;---------------------------------------------------------------------------- ;Main Loop (defun c:UpRev (/ FileName FolderPath FindPath FoundFile) ;Filename = Drawing to be updated, Folderpath = Folder of the source file; FindPath = Folderpath + Filename, FoundFile = return value if file is found in folder (setq FileName (getvar "dwgname")) ;Get Current DWG name (setq FolderPath (getstring "\Anna Pohja kansio: ")) ;Ask user for folder where source is located (setq FindPath (strcat FolderPath "\\" Filename)) ;Create findpath string (setq FoundFile (findfile FindPath)) (if FoundFile (progn (setq Dbx (open_dbx FindPath)) ; If file is found, open it with open_dbx function (vla-CopyObjects ;This part is where I am strugling. I cant get even 1 block copied (REV.A). How to loop all blocks, and copy the ones that STARTS with "REV."? How to get a list of attributes from block A4? Dbx (vlax-safearray-fill (vlax-make-safearray vlax-vbObject '(0 . 0)) (list (vla-item (vla-get-blocks dbx) "REV.A")) ) (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) ) ) (alert "NO FILE FOUND") ) (vlax-release-object dbx) )
Solved! Go to Solution.