--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
"pashley" <paul....@mcd.com> wrote in message
news:f1491...@WebX.maYIadrTaRb...
> I am not aware of that causes this?
You'll need to examine your code for such errors. Often it will be an
improper setting of a symbol that is used in a (setvar ...) function, i.e.,
(setq MyLayer 0)
(setvar "clayer" Mylayer)
will fail, because Mylayer is an integer rather than a string.
___
"pashley" <paul....@mcd.com> wrote in message
news:f149...@WebX.maYIadrTaRb...
> No, I'm not using error handlers - that's an area I've never really
understood. I don't have access to any of my routines right now but, for
example, one just loads a lisp file that does nothing but sets dimension
variables. In that routine, unless I used the command version instead of
setvar, I repeatedly got error meassages. Since AutoCAD sends the error
message, I would think that someone there would know what in there program
triggers sending it.
(setvar "XREFCTL" 0)
(setvar "ZOOMFACTOR" 70)
(command "DBLCLKEDIT" "on") ; will not accept
input as setvar
You might be trying to setvar a non-system variable item?
--
Chip Harper
The main problem between VBA and VLISP is a botched implementation
by AutoDesk. This should never have been a problem. As a workaround
don't ever use setvar in your lisp functions. Use vla-setvariable instead.
BTW,
Your mtext command could simpler. There is no need to
define a text style each time you start your mtext command.
1. Use templates that already contain the styles or
2. Write a function that does it only when the style doesn't already
exist.
For those who use VBA and/or reactors, we may have to re-write
a lot of code to avoid the setvar or redefine the built in function
setvar. This could be done by unprotecting the setvar function
and then rewriting it per Active-X. Don't have time to demonstrate
now but this is something I am thinking about doing for my
own systems.
Good luck.
"Gordon Price" <gordon-price(ditch this)@attbi.com> wrote in message
news:1700ED0829E262A3...@in.WebX.maYIadrTaRb...
>Doug, how do you release an object in VBA, or deal with the mixed methods issue? I have a VBA tool that >manages DimScale &
LTScale as you switch between PS & MS, and a Lsip tool that sets layer & text style, >then does Mtext, then attempts to set
layer & style back, but I get an error on that last bit due to the mixing >methods deal. I prefer VBA for the events and ease
of accessing dictionaries, and Lisp for the mtext because it >is easy to make a command. Trying to do both in one or the
other is less pleasant.
Best,
Gordon
> Your mtext command could simpler. There is no need to
> define a text style each time you start your mtext command.
> 1. Use templates that already contain the styles or
We have templates, but I also want to deal with the fact that people will
open drawings that are not to standard (old drawings with old standards,
drawings from elsewhere, drawings started "from scratch", etc). I am dealing
with that as a training issue, but I want to make sure the tools mitigate
whatever possible. I am also using it as a way to promote ADT also (Hey, you
like that, ADT does it with EVERYTHING. You just have to take time to learn
it")
> 2. Write a function that does it only when the style doesn't already
> exist.
My actual code does just that. As I was testing to find where my error was
coming from, I stripped the code down to a minimum that still caused the
problem. Helps me to figure things out, and I find people are more likely to
have an answer here if I post just the minimum code to define the problem.
Given that I am starting all this code from scratch, as the office had
almost nothing automated when I arrived, I think I can just use the VLA
stuff as I go along. Forces me to learn VLisp too.
Thanks,
Gordon
Load the file with acaddoc.lsp or appload. This should eliminate
some of the need to re-write all your functions that use setvar.
Tony T. and all. Please be very critical of the attached file if you
see any major problems. I haven't thoroughly tested it. I appreciate
all comments.
Regards,
Doug
A very worthy effort. But if Pragma doesn't exist, then why bother with R14?
How about just ?...
(defun setvar (var val / doc)
(if
(and
(= (type vl-load-com) 'SUBR)
(vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'vlax-invoke (list doc 'Setvariable var val)
)
)
)
)
val
)
)
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:9DF13444ECFAF421...@in.WebX.maYIadrTaRb...
--------------------------------------------------------------------------------
;|This file is an attempt to workaround problems
caused by the old version of setvar when used
with reactors active or when vba functions are
used in combination with lisp or in a mixed
VLISP/Legacy LISP environment. Use at your
own risk. May be freely distributed.
Retain authorship notice!
Please post any problems found to
autodesk.autocad.customization or to
dbr...@earthlink.net
D. C. Broad, Jr. 3/2/03
|;
;;Allows setvar and other functions in this file to be re-defined.
(pragma '((unprotect-assign setvar legacyAcad db:Undo-Group db:Undo-End)))
;;Critical Version check - could be improved
;;Vlisp was available as an extra on R14.
(defun legacyAcad () (< (getvar "acadver") "15"))
;;Undo control for acad - Inspired by John Uhden.
;;Replace all instances of undo group and undo end
;;with db:undo-group and db:undo-end
(cond ((legacyAcad)
(defun db:undo-group ()
(command "_.undo" "_end" "_.undo" "_group"))
(defun db:undo-end () (command "_.undo" "_end")))
(t
(vl-load-com)
(defun db:undo-group ()
(vla-endundomark (activedoc))
(vla-startundomark (activedoc)))
(defun db:undo-end () (vla-endundomark (activedoc)))))
;;D.C. Broad, Jr.
;;Workaround for setvar problems.
(cond ((not (legacyAcad))
(defun setvar (var val)
(vla-setvariable
(vla-get-activedocument (vlax-get-acad-object))
var
(cond ((= (type val) 'list)
;;Fragment inspired by Tony T.
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
'(0 . (1- (length val)))
;;Sys vars are 2 or 3 long
;;Only setvar lists are lists of reals.
vlax-vbdouble)
val)))
(t val))))
))
;;protects the critical symbols defined in this file
(pragma '((protect-assign setvar db:undo-group db:undo-end legacyAcad)))
;;load quietly
(princ)
Command: (setvar "asdf" "ghjk")
nil
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:A55AC6294963A08F...@in.WebX.maYIadrTaRb...
> Good point John. Hadn't thought to check to see if pragma was
> available in R14. Your version however won't load in R2000 without
> the pragma and (for my taste) you have too much error checking.
> Let's say for instance that you feed this to setvar
> (setvar "asdf" "ghjk")
> What's it going to do? Report the error and halt.
>
> Here's my reply offering:
> ;;-----------------------setvar.lsp for 2000+-----------------------
> (pragma '((unprotect-assign setvar)))
>
> ;;ensure active-x functions
> (vl-load-com)
>
> ;;Redefined setvar for Acad 2000+
> ;;D. C. Broad - Substitute for setvar in Acad 2000+
> ;;with John Uhden's vlax-invoke style
> (defun setvar (var val)
> (vlax-invoke
> (vla-get-activedocument
> (vlax-get-acad-object)) 'setvariable var val)
> val)
>
>
> (pragma '((protect-assign setvar)))
>
> ;-----------------end setvar.lsp for 2000+ ----------------------
>
>
> It could be loaded with
> (or (< (getvar "acadver" "15") (load "setvar"))
>
> There's that undocumented vlax-invoke outdoing the vlax-invoke-method
> and vla-.... again.
>
> Thanks John.
> Regards,
> Doug
>
>
>
> "John Uhden" <juh...@cadlantic.com> wrote in message
news:0F2DD20188D070D3...@in.WebX.maYIadrTaRb...
;;ensure active-x functions
(vl-load-com)
(pragma '((protect-assign setvar)))
Thanks John.
Regards,
Doug
Command: (setvar "asdf" "asdf")
LISP ERROR: AutoCAD variable setting rejected: "asdf" "asdf"
That's without VBA, ACAD.LSP, or ACADDOC.lsp or ADT loaded.
I can't test in R15.0 Didn't R15.0 have pragma? R15.06
causes load problems without pragma (if vlide is active). If vlide
has not been activated, then your version will work.
"John Uhden" <juh...@cadlantic.com> wrote in message news:8EB5F39ED80AB316...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:2A691CBEDE631842...@in.WebX.maYIadrTaRb...
"John Uhden" <juh...@cadlantic.com> wrote in message news:1D25923157B9FF97...@in.WebX.maYIadrTaRb...
The only ones I don't use anymore are entmake or command.
Regards,
Luis
btw: I wrote a new command to control the ltscale, psltscale, textstyle,
dimstyle, dimscale, etc, using pure visual lisp/activex and works just fine.
A lot of people (myself included) have a large library of routines
that worked fine in R14 and should have worked fine in R2000
and through no fault of our own, they don't. The bugs surface
slowly and in conditions that could not have been anticipated when
the programs were originally written.
I too have that type of reactor (although reactive text and dimension
styles might be a little too bossy for my style). They work fine
but other programs choke while they are enabled.
Regards,
Doug
"Luis E." <supportATcaddximationDOTcom> wrote in message
news:2E6975309F6346CB...@in.WebX.maYIadrTaRb...
I was not referring to just routines with reactors.
;-)