Friday, October 29, 2010

AreaText.lsp updated for 64-bit AutoCAD

The freeware AutoLISP AreaText.lsp has been updated to run on 64-bit AutoCAD as well.

On the x64 platform, creating a Field expression from lisp (or VB) requires that you use the 64-bit ObjectID as a string so the source code had to be updated accordingly using this function I got from ADN:

(defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) )
Now just load AreaText.lsp using APPLOAD and run the command AT, select a polyline and specify where you want the text and you can get a result like this:

If you want other units or formats or scaling of the text see the post Customize AreaText.LSP for AutoCAD.

11 comments:

  1. Sadly, the routine gives the following error message on my AutoCAD 2011 64 bit, with metric units.

    Select object: Select point: ; error: bad argument type: numberp:
    "8796083608048"

    Any idea?

    ReplyDelete
  2. Try the tip here and see if it can help as you might need to use the FIELD command to figure out the code: Customize AreaText.LSP for AutoCAD

    The other idea is to run a piece of the code at the time to figure out where it fails:
    You just paste it to the command line one row at a time.
    Start by loading the LSP file.

    (vl-load-com)

    (setq entObject (vlax-ename->vla-object(car (entsel))))

    (setq entObjectID (Get-ObjectIDx64 entObject))

    (rtos entObjectID 2 0)

    Then let me know what the command line shows.

    ReplyDelete
  3. Hi Jimmy,

    These are the results:

    Command: at

    Select object: Select point: ; error: bad argument type: numberp:
    "8796083608032"

    Command: (vl-load-com)

    Command: (setq entObject (vlax-ename->vla-object(car (entsel))))

    Select object: #

    Command: (setq entObjectID (Get-ObjectIDx64 entObject))
    "8796083608032"

    Command: (rtos entObjectID 2 0)
    ; error: bad argument type: numberp: "8796083608032"

    ReplyDelete
  4. I think I found the issue that the code converted a value with rtos that already was a string.
    Please download the updated code and try again.

    ReplyDelete
  5. Hi, This fixes the problem on a 64bit AutoCAD. But it introduces a problem on the 32bit version.

    Command: at
    Select object: Select point: ; error: bad argument type: stringp 2128975088

    ReplyDelete
  6. Seems like the upload did not work. Try to download again. You might need to clear the cache.

    ReplyDelete
  7. It does work on a 64bit AutoCAD, It doesnot on a 32bit AutoCAD.

    Maybe the following also needs a
    "if 64 bit; then ....; else ....' part.

    InsertionPoint 0.0 (strcat
    "%<\\AcObjProp Object(%<\\_ObjId "
    entObjectID
    ">%).Area \\f \"%pr2%lu2%ct4%qf1 SQ. FT.\">%"

    ReplyDelete
  8. I have tried on 32bit and it works. What AutoCAD version do you have?

    Make sure you have these rows in the code:
    (rtos (vla-get-objectid obj) 2 0)

    and further down

    "%<\\AcObjProp Object(%<\\_ObjId "
    entObjectID
    ">%).Area \\f \"%pr2%lu2%ct4%qf1 SQ. FT.\">%"

    ReplyDelete
  9. Hi,

    It works now. Thanks for all your support

    ReplyDelete
  10. is there a way to remove the wipeout behind the text?

    ReplyDelete
  11. The FIELD object has a grey background that can be hidden using FIELDDISPLAY set to 0.

    ReplyDelete

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner