A very simple vl-catch-all-apply wrapper around a vla-item call is all it takes:
(defun [color=red]_GetItem[/color] ( collection key / item )
[color=green];; caller's responsibility to pass
;; a legitimate collection and key[/color]
(vl-catch-all-apply
'(lambda ( )
(setq item
(vla-item collection key)
)
)
)
item
)
However, I'm a little reluctant to post post it without a precaution. It assumes
the programmer fully understands the ramifications of the sledge error trapping
it encapsulates, because it can hide logic errors in your code if used improperly.
For example, if one passed it an invalid collection object you'd never know it,
because the
_GetItem would blithely return nil, which suggests the key doesn't
exist, which in fact would be misleading. This would be a logic error, i.e. the program
is coded incorrectly (failed to pass a valid collection object), as opposed to a run
time error (specified key doesn't in a valid collection), so please use carefully.
Hope this abbreviated explanation made sense.
Anyway, an example of use using the variables you provided previously might be ...
[color=green];; assumes variables dbx_doc, rev_cloud are properly set ...[/color]
(if (setq rev_layer ([color=red]_GetItem[/color] (vla-get-layers dbx_doc) rev_cloud))
([color=purple]Do_Stuff_With_Layer_object[/color] rev_layer)
)
Of course, what you do with the layer object via ObjectDBX has to be legit ...
... for what it's worth, cheers.