BHenry85 Posted January 23 Author Posted January 23 On 1/22/2025 at 1:12 PM, ronjonp said: (se tq a (lm:vl-getattributevalue blk "DETAIL_NUMBER")) I noticed you had an extra space in "setq a" On 1/22/2025 at 1:12 PM, ronjonp said: Untested but try something like this: I get "Automation Error. Description was not provided." Below is the full code that I used: (defun c:dext (/ a b blk cells lst myxl row x) (vl-load-com) ;; Pre-purge file ;(command "-purge" "all" "*" "no" "") ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun lm:vl-getattributevalue (blk tag) (setq tag (strcase tag)) (vl-some '(lambda (att) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att) ) ) (vlax-invoke blk 'getattributes) ) );defun ;; Set Excel cell text (defun xlsetcelltext (row column text) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (vl-catch-all-apply 'vlax-put-property (list cells 'item row column (vlax-make-variant (vl-princ-to-string text) vlax-vbstring)) ) );defun ;; Get Nested Values (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) (vlax-for blk a (if (and (= "AcDbBlockReference" (vla-get-objectname blk)) (= -1 (vlax-get blk 'hasattributes)) (setq a (lm:vl-getattributevalue blk "DETAIL_NUMBER")) (setq b (lm:vl-getattributevalue blk "SHEET_NUMBER")) (setq c (vlax-get-property blk 'Hyperlinks)) (or (and (setq c (vlax-get-property blk 'Hyperlinks)) (setq c (vla-get-url (vla-item c 0))) ) (setq c "NO HYPERLINK") ) ) (or (member (setq x (strcat "`" a "-" b "," c)) lst) (setq lst (cons x lst)) ) ) ) ) (if lst (progn (or (setq myxl (vlax-get-object "Excel.Application")) (setq myxl (vlax-get-or-create-object "Excel.Application")) ) (vla-put-visible myxl :vlax-true) (vlax-put-property myxl 'screenupdating :vlax-true) (vlax-put-property myxl 'displayalerts :vlax-true) (vlax-invoke-method (vlax-get-property myxl 'workbooks) 'add) (setq row 0) (foreach itm (vl-sort lst '<) (xlsetcelltext (setq row (1+ row)) 1 itm)) ) (print "NO VALUES FOUND...") ) (princ) );defun Quote
BHenry85 Posted January 23 Author Posted January 23 On 1/22/2025 at 12:36 AM, mhupp said: Have you tried attout from express tools? Yes. It works in a pinch just for getting the block names, but my users are looking to include hyperlinks now too and ATTSYNC does not include that. Quote
BHenry85 Posted January 23 Author Posted January 23 So, I narrowing down the issue that I'm having pulling the hyperlinks. Apparently, it is the hyperlink itself. A few years back, we had a working version of this code that was pulling the hyperlink for details that we have stored in Autodesk BIM 360. I could drop the lisp file into my test file and it would output a csv file containing the detail tags and their corresponding hyperlinks. Example of Old Link: https://docs.b360.autodesk.com/projects/bacf5fe2-74bf-4c85-8e3d-8467336d3606/folders/urn:adsk.wipprod:fs.folder:co.eWziiblQQO2ziEfYAs8HCw/detail/viewer/items/urn:adsk.wipprod:dm.lineage:dH-D5EZIR9SJjq4MOsRpmw Since then, we have moved away from using BIM 360 and are now using another solution called M-Files. So, all of our detail bubbles have had their hyperlinks updated to point to this new solution. The hyerplinks work as intended in the dwg files and and pdf we produce from them. But, if I take the same working version of the lisp file and drop it into a file that contains these updated links, the csv file is created but it will be empty. Example of New Link: https://tb.cloudvault.m-files.com/SharedLinks.aspx?accesskey=e71ef2342dfc426d6cf4ad602a570180e3bdcc72fef43a21bea475267b197860&VaultGUID=A32AC746-BBE4-4BC7-A32E-F70BA96ADC73 The the full code that I posted last works for the Old Link, but it does not work for the New Link. Any thoughts on why this would be? Quote
ronjonp Posted January 30 Posted January 30 On 1/23/2025 at 3:11 PM, BHenry85 said: I noticed you had an extra space in "setq a" I get "Automation Error. Description was not provided." Below is the full code that I used: (defun c:dext (/ a b blk cells lst myxl row x) (vl-load-com) ;; Pre-purge file ;(command "-purge" "all" "*" "no" "") ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun lm:vl-getattributevalue (blk tag) (setq tag (strcase tag)) (vl-some '(lambda (att) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att) ) ) (vlax-invoke blk 'getattributes) ) );defun ;; Set Excel cell text (defun xlsetcelltext (row column text) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (vl-catch-all-apply 'vlax-put-property (list cells 'item row column (vlax-make-variant (vl-princ-to-string text) vlax-vbstring)) ) );defun ;; Get Nested Values (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) (vlax-for blk a (if (and (= "AcDbBlockReference" (vla-get-objectname blk)) (= -1 (vlax-get blk 'hasattributes)) (setq a (lm:vl-getattributevalue blk "DETAIL_NUMBER")) (setq b (lm:vl-getattributevalue blk "SHEET_NUMBER")) (setq c (vlax-get-property blk 'Hyperlinks)) (or (and (setq c (vlax-get-property blk 'Hyperlinks)) (setq c (vla-get-url (vla-item c 0))) ) (setq c "NO HYPERLINK") ) ) (or (member (setq x (strcat "`" a "-" b "," c)) lst) (setq lst (cons x lst)) ) ) ) ) (if lst (progn (or (setq myxl (vlax-get-object "Excel.Application")) (setq myxl (vlax-get-or-create-object "Excel.Application")) ) (vla-put-visible myxl :vlax-true) (vlax-put-property myxl 'screenupdating :vlax-true) (vlax-put-property myxl 'displayalerts :vlax-true) (vlax-invoke-method (vlax-get-property myxl 'workbooks) 'add) (setq row 0) (foreach itm (vl-sort lst '<) (xlsetcelltext (setq row (1+ row)) 1 itm)) ) (print "NO VALUES FOUND...") ) (princ) );defun Expand So does each attribute have a hyperlink or just the block? A sample drawing would help. Quote
mhupp Posted January 30 Posted January 30 (edited) On 1/30/2025 at 9:11 PM, ronjonp said: So does each attribute have a hyperlink or just the block? A sample drawing would help. Edited January 30 by mhupp 1 Quote
ronjonp Posted January 30 Posted January 30 @BHenry85 Give this version a try. I had to add another check that the hyperlink count was greater than 0. (defun c:dext (/ a b blk cells lst myxl row x) (vl-load-com) ;; Pre-purge file ;(command "-purge" "all" "*" "no" "") ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun lm:vl-getattributevalue (blk tag) (setq tag (strcase tag)) (vl-some '(lambda (att) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att) ) ) (vlax-invoke blk 'getattributes) ) ) ;defun ;; Set Excel cell text (defun xlsetcelltext (row column text) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (vl-catch-all-apply 'vlax-put-property (list cells 'item row column (vlax-make-variant (vl-princ-to-string text) vlax-vbstring)) ) ) ;defun ;; Get Nested Values (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for blk a (if (and (= "AcDbBlockReference" (vla-get-objectname blk)) (= -1 (vlax-get blk 'hasattributes)) (setq a (lm:vl-getattributevalue blk "DETAIL_NUMBER")) (setq b (lm:vl-getattributevalue blk "SHEET_NUMBER")) (setq c (vlax-get-property blk 'hyperlinks)) (or (and (setq c (vlax-get-property blk 'hyperlinks)) (> (vla-get-count c) 0) (setq c (vla-get-url (vla-item c 0))) ) (setq c "NO HYPERLINK") ) ) (or (member (setq x (strcat "`" a "-" b "," c)) lst) (setq lst (cons x lst))) ) ) ) (if lst (progn (or (setq myxl (vlax-get-object "Excel.Application")) (setq myxl (vlax-get-or-create-object "Excel.Application")) ) (vla-put-visible myxl :vlax-true) (vlax-put-property myxl 'screenupdating :vlax-true) (vlax-put-property myxl 'displayalerts :vlax-true) (vlax-invoke-method (vlax-get-property myxl 'workbooks) 'add) (setq row 0) (foreach itm (vl-sort lst '<) (xlsetcelltext (setq row (1+ row)) 1 itm)) ) (print "NO VALUES FOUND...") ) (princ) ) ;defun 1 Quote
Recommended Posts
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.