Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Visual Lisp and text

1 view
Skip to first unread message

Elise Moss

unread,
Jun 18, 1999, 3:00:00 AM6/18/99
to
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")
)


Tony Tanzillo

unread,
Jun 19, 1999, 3:00:00 AM6/19/99
to
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")

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/

David Doane

unread,
Jun 19, 1999, 3:00:00 AM6/19/99
to
Not that this has anything to do with Visual Lisp, but In addition to what
Tony has suggested, you might try combining the two 'if's' into one:

(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>...

Elise Moss

unread,
Jun 20, 1999, 3:00:00 AM6/20/99
to
Well, then there must be some other issue then. Because when I run the
command AutoCAD hangs at the rotation angle prompt and won't go any farther.
This is in ACADR14.

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")
> > )
>

Tony Tanzillo

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
The code you posted is incomplete, so I really
can't tell you what you might be doing wrong
without seeing the balance of it (mainly, the
origin of the styht variable).

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.

amy

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
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?

thanks
amy

Tony Tanzillo wrote in message <376DC8B2...@worldnet.att.net>...

Jon Fleming

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
(eq a b) is used to determine if a and b are the _same_ _thing_. This is much
more stringent than being equivalent or equal.

(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

Reini Urban

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
= is the most generic atomic equality function, for numbers, symbols
and strings, but not lists.
EQ is the most specific (fastest) function, usable only for symbols,
compiled functions and other atomic objects.
EQUAL is used for two purposes:
1) it recurses into lists (list and tree-comparison), and
2) it checks reals with a fuzzy factor.

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

Tony Tanzillo

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
Jon Fleming wrote:

> (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.

Tony Tanzillo

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
The (eq) function behaves like (=) for any type that
the latter can accept (in fact, I generally do not use
(=) except for when I need to compare more than two
values).

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?
>

amy

unread,
Jun 24, 1999, 3:00:00 AM6/24/99
to
thanks to all of you

amy


Tony Tanzillo wrote in message <376E8585...@worldnet.att.net>...

0 new messages