Author Topic: Headaches with SetBlockTableRecordID Method  (Read 9215 times)

0 Members and 1 Guest are viewing this topic.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Headaches with SetBlockTableRecordID Method
« Reply #15 on: April 29, 2011, 07:05:50 AM »
Hi,

The upper method, evaluates the processor architecture, not AutoCAD version. You can install an AutoCAD 32 bit (prior to 2008) on a 64 bit system (I have A2007 32bit and A2011 64 bit installed on Seven 64 bit).

I think a better way to know the AutoCAD version (32 or 64 bit) is to evaluate an ObjectId length :
Code: [Select]
(strlen (vl-princ-to-string (vlax-get-acad-object)))
returns 39 on a 32 bit Acad version and 47 on a 64 bit version.

EDIT: after some searches, it seems that the *32 suffixed properties and methods (ObjectId32, OwnerId32, ObjectIdToObject32, ...) have been added to the 64 bit versions of AutoCAD only to be used in VBA routines on 64 bit versions.
These properties and method shouldn't be needed for LISP which isn't platform dependent.

Anayway, according to the tests I did, these properties and methods seems to be only available on 64 bits AutoCAD version and (if so) may serve to evaluate the AutoCAD version :
Code: [Select]
(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.
« Last Edit: April 30, 2011, 03:54:50 AM by gile »
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Headaches with SetBlockTableRecordID Method
« Reply #16 on: April 29, 2011, 08:01:05 AM »
Thanks for your clarifications Gile  :-)

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Headaches with SetBlockTableRecordID Method
« Reply #17 on: April 30, 2011, 02:40:40 AM »
I edited my upper message after having done some deeper searches on 64 bit specific methods and properties.
Speaking English as a French Frog

redraiderr1999

  • Guest
Re: Headaches with SetBlockTableRecordID Method
« Reply #18 on: September 06, 2012, 10:22:16 AM »
I just found this old topic in "theSwamp" and I am working through the same issues. If anyone is still outthere, I have a couple of quesitons.
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.
from the help file

object.SetBlockTableRecordId32 nRow, nCol, nContent, blkId, autoFit

Object
Table
The object this method applies to.

nRow
Integer; Input-only
The index of the column.

nCol
Integer; Input-only
The index of the column.

nContent
Integer; Input-only
The value of the content.

blkId
Long; Input-only
The new block table record.

autoFit
VARIANT_BOOL; Input-only
The flag indicating whether to auto fit the block Integero the specified cell.
[/i][/i]

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.")
)

Thanks

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Headaches with SetBlockTableRecordID Method
« Reply #19 on: September 06, 2012, 10:51:10 AM »
1. what is the difference between these besides the 32b and 64b differences?:
a. setblocktablerecord
b. setblocktablerecord2
c. setblocktablerecord32

I'm not entirely sure of the difference between the setblocktablerecord and setblocktablerecord2 methods, but I only tend to use the setblocktablerecord method (for 32-bit) and setblocktablerecord32 (for 64-bit) and in this respect, I believe the only difference is the use in 32-bit / 64-bit environments.

2. Why would you used one over the other?

setblocktablerecord for 32-bit / setblocktablerecord32 for 64-bit.

3. for the setblocktablerecord32 method, what is the "nContent", I don't understand what value of the content means.

In my experience, the 'nContent' parameter is not required when using the setblocktablerecord32 method - at least, the method appears to perform successfully without it.

4. Is the block id from a specific block object or the name of the block from the collection?

It is the ObjectID of the Block Definition from the Block 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.")
)

I would suggest perhaps:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / blk tab )
  2.     (if
  3.         (and
  4.             (setq tab (LM:SelectifObject "\nSelect Table: " "ACAD_TABLE"))
  5.             (setq blk (LM:SelectifObject "\nSelect Block: " "INSERT"))
  6.         )
  7.         (progn
  8.             (setq blk (vlax-ename->vla-object blk)
  9.                   tab (vlax-ename->vla-object tab)
  10.                           (if (vlax-property-available-p blk 'effectivename)
  11.                               (vla-get-effectivename blk)
  12.                               (vla-get-name blk)
  13.                           )
  14.                       )
  15.             )
  16.             (vla-setcelltype tab 3 0 acblockcell)
  17.             (if (vlax-method-applicable-p tab 'setblocktablerecordid32)
  18.                 (vla-setblocktablerecordid32 tab 3 0 (vla-get-objectid32 blk) :vlax-true)
  19.                 (vla-setblocktablerecordid   tab 3 0 (vla-get-objectid   blk) :vlax-true)
  20.             )
  21.         )
  22.     )
  23.     (princ)      
  24. )
  25.  
  26. ;; Select if Object  -  Lee Mac
  27. ;; Continuously prompts the user for selection of a specific object
  28.  
  29. (defun LM:SelectifObject ( msg obj / ent )
  30.     (while
  31.         (progn (setvar 'errno 0) (setq ent (car (entsel msg)))
  32.             (cond
  33.                 (   (= 7 (getvar 'errno))
  34.                     (princ "\nMissed, try again.")
  35.                 )
  36.                 (   (= 'ename (type ent))
  37.                     (if (/= obj (cdr (assoc 0 (entget ent))))
  38.                         (princ "\nInvalid Object Selected.")
  39.                     )
  40.                 )
  41.             )
  42.         )
  43.     )
  44.     ent
  45. )
  46.  
« Last Edit: September 06, 2012, 10:59:25 AM by Lee Mac »

redraiderr1999

  • Guest
Re: Headaches with SetBlockTableRecordID Method
« Reply #20 on: September 06, 2012, 11:29:06 AM »
I would dare say, that clears it up.

It takes me a little while to understand the vlax-methods with the apostrophe " ' ". I haven't made it a habit of using those. I also have to say my weakest area is error checking. I liked the way that you have it set to look for invalid objects. I just took a C++ class and learned about passing values to functions, and I have just recently realized you could do that with Lisp so I finally understand what you are doing here calling the function and passing those values on to LM:SelectifObject.

It looks like my major problem was picking the wrong objectid and not using setblocktablerecordid correctly.

I have been trying to setup a way to create a plant list using block attribute data and put it in a table. We have been using data extractions, but it would not put blocks into the table (wish it did). I would just use a table outright and fill it like you did on your count routine, but if the value of the attributes is changed I have no way just to update the table like the data link does without using a reactor of some sort. Never done one of those before.

I appreciate your help.

Thanks a lot.

Russell