This is related to my Block Counter program as posted in
this thread, which errors when run on 64-bit systems.
The error occurs when attempting to add the Block Thumbnail to the table cells, i.e. the
SetBlockTableRecordID Method.
I don't have a 64-bit system on which to test the code, and
the program doesn't error when run on a 32-bit system, so its been a bit of trial-and-error when trying to fix the code.
I have tried changing the way the method is implemented, changing the format of the parameters, removing some parameters - but nothing seems to work and the format described in the documentation for this method doesn't seem to result in a working solution.
Hence I have constructed the following code:
(defun c:test ( / _GetObjectID _GetBlockName acdoc acspc acblk block blockid pt table ) (vl-load-com)
(setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))
acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace))
acblk (vla-get-blocks acdoc)
)
(defun _GetObjectID ( doc obj )
(if (vl-string-search "64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
(vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
(itoa (vla-get-Objectid obj))
)
)
(defun _GetBlockName ( obj )
(if (vlax-property-available-p obj 'effectivename)
(vla-get-effectivename obj)
(vla-get-name obj)
)
)
(if
(and
(setq block (car (entsel "\nSelect Block: ")))
(eq "INSERT" (cdr (assoc 0 (entget block))))
(setq pt (getpoint "\nPick Point for Table: "))
)
(progn
(setq table (vla-AddTable acspc (vlax-3D-point (trans pt 1 0)) 2 2 1.0 5.0)
blockid (atoi (_GetObjectID acdoc (vla-item acblk (_GetBlockName (vlax-ename->vla-object block)))))
i 0
)
(princ (strcat "\n\nRunning Version: " (itoa (atoi (substr (ver) 13))) " " (getenv "PROCESSOR_ARCHITECTURE")))
(if
(not
(vl-some
(function
(lambda ( expr / err ) (setq err (vl-catch-all-apply 'eval (list expr)))
(princ
(strcat "\n--> Method " (itoa (setq i (1+ i))) ": "
(if (vl-catch-all-error-p err)
(strcat "Failed\n Reason: " (vl-catch-all-error-message err))
"Succeeded"
)
)
)
(not (vl-catch-all-error-p err))
)
)
'(
(vla-SetBlockTableRecordID table 1 0 blockid :vlax-true)
(vla-SetBlockTableRecordID2 table 1 0 acblockcell blockid :vlax-true)
(vla-SetBlockTableRecordID32 table 1 0 acblockcell blockid :vlax-true)
(vla-SetBlockTableRecordID32 table 1 0 blockid :vlax-true)
(vla-SetBlockTableRecordID32 table 1 0 acblockcell blockid)
(vlax-invoke table 'SetBlockTableRecordID table 1 0 blockid :vlax-true)
(vlax-invoke table 'SetBlockTableRecordID2 table 1 0 acblockcell blockid :vlax-true)
(vlax-invoke table 'SetBlockTableRecordID32 table 1 0 acblockcell blockid :vlax-true)
(vlax-invoke table 'SetBlockTableRecordID32 table 1 0 blockid :vlax-true)
(vlax-invoke table 'SetBlockTableRecordID32 table 1 0 acblockcell blockid)
)
)
)
(princ "\n--> All Methods have Failed.")
)
)
)
(princ)
)
[ Code updated to improve GetObjectID function ]
The above code prompts for a selection of a block, then a point to place a table. A 2x2 table is then created at the point.
The code then attempts to add a block thumbnail to the cell 0,1 using various methods - stopping when a successful method is found.
I would ask as many of you as possible to test the above code, and please post the return printed to the command line (containing the system details and method report).
If anyone has any suggestions for how to implement this method, or see any mistakes in my code or the code in the linked program, I would sincerely appreciate any input you have to offer.
Thank you all for your time reading this.
Kind Regards,
Lee