There is a curt note in the Visual Lisp documentation stating that
Visual Lisp does not allow text creation using the command function, but
no data on how one is supposed to create text...(I assume there is some
vla-call?)
Can anyone translate this code to something Visual Lisp can handle?
Thanks.
Elise Moss
(if (= styht 0.0)
(command "text" "J" "M" midpt th "0" "HOLE CHART")
) ; end if
(if (/= styht 0.0)
(command "text" "J" "M" midpt "0" "HOLE CHART")
)
There should be no problem creating text via
(command).
I ran the following code in AutoCAD 2000, and
it works just fine:
(setq inspt '(0.0 0.0 0.0))
(setq th 2.0)
(command "text" "J" "M" inspt th "0" "HOLE CHART")
--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
(setq inspt '(0.0 0.0 0.0))
(setq th 2.0)
(if (= styht 0.0)
(command "text" "J" "M" inspt th "0" "HOLE CHART")
(command "text" "J" "M" inspt "0" "HOLE CHART")
)
We are assuming that your 'midpt' is a preset point, and not something to
be picked during the command.
--
Dave D
David Doane
Lectro-Mech Services
lectr...@cyberportal.net
(remove '-' for Email)
Elise Moss <elise...@csi.com> wrote in article
<376AFC13...@csi.com>...
I don't get the same error if I run the code using Lisp Link, only when I run
it from Visual Lisp.
Tony Tanzillo wrote:
> There are now 2 releases of AutoCAD that use
> Visual LISP, so you must state which one you're
> using.
>
> There should be no problem creating text via
> (command).
>
> I ran the following code in AutoCAD 2000, and
> it works just fine:
>
> (setq inspt '(0.0 0.0 0.0))
> (setq th 2.0)
> (command "text" "J" "M" inspt th "0" "HOLE CHART")
>
> Elise Moss wrote:
> >
> > The following code will not work in Visual Lisp... I get an error-
> > Function Cancelled message.
> >
> > There is a curt note in the Visual Lisp documentation stating that
> > Visual Lisp does not allow text creation using the command function, but
> > no data on how one is supposed to create text...(I assume there is some
> > vla-call?)
> >
> > Can anyone translate this code to something Visual Lisp can handle?
> >
> > Thanks.
> >
> > Elise Moss
> >
> > (if (= styht 0.0)
> > (command "text" "J" "M" midpt th "0" "HOLE CHART")
> > ) ; end if
> > (if (/= styht 0.0)
> > (command "text" "J" "M" midpt "0" "HOLE CHART")
> > )
>
For starters, I would eliminate the use of
(=) and (/=) when comparing real numbers, as
this may be a cause of the problem, especially
in cases where you get different results in
Visual LISP and AutoLISP.
Real number comparisons should always be done
with (equal), using the optional third argument:
(equal <number1> <number2> <fuzz>),
where <fuzz> is the largest difference between
<number1> and <number2> allowed for the purpose
of equality testing:
(if (equal styht 0.0 0.00001)
(princ "\nStyle height is 0.0")
(princ "\nStyle height is > 0.0")
)
What I can tell you is that I have absolutely
no problems generating text via (command), in
a number of applications I've written for R14.
Am I right about the (= str str) is used for strings?
Then how about the (eq item item) function?
thanks
amy
Tony Tanzillo wrote in message <376DC8B2...@worldnet.att.net>...
(setq a 1)
1
(setq b 1)
1
(setq c a)
1
(= a b)
T
(eq a b)
nil
(= a c)
T
(eq a c)
T
jrf
Member of the Autodesk Discussion Forum Moderator Program
usually you write your own equality function.
some other useful equality functions are described here:
http://xarch.tu-graz.ac.at/autocad/stdlib/html/func4hkg.htm
=> Table of equality operators
"amy" <amy...@jps.net> wrote:
>Tony:
>thanks for the lesson about the (equal num1 num2 fuzz) now I know how to use
>it...
>
>Am I right about the (= str str) is used for strings?
>
>Then how about the (eq item item) function?
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html
> (setq a 1)
> 1
>
> (setq b 1)
> 1
>
> .....
>
> (eq a b)
> nil <------------ ??????????
Since when? What LISP are you using?
> (eq a b) is used to determine if a and b are
> the _same_ _thing_.
I wouldn't agree with this unconditionally.
Early AutoLISP documentation is primarily at fault
for confusion surrounding the differences between
the various equality predicates.
The (eq) function behaves like (=) for some data
types, but not others. You also cannot use (=)
to compare AutoCAD-specific types like enames and
selection sets.
For example:
(setq a "foo")
(setq b "foo")
(eq a b) -> T
The strings assigned to a and b are not the same
string, they are different strings, but (eq) treats
strings and most other atomic types the same way
that (=) does.
What you say is true only for lists and AutoCAD-
specific types, because (eq) does not look at their
contents. For lists, (equal) only compares the first
nodes to determine if they are the same node (and
hence, the same list). For enames and selection sets,
(eq) treats them as pointers to data, and compares
the values of the pointers, rather than the data
they point to.
For entity names and selection sets, you cannot use
(=), you must use (eq). For lists, you should always
use (equal).
amy wrote:
>
> Tony:
> thanks for the lesson about the (equal num1 num2 fuzz) now I know how to use
> it...
>
> Am I right about the (= str str) is used for strings?
>
> Then how about the (eq item item) function?
>