TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on July 12, 2017, 10:19:12 AM

Title: getting handle error....
Post by: Andrea on July 12, 2017, 10:19:12 AM
Hi all,..

in some case, I have this issue..

Code: [Select]
(setq blkobj (vla-handletoobject dbx_file "36B"))
Automation Error. Unknown handle

but the Handle is correct.
This situation happen only if the external file is open and user perform a QSAVE.
then,..the function vla-handletoobject  do not recognize the handle "36B"...but it still there.

I've made some research on the net and validate the presence of the "36B" handle with this awesomne LeeMac programmer...
here (https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/those-familiar-with-objectdbx-handles/td-p/5099654)
it recognize the "36B" handle,...

here is the part of my code:

Code: [Select]
(setq xref-ename (handent sec_hand))
(setq vla-xref (vlax-ename->vla-object xref-ename))
(if (not dbx_file) (setq dbx_file (_dbxopenfile (vla-get-path vla-xref))))
(setq blkobj (vla-handletoobject dbx_file prim_hand));;<----ERROR


any help will be appreciated.
thank you.


Title: Re: getting handle error....
Post by: roy_043 on July 12, 2017, 04:14:43 PM
This is a known issue of ODBX. The standard workaround is to make a temporary copy of the file.
But since you appear to be working with an xref using vla-get-xrefdatabase is probably more logical:
Code: [Select]
(setq db
  (vla-get-xrefdatabase
    (vla-item
      (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
      "A" ; "A" is the name of the xref.
    )
  )
)
(entget (vlax-vla-object->ename (vla-handletoobject db "AD"))) ; "AD" is the handle.