(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)
)
Command: test
Select Block:
Pick Point for Table:
Running Version: 2011 AMD64
--> Method 1: Failed
Reason: Automation Error. Null object ID
--> Method 2: Failed
Reason: Automation Error. Null object ID
--> Method 3: Failed
Reason: Too many actual parameters; error: Exception occurred: 0xC0000005
(Access Violation)
; warning: unwind skipped on unknown exception
I'm glad I was finally able to be able to jump in and lend a hand. I read through all these posts, and usually by the time I get to the point of thinking I may have something to add someone else has already made the observation, or the OP has figured out the problem.
since it looked like you've been struggling with it for a while :-)
(defun objectID (o / i)
(if
(vl-some
(function
(lambda (p)
(not (vl-catch-all-error-p (setq i (vl-catch-all-apply (function vlax-get) (list o p)))))
)
)
'(objectID objectID32)
)
i
)
)
(defun objectID (o)
(vl-some
(function
(lambda (p / i)
(if
(not (vl-catch-all-error-p (setq i (vl-catch-all-apply (function vlax-get) (list o p)))))
i
)
)
)
'(objectID objectID32)
)
)
Interesting stuff guys. Out of curiosity, wouldn't something like one of these be sufficient?
Agreed, but if it avoids the need to fuss with checking the architecture, then I'd say it's worth the vl-catch. I'd love to know if it actually works on a 64-bit machine.Interesting stuff guys. Out of curiosity, wouldn't something like one of these be sufficient?
I suppose, but some errors can't be caught by the vl-catch-all-apply function (as shown in Trogg's command line printout), so for the sake of testing whether the system is 64-bit I'd rather not take that chance.
I tend to only use vl-catch-all-apply when I really have to.
Agreed, but if it avoids the need to fuss with checking the architecture
(vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
(vlax-get-property obj (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) 'ObjectID32 'ObjectID))
Point taken. Mind changed.Agreed, but if it avoids the need to fuss with checking the architecture
That's only a quick vl-string-search of an environmental variableCode: [Select](vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
I'd use this method:Code: [Select](vlax-get-property obj (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) 'ObjectID32 'ObjectID))
(strlen (vl-princ-to-string (vlax-get-acad-object)))
(defun gc:IsAcad64 ()
(vlax-property-available-p
(vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
'ObjectId32
)
)
Returns T on a 64 bit version, nil on a 32 bit.(setq objTable (vlax-ename->vla-object (car (entsel "\nSelect Table:"))))
(setq objBlock (vlax-ename->vla-object (car (entsel "\nSelect Block:"))))
(cond
((/= (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))0)
(setq BlockObjectIdNum (vla-get-objectid32 objBlock))
(vla-SetBlockTableRecordId32 objTable 3 0 1 BlockObjectIdNum :vlax-true)
)
((> (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))0)
(setq BlockObjectIdNum (vla-get-objectid objBlock))
(vla-SetBlockTableRecordId objTable 3 0 BlockObjectIdNum :vlax-true)
)
(princ "\nUnknown processor.")
)
1. what is the difference between these besides the 32b and 64b differences?:
a. setblocktablerecord
b. setblocktablerecord2
c. setblocktablerecord32
2. Why would you used one over the other?
3. for the setblocktablerecord32 method, what is the "nContent", I don't understand what value of the content means.
4. Is the block id from a specific block object or the name of the block from the collection?
This is my code.Code: [Select](setq objTable (vlax-ename->vla-object (car (entsel "\nSelect Table:"))))
(setq objBlock (vlax-ename->vla-object (car (entsel "\nSelect Block:"))))
(cond
((/= (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))0)
(setq BlockObjectIdNum (vla-get-objectid32 objBlock))
(vla-SetBlockTableRecordId32 objTable 3 0 1 BlockObjectIdNum :vlax-true)
)
((> (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))0)
(setq BlockObjectIdNum (vla-get-objectid objBlock))
(vla-SetBlockTableRecordId objTable 3 0 BlockObjectIdNum :vlax-true)
)
(princ "\nUnknown processor.")
)