Is there a better way? or should that be What is the better way?
(defun IsDocOpen ( Doc / Tmp)
(vlax-for x (vla-get-documents (vlax-get-acad-object))
(if (equal (strcase Doc) (strcase (vla-get-name x)))
(setq Tmp x)
)
)
Tmp
)
No need to keep going once the (if) evaluates to T. What are my other
alternatives? How do you handle multiple sessions?
(vla-get-documents (vlax-get-acad-object)) is only for the current session,
right?
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
--
Ken Alexander
Acad 2000
Win 2000
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:A96D6D8FF241D771...@in.WebX.maYIadrTaRb...
Look at the ITEM method of the layers collection...and you'll also need to
look at the VL-CATCH-ALL-APPLY function...we're here for ya
--
Bobby C. Jones
www.acadx.com
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:A96D6D8FF241D771...@in.WebX.maYIadrTaRb...
This jb:OpenDbxDocument returns the axdbdocument object if the drawing is
NOT opened - nil if it is opened (locked by the OS).
;;; Does NOT close DbxDocument!!!
(defun jb:OpenDbxDocument (DwgName / dbxopen)
(if (not (RegisterObjectDBX))
(exit)
)
(if (= (type dwgname) 'STR)
(progn
(if (setq Dwg-Name (findfile DwgName))
(progn
(setq *dbxDoc*
(vla-GetInterfaceObject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
(setq dbxopen(vl-catch-all-apply
'vla-open (list *dbxDoc* Dwg-Name)))
(if (vl-catch-all-error-p dbxopen)
(setq *dbxDoc* nil)
)
)
(alert
(strcat
"*WARNING*\n\nDrawing "
dwgname
" \nnot found. Check to make sure it has not been moved or erased"
)
)
)
)
)
*dbxDoc*
)
jb
Doug
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message news:A96D6D8FF241D771...@in.WebX.maYIadrTaRb...
Thanks for jumping in here, you are pretty scarce around here these days....
Time for me to stop playing and get back to work :-(
Hopefully I can concentrate on this a bit more after while.
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
You can use (vl-catch-all-apply ...(exit)..) to break
out of just about any type of looping construct, as
shown here:
(defun isDocOpen(name / temp)
(setq name (strcase name)) ;; only need to do this once
(vl-catch-all-apply
'(lambda ()
(vlax-for doc (vla-get-documents (vlax-get-acad-object))
(if (eq name (strcase (vla-get-name doc)))
(progn
(setq temp doc)
(exit) ;; stop iterating
)
)
)
)
)
temp ;; returns the document object if open, or NIL
)
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:A96D6D8FF241D771...@in.WebX.maYIadrTaRb...
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
> This jb:OpenDbxDocument returns the axdbdocument object if the drawing is
Network, multiple sessions? What's wrong with the ObjectDBX method?
jb
I generally try and stay away from (exit) since it is such an abrupt ending,
but I see that wrapping it in (vl-catch-all-apply) takes care of that.
> (setq name (strcase name)) ;; only need to do this once
Wouldn't 'name' need to be localized now?
>(defun isDocOpen(name / temp)
No 'name' after the '/'
> (setq name (strcase name))
Wouldn't this make it so it needs to be localized? Or am I all wet?
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
> It was. Look at the parameter list.
Technically, you should always check to see if a given
file is open in the editor before trying to open it in
ObjectDBX. If it's already open in the editor, you can
just access it via AcadDocument instead, or you can ask
the user to close the drawing first if you require it to
be open in ObjectDBX.
Your code doesn't make an attempt to determine what
caused the vla-open method to fail, which could be
because the drawing is already open in the editor, or
in another AutoCAD session, or because it's read only,
or because of network permissions..., file corruption,
etc.
> I see that name is nil, how does that work? If the same symbol is
> used for an argument and local var it doesn't need to be localized?
It was. Look at the parameter list.
--
http://www.acadx.com
"If you want to be somebody else change your mind"
--
Thanks for that great illustration of how to break out of a vlax-for
loop. Almost as good as having a while. Though it may be
overkill here(with the likely number of documents open < 20), it
has excellent application for larger collections.
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:77789807D67247E5...@in.WebX.maYIadrTaRb...
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:366B20A6325E4CBE...@in.WebX.maYIadrTaRb...
(defun isDocOpen (name)
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'vla-item
(list
(vla-get-documents (vlax-get-acad-object))
name
)
)
)
)
)
--
Cliff
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:A96D6D8FF241D771...@in.WebX.maYIadrTaRb...
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
>avoids iterating through the documents collection but has the
Funny thing is that the help files state that the selection set collection
is the only case sensitive collection. I've never encountered the documents
case problem as the only time that I've ever tested the open documents
against a file name is when I've collected the name directly from the file.
Another note to add to the list...
Here is my generic Item recipe that you all may, or may not, find useful:
(defun ax:Item (oCollection item / RetVal)
(if
(vl-catch-all-error-p
(setq RetVal
(vl-catch-all-apply
'vla-item
(list oCollection item)
)
)
)
nil
RetVal
)
As Tony pointed out weeks ago, this can be reduced to:
(defun ax:Item (oCollection item / RetVal)
(vl-catch-all-apply
(function (lambda () (setq RetVal (vla-Item oCollection item)))))
RetVal)
--
R. Robert Bell, MCSE
www.AcadX.com
"Bobby C. Jones" <bob...@acadx.com> wrote in message
news:BFF61B70E337DA98...@in.WebX.maYIadrTaRb...
Bobby,
I agree that Tony's version is better for the reasons given. The generic
item utility is handy tool. I have to look up vl-catch-all-apply every time
I use it.
R. Robert,
Thanks for posting the reduced version.
--
Cliff
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message
news:4FEAC5AEC1EEB46B...@in.WebX.maYIadrTaRb...
You and me both! :-)
jb
"James Buzbee" <j...@levelvoid.com> wrote in message
news:DE9E88536F08A2B2...@in.WebX.maYIadrTaRb...
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message
news:CE4BB6882A9E12BB...@in.WebX.maYIadrTaRb...
> In fact, it's documented *otherwise*:
>
> <clip>
>
> Your program can intercept and attempt to process errors instead of
allowing
> control to pass to *error*. The vl-catch-all-apply function is designed to
> invoke any function, return a value from the function, and trap any error
> that may occur. The function _requires_ (emphasis mine) two arguments: a
> symbol identifying a function or lambda expression, and a list of
arguments
> to be passed to the called function.
>
> </clip>
>
> Visual LISP Developer's Guide, Catching Errors and Continuing Program
> Execution
>
> --
> R. Robert Bell, MCSE
> www.AcadX.com
>
>
> "Cliff Middleton" <cmidd...@generalbroach.com> wrote in message
> news:569A9E72D6996EE9...@in.WebX.maYIadrTaRb...
<clip>
Your program can intercept and attempt to process errors instead of allowing
control to pass to *error*. The vl-catch-all-apply function is designed to
invoke any function, return a value from the function, and trap any error
that may occur. The function _requires_ (emphasis mine) two arguments: a
symbol identifying a function or lambda expression, and a list of arguments
to be passed to the called function.
</clip>
Visual LISP Developer's Guide, Catching Errors and Continuing Program
Execution
--
R. Robert Bell, MCSE
www.AcadX.com
"Cliff Middleton" <cmidd...@generalbroach.com> wrote in message
news:569A9E72D6996EE9...@in.WebX.maYIadrTaRb...
Command: (vl-catch-all-apply 'eval)
#<%catch-all-apply-error%>
Command: (vl-catch-all-apply 'rtos)
#<%catch-all-apply-error%>
It's sorta catching itself. :]
Can't go wrong with this one:
Command: (vl-catch-all-apply 'vl-catch-all-apply *anything/nothing*)
#<%catch-all-apply-error%>
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Cliff Middleton" <cmidd...@generalbroach.com> wrote in message
news:569A9E72D6996EE9...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"John Uhden" <juh...@cadlantic.com> wrote in message
news:C6BDA6CD12FB831F...@in.WebX.maYIadrTaRb...
Guess I don't follow you with the documentation issue.
> Other than removing a few lines of code, are
> there any valid reasons to use the shorter version?
Case sensitivity is an issue for me, and shorter than your version?
> In light of the documentation issue, the shorter version
> masks the true intent of the code and makes it almost
> impossible for even an advanced lisp programmer to
> easily see what the original programmers intent was.
Have to disagree there, I barely know what I am looking at with this stuff
and I think it is pretty clear what the intent was/is.
"Bobby C. Jones" <bob...@acadx.com> wrote in message
news:3C36BFFF9A47EE38...@in.WebX.maYIadrTaRb...
"Cliff Middleton" <cmidd...@generalbroach.com> wrote in message
news:838A99A35AE578A4...@in.WebX.maYIadrTaRb...
(defun ax:Item (oCollection item / RetVal)
(if
(vl-catch-all-error-p
(setq RetVal
(vl-catch-all-apply
'vla-item
(list oCollection item)
)
)
)
nil
RetVal
)
)
(defun ax:Item (oCollection item / RetVal)
(vl-catch-all-apply
(function (lambda () (setq RetVal (vla-Item oCollection item)))))
RetVal)
--
Bobby C. Jones
www.acadx.com
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:DF9F6D7AEA1BCBD5...@in.WebX.maYIadrTaRb...
The second argument to (vl-catch-all-apply) is
optional, and if not supplied, defaults to '()
or Nil.
The second argument if supplied, must be a list.
The number of elements in that list must be at
least equal to the number of required arguments
that the function passed as the first argument
takes.
So, in your example, (vl-catch-all-apply) is not
catching "itself", it is catching the error raised
by (eval), which requires one argument.
"John Uhden" <juh...@cadlantic.com> wrote in message
news:C6BDA6CD12FB831F...@in.WebX.maYIadrTaRb...
I get the feeling we're all learning the behavior, and it ain't over 'til it's
over.
Notice in the following (I deleted the CRs) how the second argument is *not* a
list, and there's no apparent error.
Command: (vl-catch-all-apply 'boole 1)
Command: (setq error (vl-catch-all-apply 'boole 1))
Command: (type error) nil
Go figure.
Meanwhile, though this little (vla-catch-all...) exercise is only academic for
the reasons you stated earlier (file might be open for other reasons), I found
that your IsDocOpen function, though very clever, returned a VLA-Object for
"Drawing1.dwg" that had not yet been saved, as in (getvar "dwgtitled") being
zero. And, of course, without using the FullName how can you tell that *this*
"Drawing1.dwg" is different from or same as *that* "Drawing1.dwg?"
Also, the use of (vla-item) isn't predictable, because it appears to succeed
only if the string is an exact match, character by character.
So I hafta believe that James' ObjectDBX approach (which needs a little path
embellishment as well) or something like it is probably more reliable, and we
oughta drop the "blinders" approach that the current AutoCAD session is the only
application that might have the file open.
What say?
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Tony Tanzillo" <tony.tanzillo at caddzone dot com> wrote in message
news:715DDA409F792DCA...@in.WebX.maYIadrTaRb...
It seems that after all this T&E that Dale's (dos_openp) function might be a
better mouse trap. :]
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Jason Piercey" <Jason@AtrEngDOTcom> wrote in message
news:A96D6D8FF241D771...@in.WebX.maYIadrTaRb...
> Slowly dipping my toes into the ActiveX pool.....
>
> Is there a better way? or should that be What is the better way?
>
> (defun IsDocOpen ( Doc / Tmp)
> (vlax-for x (vla-get-documents (vlax-get-acad-object))
> (if (equal (strcase Doc) (strcase (vla-get-name x)))
> (setq Tmp x)
> )
> )
> Tmp
> )
>
> No need to keep going once the (if) evaluates to T. What are my other
> alternatives? How do you handle multiple sessions?
> (vla-get-documents (vlax-get-acad-object)) is only for the current session,
> right?
>
The fact that it doesn't generate an error when the
second argument isn't a list, is a bug. But, aside
from that, the behavior you suggested earlier is
simply not the case. The function accepts nil, or
no second argument, and behaves identically.
> Meanwhile, though this little (vla-catch-all...) exercise is only academic
for
> the reasons you stated earlier (file might be open for other reasons), I
found
> that your IsDocOpen function, though very clever, returned a VLA-Object
for
> "Drawing1.dwg" that had not yet been saved, as in (getvar "dwgtitled")
being
> zero. And, of course, without using the FullName how can you tell that
*this*
> "Drawing1.dwg" is different from or same as *that* "Drawing1.dwg?"
The version of Jason's IsDocOpen() function I posted was
intended to demonstrate how to break out of a loop using
(vl-catch-all-apply) and (exit), and nothing more.
> So I hafta believe that James' ObjectDBX approach (which needs
> a little path embellishment as well) or something like it is
> probably more reliable, and we oughta drop the "blinders"
> approach that the current AutoCAD session is the only application
> that might have the file open.
Sorry, but I don't follow your logic here at all.
Jason's original post, and James' reply are each
attempts at answering two different questions:
1. Can the file be opened for writing? (James' code)
2. Is the file is open in the drawing editor? (Jason's code)
The code they posted are not two different approaches
that attempt to answer the same question, each answers
a different question, both of which are legitmate and
not mutually exclusive.
In any case, it isn't really necessary to use ObjectDBX
to figure out if a drawing file is write-enabled. This is
what I've used for the past ten or so years for any type
of file:
(defun is-write-enabled (file / fh)
(if (setq fh (open file "a"))
(not (close h))
)
)
After AutoCAD switched from using ".DWK" semaphores
to the OS's file locking mechanism, this also happens
to work for dwg's as well, but again, the point here
is that "can this dwg file be opened?" and "is this
dwg file opened in this instance of AutoCAD" are two
different questions which can have different answers.
Which of the two questions (if not both) Jason should
be asking, is something you nor I know enough about
to intelligently debate.
(defun is-write-enabled (file / fh)
(if (setq fh (open file "a"))
(not (close fh));<----
)
)
It should also be noted that this will flag non-existant files as "write-enabled"
which is appropriate. But it should always return nil if the drawing file is
opened.
Regards,
Doug
"Tony Tanzillo" <tony.tanzillo at caddzone dot com> wrote in message news:33462E80711BD166...@in.WebX.maYIadrTaRb...
Yes, it will return nil for non-existing files,
but keep in mind that its job is limited to
determining if an existing file can be opened
for write. IOW, it assumes the file passed in
does exist.
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:EA23B43735A0DB36...@in.WebX.maYIadrTaRb...
Sorry for the delay; the storm last night blew the entire top of my corner maple
over the wires, knocked out power for 8 hours, and the utility company left me
to clean up all the debris out of my yard. I've been conjugating the Latin verb
"shio" all day. :/
My apologies for erroneously implying that (vl-catch-all-apply) "catches
itself." I agree that's not the case. I don't take it that the 2nd argument is
optional, but rather the function catches the error of the argument's absence
only if the function being "caught" requires argument(s). Similarly, if the
function being "caught" does not take any arguments and you give it one, a
(vl-catch-all-error-message) will be likewise generated.
Example (CRs removed):
Command: (setq error (vl-catch-all-apply 'terpri))
nil
Command: (setq error (vl-catch-all-apply 'terpri '("X")))
#<%catch-all-apply-error%>
Command: (vl-catch-all-error-message error)
"too many arguments"
So, while the documentation is, let's say "abridged", the function works
logically.
Also, upon further inspection, if any 2nd argument is required or provided, then
it must be in the form of a list, otherwise even the (vl-catch-all-apply)
function will fail without either warning or continuing subsequent code.
Example (CRs removed):
Command: (setq error "Whatever")
"Whatever"
Command: (setq error (vl-catch-all-apply 'exit 1))(princ error)
Command: !error
"Whatever"
Note that nil qualifies as an empty list.
I think Dale's (dos_openp) function might be the best all-around method. I used
to use a function similar to your (open file "a") method, but found it
inappropriate because it would change the file's date/time stamp.
Thanks for helping us learn.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Tony Tanzillo" <tony.tanzillo at caddzone dot com> wrote in message
news:33462E80711BD166...@in.WebX.maYIadrTaRb...
> I think Dale's (dos_openp) function might be the best all-around
> method. I used to use a function similar to your (open file "a")
> method, but found it inappropriate because it would change the
> file's date/time stamp.
Well, it doesn't appear to change the
file's timestamp here (Win2K).
but this doesn't choke
(vl-catch-all-apply 'vl-cmdf (list "line" "0,0" "1,1"))
"John Uhden" <juh...@cadlantic.com> wrote in message news:2E35B106210B7907...@in.WebX.maYIadrTaRb...
I'm beat and have got to get some sleep, so I'm not going to put my foot in my
mouth by responding without research (if you know what I mean). But I do recall
that "catching" 'command was futile. Could be the order in which the arguments
are evaluated. Not so sure that "catching" 'vl-cmdf was any better. Maybe
tomorrow... (which is already today) <yawn/zzzz>.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:52C9BBFF9B079F7E...@in.WebX.maYIadrTaRb...
Care to address the vl-catch-... stuff?
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Tony Tanzillo" <tony.tanzillo at caddzone dot com> wrote in message
news:6D9DB77F3523AD59...@in.WebX.maYIadrTaRb...
(vl-catch-all-apply
'(lambda ()
(apply 'command (list "line" "0,0" "2,2" ""))
)
)
I usually avoid using vl-catch-all-apply directly like
your command example since it makes code harder to read.
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:52C9BBFF9B079F7E...@in.WebX.maYIadrTaRb...
(vl-catch-all-apply
(function
(lambda ()
(command "line" "0,0" "2,2" "Kaboom")
)
)
)
Though the resulting error message is a bit confusing.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:52C9BBFF9B079F7E...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Tony Tanzillo" <tony.tanzillo at caddzone dot com> wrote in message
news:8C64F7B1ABDFE993...@in.WebX.maYIadrTaRb...
Regards,
Doug
"John Uhden" <juh...@cadlantic.com> wrote in message news:84ADE026831E0A30...@in.WebX.maYIadrTaRb...
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
> Which of the two questions (if not both) Jason should
"Eric Schneider" <eschn...@spamfree.jensenprecast.com> wrote in message
news:82C4352A05E5A964...@in.WebX.maYIadrTaRb...
> Almost identical to this snippet from AutoLay[X.X].lsp. Just wondering if
> you re-invented it or adapted it?
>
> ;;;returns ActiveX object if exist, else nil
> (defun al:exist (collection item / rslt)
> (if
> (not
> (vl-catch-all-error-p
> (setq rslt
> (vl-catch-all-apply 'vla-item
> (list collection item)
> );trap error
> );end setq
> );return T if successful, else nil
> );end not
> rslt; return object or nil
> );end if
> );end defun
> --
>
> Regards,
> Eric S.
> A2k/W2k
>
>
Command: (listp nil)
T
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Eric Schneider" <eschn...@spamfree.jensenprecast.com> wrote in message
news:82C4352A05E5A964...@in.WebX.maYIadrTaRb...
;If an error occurs, it will happen before the rslt
is bound, and therefore will be nil.
;|But if I may again muddy the water, it is possible
to have more than one item in a collection with the
same name as well as it is possible that the name
not exist. For drawings, it is possible to
have more than one open with the same name. It is
possible in fact to have several drawings open
with the same name and path (as long as one is not
titled). I found a wealth of information as I pushed
an prodded ACAD this weekend. If any of you are still
interested, let me know and I'll start a new thread.
This one is getting too deep to scroll for. Eric,
you should know that we all enjoy re-inventing the
wheel. I for one, though, have never looked in
AutoLay(sorry).
Regards,
Doug
"John Uhden" <juh...@cadlantic.com> wrote in message news:395BE4EA0BC98CD1...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:4D975ABF4CF17D0F...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"John Uhden" <juh...@cadlantic.com> wrote in message
news:39829E25FE47380C...@in.WebX.maYIadrTaRb...
| Hey, plagiarism is the highest form of flattery, right?
|
| --
| John Uhden, Cadlantic/formerly CADvantage
| http://www.cadlantic.com
| Sea Girt, NJ
|
|
| "R. Robert Bell" <NOT.r...@acadx.com> wrote in message
| news:D43884F5A1F04DAC...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message
news:D43884F5A1F04DAC...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:4D975ABF4CF17D0F...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"John Uhden" <juh...@cadlantic.com> wrote in message
news:346D0DC341FB840D...@in.WebX.maYIadrTaRb...
| Come to think of it, he plagiarized my use of (function), I think. That
does
| flatter me. Nice work, Doug!
|
| --
| John Uhden, Cadlantic/formerly CADvantage
| http://www.cadlantic.com
| Sea Girt, NJ
|
|
| "R. Robert Bell" <NOT.r...@acadx.com> wrote in message
| news:24D5C72696CAE520...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message
news:24D5C72696CAE520...@in.WebX.maYIadrTaRb...
Heck, can we really copyright these basic building block
code formulations anyway? Someone, somewhere, probably
used the same construct prior to Tony or without seeing
it from Tony don't you think? I've made an effort to integrate
FUNCTION since I learned about it last summer(from one of you
no doubt). Can we avoid, either consciously or unconsciously, being
influenced by one another?
This construct by Tony and posted Robert is the best in my opinion
for the task. BTW, I like the name ITEM better than EXISTS_IN.
Was that the same name Tony gave it?
Now, who else can I copy?
Regards,
Doug
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message news:D43884F5A1F04DAC...@in.WebX.maYIadrTaRb...
BTW This is a Nesterovskized version<VBG>
<Disclaimer> Speaking only of his probable style.
<Intended as a compliment>
AFAIK they are original (Maybe???)
Any single argument|;
(defun catch1 (fun a / rslt)
(vl-catch-all-apply
(function
(lambda ()
(setq rslt (fun a)))))
rslt)
;;Any 2 arg function
(defun catch2 (fun a b / rslt)
(vl-catch-all-apply
(function
(lambda ()
(setq rslt (fun a b)))))
rslt)
;;Any function with arbitrary args
(defun catchn (fun args / r)
(if (not(vl-catch-all-error-p
(setq r (vl-catch-all-apply 'fun args))))
r))
;;Any quoted expression you want to error trap.
(defun vl-error-trap (expr)
(vl-catch-all-apply
'(lambda () (eval expr))
))
;|
Examples
(catch1 vla-get-count *docs* )
(catch2 vla-item *docs* 0)
(catchn vla-item (list *docs 0))
(catchn vla-add-arc (list *mspace* .......))
(vl-error-trap '(command "line" "0,0" "1,1" "Kaboom"))
These might<possibly> be better than making a wrapper
for every method/property/event that you want to trap.
They may not have any particular advantage over wrapping much
larger programs with vl-catch-all-apply. As noted in
the thread above, the catchn function would not work
with many functions (ex: COMMAND)
Also I'm not sure FUNCTION can do anything
to really optimize these expression since a function
is passed as an argument. They may be more secure from
prying eyes, however, in an error trace.
|;
Regards,
Doug
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message news:B09BB507E7AA7E9B...@in.WebX.maYIadrTaRb...
FWIW, I don't think it is reasonable to attempt to copyright basic functions
such as this. Where would the madness stop?! For instance, there was a post
to the AUGI guilds where an author (from a book!) had actually placed a
copyright on a basic VBA error handling structure (selection sets)! Of
course, I was able to reduce it, so blatantly removed the "copyright" in
that thread. But I do endeavor to place credit where credit is due for the
techniques I employ.
The function name ax:Item was actually ripped from Bobby's posted
function...
--
R. Robert Bell, MCSE
www.AcadX.com
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:42C31C808694AE76...@in.WebX.maYIadrTaRb...
ax: portion of function name Copyright Frank Oquendo 2002
Item portion of function name Copyright Unknown source 2002
ax:Item combined function name Copyright Bobby C. Jones 2002
(defun ax:Item () ...)
If we all don't start copyrighting every single part of every single
function now, there's no telling who will be stealing what!
--
Bobby C. Jones
www.acadx.com
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message
news:8D472F8CCFDE7C4C...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Bobby C. Jones" <bob...@acadx.com> wrote in message
news:7A337BCEDDC3224E...@in.WebX.maYIadrTaRb...
Seriously though, I do try to give credit. Stuff I cut and paste
from the newsgroup to my disk gets put in LSP files a header
like:
;;Newsgroup: Autodesk.autocad.customization
;;Thread: Reactors and LDT3
;;Date: 5/17/02
;;Posted by: John Uhden
;;Author: John Uhden
;;Function(s):
;;Purpose(s): Demonstration of how to add functions to startup.
<snip>
15 from Bobby's, 9 from Roberts and 6 from John U. at this
location and more at school. My goal was to give my students
good examples of programming style and some useful functions
that they wouldn't need to write themselves.
"Bobby C. Jones" <bob...@acadx.com> wrote in message news:7A337BCEDDC3224E...@in.WebX.maYIadrTaRb...
Doug: "Anyone got a function to find the hypercenter of a globule?"
John: "Sure, Doug. Look in Lib12 for HyperGlob.lsp. I posted it a month ago."
Doug: "John - I just downloaded it and it gave me me an error."
John: "I don't understand; it's been downloaded 37 times with no other
complaints!?"
Bobby: "Yeah... I had downloaded it 36 times and never did get it to work. :/"
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Bobby C. Jones" <bob...@acadx.com> wrote in message
news:9C31ADEE827BF520...@in.WebX.maYIadrTaRb...
(I see this thread headed for other pastures...)
--
R. Robert Bell, MCSE
www.AcadX.com
"John Uhden" <juh...@cadlantic.com> wrote in message
news:7766B71F773D7C78...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"R. Robert Bell" <NOT.r...@acadx.com> wrote in message
news:CC5E5EDC7A356B73...@in.WebX.maYIadrTaRb...
Anne
Compuserve ACAD Forum Wizop
John Uhden wrote:
>
> Don't know if you guys ever played in the old ACAD Forum, but you used to be
> able to post code, like in CF, and it would show the number of downloads. (snip)
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Anne Brown" <discussio...@autodesk.com> wrote in message
news:3CFD5CA1...@autodesk.com...
Unfortunately I was much to poor to afford CompuServe at that time...didn't
start hitting news groups until I had *free* access to C.C.A. at the office
via a listserver that delivered all of the messages to my email inbox. What
I didn't realize was that the company was charged on a per document basis
for each email that was sent or received over the internet. I discovered
this fact one day when the head of the IS department entered my office all
out of breath from sprinting down the hallway to inform me that one of my
incoming SMTP internet email messages had hung in the server overnight and
had effectively shut down external email communications for the entire
company. While unclogging the mess, one of the techs discovered a backlog
of nearly 100 *not so free* email messages for me...I was working for Exxon
at the time....
... and after I lost THAT job ... ;-)
jb