Jump to content

Recommended Posts

Posted

I have updated the code in the first post to Version 2.8, in this version the user can choose to extract the block coordinates.

 

Lee

Posted

Pulled V2.8 of this fantastic program, it works great! :D

 

I would like to modify it a bit to suit my own needs but I've never really worked with VBA,.

 

I really just need the editor (if you happen to have it as a stand alone), and I would like add in my own LISP that updates the titleblock (mainly a basic Block=Block redefine with some clean up functions) but I have no idea where to plug it in.

Posted

Hi Lady Hawk,

 

Firstly I'm glad you like the program :)

 

I haven't used VBA in this program, but Visual LISP and ObjectDBX - the Extractor and Editor are combined in one subfunction of the program, as they share various functions, and it was easier this way.

 

You will not be able to use your own LISP routines in this program unless they are suited for use with ObjectDBX, i.e. only using Visual LISP methods, (no command calls, not ent* methods, no access to system variables).

 

Lee

Posted

It should be attached in the first post - I'm not sure if there are restrictions if you have fewer than 10 posts (hopefully a Mod will correct me), but you should be able to just click on the attached file in the first post to download it.

 

Lee

Posted
Thank you Lee Mac for your work.:wink:

 

You're very welcome, I'm glad it helps you out - I enjoyed coding it :)

  • 2 weeks later...
Posted

Hello, I'm new to this site, first off your program is awesome, very very helpful. Thank you.

 

but i admit :oops: I am curious mainly about the subject of having any it update back to cad, or if that was just impossible.

 

 

Well, as I said, the format that the extractor uses groups all the block information together for blocks with the same name, hence, when coming to read this information how would the program know which information went where... :geek:

 

The drawing numbers for instance would be fixed. All other data in excel would link to cad through these drawing numbers. :unsure:

Posted
Hello, I'm new to this site, first off your program is awesome, very very helpful. Thank you.

 

but i admit :oops: I am curious mainly about the subject of having any it update back to cad, or if that was just impossible.

 

 

 

 

The drawing numbers for instance would be fixed. All other data in excel would link to cad through these drawing numbers. :unsure:

 

Firstly, thanks for your interest in the program - I'm glad you like it :)

 

True, the drawing numbers would be fixed, but how would the program know which blocks to update... unless the handle was extracted into the Excel sheet also.

 

Lee

Posted
Firstly, thanks for your interest in the program - I'm glad you like it :)

 

True, the drawing numbers would be fixed, but how would the program know which blocks to update... unless the handle was extracted into the Excel sheet also.

 

Lee

 

So, There could not be a direct sync from the excel file your program creates to back to the dwg sheet it came from then. Just update everything, type thing.

 

forgive me i don't know a ton about this kinda stuff, our issue is that we have sometimes 20 layout pages with 15 att per layout, it would be way easier to edit them in excel then update cad, then going through each layout sheet.

 

I've always pictured a window in cad that allows edits of every att on the drawing file organized by location(layout tab). but that's probably wishful thinking. lol

 

Thanks again, your like my cad hero now lol. :lol:

Posted

Wasn't someone working on an Excel to Titleblock attribute program?

Posted
Thanks again, your like my cad hero now lol. :lol:

 

Hehe thanks :D

 

I can see what you are getting at, and believe me I've considered it - the only problem is that when going through the blocks in the drawing, the order that they are encountered is not consistent enough for an accurate 'sync', the way to do it would be to extract the Object handles to Excel (these don't change unless the object is deleted), then, when reading from Excel, update the objects based on the handle that is read.

 

But, this would probably have to be coded as a separate program, a counterpart to the Extractor program, and reading the same format ( not easy when I've provided the option to write in three different formats :( )

 

Lee

Posted
Hehe thanks :D

 

I can see what you are getting at, and believe me I've considered it - the only problem is that when going through the blocks in the drawing, the order that they are encountered is not consistent enough for an accurate 'sync', the way to do it would be to extract the Object handles to Excel (these don't change unless the object is deleted), then, when reading from Excel, update the objects based on the handle that is read.

 

But, this would probably have to be coded as a separate program, a counterpart to the Extractor program, and reading the same format ( not easy when I've provided the option to write in three different formats :( )

 

Lee

 

 

Okay, it just clicked what you meant. damn. i figured you were right, i just wanted to understand.

 

Thanks!

Posted
Wasn't someone working on an Excel to Titleblock attribute program?

 

oh i wish, the time it would save us!!! :shock:

Posted
oh i wish, the time it would save us!!! :shock:

I saw it floating around, but don't have a clue where it is. Do a little searching.

Posted
I saw it floating around, but don't have a clue where it is. Do a little searching.

 

Try this one don't remember how it worked

 

; Tested on A2005, A2008; MS Office 2003
(defun C:AXE (/)
;; local defun:  
;; read Excel data
(defun EXD ( / ExcelApp ExcData FilePath Sht ShtNum UsdRange Wbk)

 (vl-load-com)
   (setq FilePath (getfiled "Select Excel file to read attribute values:"
  (getvar "dwgprefix")
  "xls"
  16
      )
 )
 (setq ShtNum 1); Spreadsheet number, change to suit 
 (setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
 (vla-put-visible ExcelApp :vlax-true)
 (setq Wbk (vl-catch-all-apply 'vla-open
      (list (vlax-get-property ExcelApp "WorkBooks") FilePath)))
  (setq Sht (vl-catch-all-apply 'vlax-get-property
         (list (vlax-get-property Wbk "Sheets")
        "Item" ShtNum)))
     (vlax-invoke-method Sht "Activate")
 (setq Sht (vlax-get-property ExcelApp "ActiveSheet"))
(setq UsdRange1 (vlax-get-property Sht "Range"
      "A1:D1");<-- first row with headers (tags), change to suit
      UsdRange2 (vlax-get-property Sht "Range"
      "A3:D3");<-- second row with attribute values, change to suit
      UsdRange (vlax-invoke ExcelApp "Union" UsdRange1  UsdRange2
   nil nil nil nil nil nil nil nil nil nil nil nil
   nil nil nil nil nil nil nil nil nil nil nil nil
   nil nil nil )
)
 (vlax-for Row (vlax-get-property UsdRange 'Areas)
 (setq ExcData (cons (car (vlax-safearray->list
      (vlax-variant-value
   (vlax-get-property Row 'Value2)))) ExcData)))
(setq ExcData (reverse (mapcar (function (lambda (x)
 (mapcar 'vlax-variant-value x)))
       ExcData)
        )
     )

     (vl-catch-all-apply
'vlax-invoke-method
(list Wbk "Close")
     )
(vl-catch-all-apply
  'vlax-invoke-method
  (list ExcelApp "Quit")
)
 (mapcar
   (function (lambda (x)
 (if (not (vlax-object-released-p x))

   (vlax-release-object x)
 )
      )
   )
   (list UsdRange1 UsdRange2 UsdRange Sht Wbk ExcelApp)
 )
 (setq UsdRange1 nil
UsdRange2 nil
UsdRange nil
Sht nil
Wbk nil
ExcelApp nil
 )
 (gc)
 (gc)
 ; to ignore empty cells:
 (vl-remove-if (function(lambda(x)(member nil x)))
 ExcData
 )
)
;======================main part=======================;
(if (and
(setq data (exd))
(setq data (mapcar 'cons (car data)(cadr data)))
(setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 "Title-Block")(cons 66 1)))));<-- change title block name here
 (progn
   (setq i -1)
   (repeat (sslength ss)
   (setq blkref (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
   (setq atts (vlax-invoke blkref "GetAttributes"))
   (foreach at atts
     (if (setq itm (assoc (vla-get-tagstring at) data))
 (progn
 (vla-put-textstring at (cdr itm))
 (vla-update at)))
     )
   (vla-update blkref)
   )
   )
 (alert "Something wrong")
 )
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports)  
(princ)
 )
(prompt "\t\t***\t\nType AXE to change attributes\t***")
(princ)

 

~'J'~

Posted

There you go MotoGirl. Thanks for sharing Fixo. :)

 

Try this one don't remember how it worked

 

; Tested on A2005, A2008; MS Office 2003
(defun C:AXE (/)
;; local defun:  
;; read Excel data
(defun EXD ( / ExcelApp ExcData FilePath Sht ShtNum UsdRange Wbk)

 (vl-load-com)
   (setq FilePath (getfiled "Select Excel file to read attribute values:"
  (getvar "dwgprefix")
  "xls"
  16
      )
 )
 (setq ShtNum 1); Spreadsheet number, change to suit 
 (setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
 (vla-put-visible ExcelApp :vlax-true)
 (setq Wbk (vl-catch-all-apply 'vla-open
      (list (vlax-get-property ExcelApp "WorkBooks") FilePath)))
  (setq Sht (vl-catch-all-apply 'vlax-get-property
         (list (vlax-get-property Wbk "Sheets")
        "Item" ShtNum)))
     (vlax-invoke-method Sht "Activate")
 (setq Sht (vlax-get-property ExcelApp "ActiveSheet"))
(setq UsdRange1 (vlax-get-property Sht "Range"
      "A1:D1");<-- first row with headers (tags), change to suit
      UsdRange2 (vlax-get-property Sht "Range"
      "A3:D3");<-- second row with attribute values, change to suit
      UsdRange (vlax-invoke ExcelApp "Union" UsdRange1  UsdRange2
   nil nil nil nil nil nil nil nil nil nil nil nil
   nil nil nil nil nil nil nil nil nil nil nil nil
   nil nil nil )
)
 (vlax-for Row (vlax-get-property UsdRange 'Areas)
 (setq ExcData (cons (car (vlax-safearray->list
      (vlax-variant-value
   (vlax-get-property Row 'Value2)))) ExcData)))
(setq ExcData (reverse (mapcar (function (lambda (x)
 (mapcar 'vlax-variant-value x)))
       ExcData)
        )
     )

     (vl-catch-all-apply
'vlax-invoke-method
(list Wbk "Close")
     )
(vl-catch-all-apply
  'vlax-invoke-method
  (list ExcelApp "Quit")
)
 (mapcar
   (function (lambda (x)
 (if (not (vlax-object-released-p x))

   (vlax-release-object x)
 )
      )
   )
   (list UsdRange1 UsdRange2 UsdRange Sht Wbk ExcelApp)
 )
 (setq UsdRange1 nil
UsdRange2 nil
UsdRange nil
Sht nil
Wbk nil
ExcelApp nil
 )
 (gc)
 (gc)
 ; to ignore empty cells:
 (vl-remove-if (function(lambda(x)(member nil x)))
 ExcData
 )
)
;======================main part=======================;
(if (and
(setq data (exd))
(setq data (mapcar 'cons (car data)(cadr data)))
(setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 "Title-Block")(cons 66 1)))));<-- change title block name here
 (progn
   (setq i -1)
   (repeat (sslength ss)
   (setq blkref (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
   (setq atts (vlax-invoke blkref "GetAttributes"))
   (foreach at atts
     (if (setq itm (assoc (vla-get-tagstring at) data))
 (progn
 (vla-put-textstring at (cdr itm))
 (vla-update at)))
     )
   (vla-update blkref)
   )
   )
 (alert "Something wrong")
 )
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports)  
(princ)
 )
(prompt "\t\t***\t\nType AXE to change attributes\t***")
(princ)

~'J'~

Posted

No flowers, please, still waiting for result from MotoGirl :)

Posted

lmao, hahah i got a messege that said.... "something wrong" lol,

 

 

i'm still working on it tho, i just thought it was funny, i feel that it should say that when i get those stupid unhelpful autocad errors. lol

Posted
lmao, hahah i got a messege that said.... "something wrong" lol,

 

 

i'm still working on it tho. lol

 

Can you upload your Excel file here

Probably problem is on data format

I use now Excel 2007

(I will be back just tomorrow only)

 

~'J'~

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...