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

Visual LISP and Geomcal functions

374 views
Skip to first unread message

Jim Fisher

unread,
Mar 31, 1998, 3:00:00 AM3/31/98
to

I've been trying to debug a program I have in the VL IDE and everytime I
use the geometry calculator, all the functions return 'nil'. Is this a
known limitation? :-/

Here's a small sample that should draw a line, but doesn't because 'pt2' is
never set to anything ... I also noticed that 'cal' never seems to get
loaded. Is there some other trick to using functions from an external ARX
file from within the IDE?

(defun c:geomtest ( / pt1 pt2)
(if (not cal)(arxload "geomcal"))
(setq ; <-- set a break point here and a watch on pt1, pt2 & what
; to see that pt2 never gets set but geomcal gets loaded
what (arx)
pt1 (getpoint "\nPick a point: ")
pt2 (cal "pt1+[3,5,0]")
)
(command "_.line" pt1 pt2 "")
(princ)
)

I know that the geometry calculator is being loaded because it's in the
list returned by (arx). Also, if you save this to a file, and load/run it,
it works perfectly.

- Jim

Tony Tanzillo

unread,
Mar 31, 1998, 3:00:00 AM3/31/98
to

If you refer to a LISP symbol in a GeomCal expression,
the symbol's value is obtained from AutoLISP, not from
Visual LISP. Since Geomcal does not know what Visual
LISP is, it can't get the symbol's value in the VLISP
environment.

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* Member of the OpenDWG Alliance */
/* Co-Author of Maximizing AutoCAD R13 and */
/* Maximizing AutoLISP for AutoCAD R13/R14 */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
Jim Fisher wrote in message <01bd5c68$0c5393c0$5ec60ccf@reptar>...

Ralph Gimenez

unread,
Mar 31, 1998, 3:00:00 AM3/31/98
to Jim Fisher

Jim Fisher wrote:

Jim,


I use the geometry calculator all the time from within Vital LISP,
Visual LISP, VLX'x, Fas and Lisp combined arx files. Here is a copy of
my arxload.xdf.file

If you want your compiled files and Visual LISP IDE to use any external
arx command/functions you must include them in the xdf file. Otherwise
Visual LISP is unaware of these functions.


;; VISUAL LISP/VLATS/VLRTS can call EXRXSUBRs that have been defined and
implemented
;; by other ADS applications. The problem is in providing VISUAL
LISP/VLATS/VLRTS
;; with information about EXRXSUBRs names defined by each ARX
;; application you intend to use within VISUAL LISP/VLATS/VLRTS.
;; VISUAL LISP/VLATS/VLRTS try to get this information from this file.
;; You should extend the information contained here according to your
;; needs.
;; For example, if you want to use FACT, standart ADS application,
;; you have to insert in "ARXLOAD.DFS" the following line (without
comments):
;; ("FACT" SQR FACT)
;; where "FACT" is application's file-name without directory and
extention,
;; SQR and FACT - functions, that this application defines.

;; VISUAL LISP/VLATS/VLRTS can call EXRXSUBRs that have been defined and
implemented
;; by other ADS applications. The problem is in providing VISUAL
LISP/VLATS/VLRTS
;; with information about EXRXSUBRs names defined by each ARX
;; application you intend to use within VISUAL LISP/VLATS/VLRTS.
;; VISUAL LISP/VLATS/VLRTS try to get this information from this file.
;; You should extend the information contained here according to your
;; needs.
;; For example, if you want to use FACT, standart ADS application,
;; you have to insert in "ARXLOAD.DFS" the following line (without
comments):
;; ("FACT" SQR FACT)
;; where "FACT" is application's file-name without directory and
extention,
;; SQR and FACT - functions, that this application defines.

(
"14*" ; ACADVER wcmatch tag


("ACADAPP" ; module name
C:PSDRAG ; 0
MTPROP ; 1
MTEDIT ; 2
C:PSFILL ; 3
;;ACAD_STRLSORT ; 4
C:DDIM ; 5
BHERRS ; 6
BHATCH ; 7
BPOLY ; 8
C:PSIN ; 9
ACAD_COLORDLG ; 10
STARTAPP ; 11
ISMNUGRPLOADED ; 12
INITDIA ; 13
)
("ACADPS" ; module name
PSGEN ; 0
PSERR ; 1
PSDO ; 2
)
("ACMTED" ; module name
MTPROP ; 0
MTEDIT ; 1
)
("ASE" ; module name
ASE_LSSUBTRACT ; 0
ASE_LPGETPRIMARY ; 1
ASE_ERRMSG ; 2
ASE_LSFREE ; 3
ASE_LPUPD ; 4
ASE_ERRQTY ; 5
ASE_VERSION ; 6
ASE_LSINTERSECT ; 7
ASE_LSQTY ; 8
ASE_LPPATH ; 9
ASE_DOPATHCODE ; 10
ASE_LPCREATE ; 11
ASE_LSXNAMES ; 12
ASE_DOPATHMAKE ; 13
ASE_LSCMP ; 14
ASE_LPGETSECONDARYNAMES ; 15
ASE_ERRCLEAR ; 16
ASE_LSGET ; 17
ASE_LINKCREATE ; 18
ASE_LSISUPDATABLE ; 19
ASE_LSCOPY ; 20
ASE_LSLPNAMES ; 21
ASE_LPISPRIMARYFOR ; 22
ASE_LSINTERSECTFILTER ; 23
ASE_LSADD ; 24
ASE_DOLIST ; 25
ASE_LSENTSEL ; 26
ASE_LSDEL ; 27
ASE_DOPATHNAME ; 28
ASE_ERRCODE ; 29
ASE_LINKREMOVE ; 30
ASE_DOSTATUS ; 31
ASE_LINKUPDATE ; 32
ASE_LSERASE ; 33
ASE_ADS_API ; 34
ASE_LPLIST ; 35
ASE_LPKEY ; 36
ASE_LPCREATESECONDARY ; 37
ASE_LPISUPDATABLE ; 38
ASE_DOCURRENT ; 39
ASE_LPISSECONDARY ; 40
ASE_ERRDSC ; 41
ASE_LPISPRIMARY ; 42
ASE_LSUNITE ; 43
ASE_LSCREATE ; 44
ASE_LPERASE ; 45
ASE_DOCMP ; 46
ASE_LSMEMB ; 47
ASE_LPRENAME ; 48
ASE_LINKGET ; 49
ASE_LPISSECONDARYOF ; 50
ASE_SSFREE ; 51
)
("ASILISP" ; module name
ASI_CMPIDENT ; 0
ASI_DEALLOCSTM ; 1
ASI_FETCH ; 2
ASI_SQL ; 3
ASI_OBJLIST ; 4
ASI_STATECSR ; 5
ASI_IEXECUTE ; 6
ASI_DBMS ; 7
ASI_EXECUTE ; 8
ASI_OPEN ; 9
ASI_OBJNAME ; 10
ASI_FEATURE ; 11
ASI_VERSION ; 12
ASI_DELETE ; 13
ASI_DISCONNECT ; 14
ASI_LISPVERSION ; 15
ASI_DIAG ; 16
ASI_UPDATE ; 17
ASI_CONNECT ; 18
ASI_PREPARE ; 19
ASI_STMTYPE ; 20
ASI_ROWQTY ; 21
ASI_ALLOC ; 22
ASI_PARDSC ; 23
ASI_CMDTYPE ; 24
ASI_CLOSE ; 25
ASI_ERRQTY ; 26
ASI_COLDSC ; 27
ASI_MSG ; 28
ASI_NEXECUTE ; 29
ASI_OBJP ; 30
ASI_GETCFG ; 31
ASI_SETCFG ; 32
)
("BROWSER" ; module name
)

("DORDER" ; module name
)
("DWFIU" ; module name
)
("DWFOUT" ; module name
SETURL ; 0
GETURL ; 1
)
("GEOM3D" ; module name
C:ROTATE3D ; 0
MIRROR3D ; 1
C:ALIGN ; 2
C:MIRROR3D ; 3
ROTATE3D ; 4
ALIGN ; 5
)
("GEOMCAL" ; module name
C:CAL ; 0
CAL ; 1
)
("INTERNET" ; module name
)
("ISM" ; module name
IMAGEADJUST ; 0
)
("MATCH" ; module name
)
("SOLIDS" ; module name
C:SOLPROF ; 0
C:SOLVER ; 1
SOLVER ; 2
C:SOLDRAW ; 3
C:SOLVIEW ; 4
SOLPROF ; 5
)
("RENDER" ; module name
C:RMAT ; 0
C:ANIMLIGHTMOD ; 1
C:SCENE ; 2
C:FOG ; 3
C:FINISH ; 4
C:LSNEW ; 5
C:LSLIB ; 6
C:3DSIN ; 7
C:3DSOUT ; 8
C:RSUB ; 9
C:MATLIB ; 10
C:BACKGROUND ; 11
C:RPREF ; 12
C:SHOWMAT ; 13
C:RFILEOPT ; 14
C:RENDER ; 15
C:SETUV ; 16
C:LIGHT ; 17
C:RENDSCR ; 18
C:STATS ; 19
C:SAVEIMG ; 20
C:LSEDIT ; 21
C:RENDERUPDATE ; 22
C:ANIMGRREAD ; 23
C:REPLAY ; 24
)
)
;;;EOF


Hope this helped

Ralph Gimenez


Tony Tanzillo

unread,
Mar 31, 1998, 3:00:00 AM3/31/98
to

Jim - Try modifying your code like so:

(defun c:geomtest ( / pt1 pt2)
(if (not cal)(arxload "geomcal"))

(setq (getpoint "\nPick a point: "))
(vlisp-export-symbol 'pt1)
(setq pt2 (cal "pt1+[3,5,0]"))


(command "_.line" pt1 pt2 "")
(princ)
)

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* Member of the OpenDWG Alliance */
/* Co-Author of Maximizing AutoCAD R13 and */
/* Maximizing AutoLISP for AutoCAD R13/R14 */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
Jim Fisher wrote in message <01bd5c68$0c5393c0$5ec60ccf@reptar>...

Tony Tanzillo

unread,
Mar 31, 1998, 3:00:00 AM3/31/98
to

Ralph - I'm not sure that solves his problem.

Geomcal can use AutoLISP variables in expressions,
for example (AutoLISP):

Command: (arxload "geomcal")
"geomcal"

Command: (setq d (getdist "\nDistance: "))
Distance: 2.5
2.5

Command: (cal "d+10")
12.5

In VLISP, this is not going to work, because
GEOMCAL is calling ads_getsym() to get the value
of the symbol 'd' in the _AutoLISP environment_,
not the VLISP environment.

In order to the equivalent in Vlisp, you would
have to call (vlisp-export-symbol 'd) to assign
the value of d in VLISP, to the value of d in
AutoLISP:


(defun c:geomtest ( / pt1 pt2)
(if (not cal)(arxload "geomcal"))

(setq (getpoint "\nPick a point: "))
(vlisp-export-symbol 'pt1)
(setq pt2 (cal "pt1+[3,5,0]"))

(command "_.line" pt1 pt2 "")
(princ)
)

--


/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* Member of the OpenDWG Alliance */
/* Co-Author of Maximizing AutoCAD R13 and */
/* Maximizing AutoLISP for AutoCAD R13/R14 */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/

Ralph Gimenez wrote in message <3521978E...@Compuserve.com>...

Tony Tanzillo

unread,
Mar 31, 1998, 3:00:00 AM3/31/98
to

Yes - You can branch conditionally depending on whether
you're running in VLISP or AutoLISP. You can also define
functions conditionally depending on which environment
your code is loaded into.

For example, this function will return T when evaluated
in Visual LISP, and nil when evaluated in AutoLISP:

(defun vlisp? ()
(atom vlisp?)
)

So, with it you can do something like:

(defun c:geomtest ( / pt1 pt2)
(if (not cal)(arxload "geomcal"))
(setq (getpoint "\nPick a point: "))

(if (vlisp?)
(vlisp-export-symbol 'pt1)


)
(setq pt2 (cal "pt1+[3,5,0]"))
(command "_.line" pt1 pt2 "")
(princ)
)

That technique is okay for functions that are called
occasionally, but for ones that are called frequently,
or where performance is an issue, it's generally better
to conditionally define one of two different versions
of a function, eliminating the need to test to see what
environment its running in each time it's called:

(if (vlisp?)
(defun c:geomtest ()
...Visual LISP version...
)
(defun c:geomtest ()
...AutoLISP version...
)
)


--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* Member of the OpenDWG Alliance */
/* Co-Author of Maximizing AutoCAD R13 and */
/* Maximizing AutoLISP for AutoCAD R13/R14 */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/

Jim Fisher wrote in message <01bd5d22$0340ede0$6bc60ccf@reptar>...


>>> Try modifying your code like so: <<
>

>Thanks Tony I'll give it a whirl tonight ... right now I'm really new to
>Visual LISP (never used Vital LISP), and was using it primarily for
>debugging until I can move on to the more advanced features. Is there any
>way to write the code so that it will work in both inside the VL IDE as
>well as when run strictly under ACAD?
>
> - Jim

Jim Fisher

unread,
Apr 1, 1998, 3:00:00 AM4/1/98
to

Thanks, Ralph. I'll save your post to a file and see what happens. Is
this stuff documented somewhere? I'm new to Visual LISP, but have been
writing AutoLISP programs for quite a while. I wanted to try and take
advantage of the debugging capabilities of te IDE until I have the time to
delve into the more advanced features.


- Jim

Jim Fisher

unread,
Apr 1, 1998, 3:00:00 AM4/1/98
to

Link Davis

unread,
Apr 1, 1998, 3:00:00 AM4/1/98
to

I can compile and run Tony's sample, no problem.

But I'm missing something. When I load it to the console, and then go to
Acad, it fails. Other than being dense, what's my problem?

(defun c:geomtest ( / pt1 pt2)
(if (not cal)(arxload "geomcal"))

(setq pt1 (getpoint "\nPick a point: "))
(vlisp-export-symbol 'pt1)

Link Davis

unread,
Apr 3, 1998, 3:00:00 AM4/3/98
to

Still no solution to this...

Link Davis wrote in message <6fttr7$dk...@adesknews2.autodesk.com>...

Ralph Gimenez

unread,
Apr 3, 1998, 3:00:00 AM4/3/98
to Link Davis

Link Davis wrote:

:|
Link,

I think this will clear up some of your questions and doubts.
Just cut and paste into Visual LISP!

Vital LISP 3.2 Documentation ... (from the help file)

Vital LISP can call EXSUBR or EXRXSUBR (that correspond to ARXSubrs in
AutoCAD)
that have been defined by other ADS or ARX applications. However, to
recognize
functions as EXSUBR or EXRXSUBR, Vital LISP relies on information
stored in XDF
(eXternally Defined Functions) files. An XDF file describes which
functions are
defined by which application.

You do not need to define the .XDF file if you do not intend to call
EXSUBRS/EXRXSUBRS from your code running within Vital LISP.
Vital LISP automatically retrieves information from XDF files for all
ADS
or ARX applications that were loaded before Vital LISP IDE or RTS, or
when
ARXLOAD or XLOAD function was called from within Vital LISP
(either from IDE or from Compiled code under RTS). Vital LISP searches
for an
XDF file in the following sequence:

-> in the ADS/ARX application's directory under the same name
as the application,
-> in the directory containing VILLRTS or VILL IDE under
the name XLOAD.XDF or ARXLOAD.XDF.

IMPORTANT: It is necessary to describe EVERY external function to be
called
from within Vital LISP (either IDE or RTS) that is defined in an
external
ADS/ARX module. If such a description is missing, Vital LISP will be
unable
to call that function.

If some application was loaded from the Command: prompt or from other
application after VILL IDE or RTS were loaded, VILL will not be able
to
correctly recognize them. If this may happen an explicit call to

VILL-IMPORT-EXSUBRS function will be necessary. The call format is

(VILL-IMPORT-EXSUBRS '(app-name {entry-name}))

The function takes a list as an argument.

(VILL-IMPORT-EXSUBRS'("c:/ACADR13/WIN/GEOMCAL.EXE" "C:CAL" "CAL"))

The first element should be the application's full name and the rest
are the
name strings for function that should be defined in VILL.

|;


;| Note:
The line below ensures we import Geomcal stuff before we use it.
No guarantee geomcal.arx is loaded ACAD prior to running geomtest.
Note no error checking to see if geomcal.arx is found. |;

(defun Initialize-Geomcal-Stuff ()
;;; Would need some error checking incase someone deleted or moved
goemcal.arx. But that is another story...
(if (not cal)
(arxload "geomcal") )
(VLISP-IMPORT-EXSUBRS (list (FINDFILE "GEOMCAL.ARX") "C:CAL" "CAL"))
T
)

(defun c:geomtest (/ pt1 pt2)
;;; Aha! you need to explicidly call vlisp-mport-exsubrs after your
load or
;;; if your arxload.xdf does not contain geomcal definitions.
;;; (if (not cal)
;;; (arxload "geomcal")
;;; )

;; Just to be on the safe side we'll check for cal and import the
functions once.
(if (null *cal-init* )
(setq *cal-init* (Initialize-Geomcal-Stuff ) )
)

(setq pt1 (getpoint "\nPick a point: "))
(vlisp-export-symbol 'pt1)
(setq pt2 (cal "pt1+[3,5,0]"))
(command "_.line" pt1 pt2 "")
(princ)
)

;;; -------------------------------------------------------------------;

;;; Instructions: ;

;;; ;

;;; 1. Load this into Visual LISP IDE ;

;;; 2. Type geomtest in the ACAD Command: line. ;

;;; 3. Paste the code fragment below into the ACAD Text ;

;;; screen or load into native AutoLISP as an LSP file. ;

;;; ;

;;; -------------------------------------------------------------------;

;;; -------------------------------------------------------------------;

;;; ;

;;; Example of passing values between environments ;

;;; This example uses the value of pt1 (global to ACAD) ;
;;; previuosly exported into ACAD by C:GEOMTEST ;
;;; ;

;;; -------------------------------------------------------------------;

;|

(defun c:UseGeomtest ()
(setq pt2 (cal "pt1+[12,0,0]"))


(command "_.line" pt1 pt2 "")

)

|;

;;;
;;; Hope this helped
;;;
;;; Ralph Gimenez
;;;


Link Davis

unread,
Apr 5, 1998, 4:00:00 AM4/5/98
to

Thanks!

You hit it right when you told me 'if geomcal is already loaded it will be
unavailable to VLisp'.

Thanks again.

0 new messages