Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Parsons, Todd
Message 1 of 10 (452 Views)

ObjectARX->AutoLISP function question...

452 Views, 9 Replies
10-19-1999 10:56 AM
Hello again. Thanks to everyone who helped me out last time... I have
another question, though.
I've been building an ObjectARX app with MFC support for A2K (Map). My
commands have been initialized in the InitApplication() section of the file
with the entry point. I'm using the AddCommand function the ARX wizard sets
up. For example:
AddCommand("CCIIMPORT", "D2IMPT", "D2IMPT", ACRX_CMD_TRANSPARENT,
cciimportd2impt);

That works fine. After doing an appload from command line and typing
"d2impt", everything pops up. This function should be called from an
Autolisp routine, though, but it doesn't work as is from within the
Autolisp... So I tried changing the flags:
AddCommand("CCIIMPORT", "D2IMPT", "D2IMPT",
ACRX_CMD_TRANSPARENT|ACRX_CMD_DEFUN, cciimportd2impt);

Well, when I do that, neither the Autolisp routine or the command line
recognize it any more. Any suggestions? I need to use acedRetStr to send a
command string back to the Autolisp routine. Any help would result in my
undying gratitude! :smileyhappy:

--Todd Parsons, CCI
*Tanzillo, Tony
Message 2 of 10 (452 Views)

Re: ObjectARX->AutoLISP function question...

10-19-1999 11:13 AM in reply to: *Parsons, Todd
You don't say how you're calling the ARX command from LISP.

Are you using (command)?

Todd Parsons wrote:
>
> Hello again. Thanks to everyone who helped me out last time... I have
> another question, though.
> I've been building an ObjectARX app with MFC support for A2K (Map). My
> commands have been initialized in the InitApplication() section of the file
> with the entry point. I'm using the AddCommand function the ARX wizard sets
> up. For example:
> AddCommand("CCIIMPORT", "D2IMPT", "D2IMPT", ACRX_CMD_TRANSPARENT,
> cciimportd2impt);
>
> That works fine. After doing an appload from command line and typing
> "d2impt", everything pops up. This function should be called from an
> Autolisp routine, though, but it doesn't work as is from within the
> Autolisp... So I tried changing the flags:
> AddCommand("CCIIMPORT", "D2IMPT", "D2IMPT",
> ACRX_CMD_TRANSPARENT|ACRX_CMD_DEFUN, cciimportd2impt);
>
> Well, when I do that, neither the Autolisp routine or the command line
> recognize it any more. Any suggestions? I need to use acedRetStr to send a
> command string back to the Autolisp routine. Any help would result in my
> undying gratitude! :smileyhappy:
>
> --Todd Parsons, CCI

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
*Parsons, Todd
Message 3 of 10 (452 Views)

Re:

10-19-1999 11:24 AM in reply to: *Parsons, Todd
> You don't say how you're calling the ARX command from LISP.
>
> Are you using (command)?

Yes... For example (just to test it):

(defun C:smileyvery-happy:2 ()
(arxload "m:/!code/import2/release/cciimport2")
(while (not (= status 'DONE))
(d2impt)
))

(d2impt has acedRetStr("setq status 'DONE") at the end)... Attempting to
call d2 from the command line succesfully loads cciimport2.arx, but returns:
; error: no function definition: D2IMPT
Any suggestions?

--Todd Parsons, CCI
*Tanzillo, Tony
Message 4 of 10 (452 Views)

Re:

10-19-1999 11:31 AM in reply to: *Parsons, Todd
No, you're not using (command).

This uses (command):

(command "D2IMPT" ...)

To call it as a function (as in (d2impt ...)) you must
define the function with acedDefun() and acedRegFunc(), and
I believe you must do that in the kLoadDwg message, as LISP
functions are document-specific.

Todd Parsons wrote:
>
> > You don't say how you're calling the ARX command from LISP.
> >
> > Are you using (command)?
>
> Yes... For example (just to test it):
>
> (defun C:smileyvery-happy:2 ()
> (arxload "m:/!code/import2/release/cciimport2")
> (while (not (= status 'DONE))
> (d2impt)
> ))
>
> (d2impt has acedRetStr("setq status 'DONE") at the end)... Attempting to
> call d2 from the command line succesfully loads cciimport2.arx, but returns:
> ; error: no function definition: D2IMPT
> Any suggestions?
>
> --Todd Parsons, CCI

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
*Parsons, Todd
Message 5 of 10 (452 Views)

Re:

10-19-1999 11:56 AM in reply to: *Parsons, Todd
> No, you're not using (command).
> This uses (command):
> (command "D2IMPT" ...)

Fair enough... As I've said before, I'm new to this environment. Trying
that, I can certainly call the command from within Autolisp. I was hoping
to be able to use the ACRX_CMD_DEFUN flag within
acedRegCmds->addCommand to set it as a function... But, adding that in
makes it inoperable everywhere.

> To call it as a function (as in (d2impt ...)) you must
> define the function with acedDefun() and acedRegFunc(), and
> I believe you must do that in the kLoadDwg message, as LISP
> functions are document-specific.

Ok, I'll look more closely at acedDefun, etc... The second argument for
that is an int... I've seen that as an index into a function table... Is
that still the way it works? Thanks again for the help.

--Todd Parsons, CCI
*Tanzillo, Tony
Message 6 of 10 (452 Views)

Re:

10-19-1999 12:04 PM in reply to: *Parsons, Todd
Well - According to the docs, ACRX_CMD_DEFUN should make the
function available, but it obviously isn't working.

You don't have to look up function codes if you use acedRegFunc()
to define the function. In that case, the function handler is
called directly, rather than through the kInvokeSubr message in
acrxEntryPoint().

Todd Parsons wrote:
>
> > No, you're not using (command).
> > This uses (command):
> > (command "D2IMPT" ...)
>
> Fair enough... As I've said before, I'm new to this environment. Trying
> that, I can certainly call the command from within Autolisp. I was hoping
> to be able to use the ACRX_CMD_DEFUN flag within
> acedRegCmds->addCommand to set it as a function... But, adding that in
> makes it inoperable everywhere.
>
> > To call it as a function (as in (d2impt ...)) you must
> > define the function with acedDefun() and acedRegFunc(), and
> > I believe you must do that in the kLoadDwg message, as LISP
> > functions are document-specific.
>
> Ok, I'll look more closely at acedDefun, etc... The second argument for
> that is an int... I've seen that as an index into a function table... Is
> that still the way it works? Thanks again for the help.
>
> --Todd Parsons, CCI

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
*Blattel, Byron
Message 7 of 10 (452 Views)

Re:

10-19-1999 01:27 PM in reply to: *Parsons, Todd
The easy way to do this in A2K is to use the ads_defun() option instead
of the addCommand() option in the ARX wizard :smileyhappy:

Tony Tanzillo wrote:
> >
> > > To call it as a function (as in (d2impt ...)) you must
> > > define the function with acedDefun() and acedRegFunc(), and
> > > I believe you must do that in the kLoadDwg message, as LISP
> > > functions are document-specific.
> >
> > Ok, I'll look more closely at acedDefun, etc... The second argument for
> > that is an int... I've seen that as an index into a function table... Is
> > that still the way it works? Thanks again for the help.
> >
> > --Todd Parsons, CCI

|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
|
| e-mail: cadwerx@texas.net
| web site: http://lonestar.texas.net/~cadwerx
|
*Parsons, Todd
Message 8 of 10 (452 Views)

Re:

10-19-1999 02:15 PM in reply to: *Parsons, Todd
> The easy way to do this in A2K is to use the ads_defun() option instead
> of the addCommand() option in the ARX wizard :smileyhappy:

I'm noticing that. :smileyhappy: Here's what I put in:
void InitApplication()
{
...
acedDefun("d2impt", 0);
acedRegFunc(&cciimportd2impt, 0);
...}

I just put those in right in InitApplication, and it now works as a
function (d2impt )... However, when I exit out of d2impt, Autolisp
(cmdline) returns "ADS request error"... And I'm calling
acedRetStr(returnval), where CString returnval="(setq status 'DONE)";
*shrug* I'll keep plugging away at this... Just need to get one case where
it works and I'm set. :smileyhappy: Thanks again.

--Todd Parsons, CCI
*Parsons, Todd
Message 9 of 10 (452 Views)

Re:

10-19-1999 02:29 PM in reply to: *Parsons, Todd
> The easy way to do this in A2K is to use the ads_defun() option instead
> of the addCommand() option in the ARX wizard :smileyhappy:

Allrighty, ads_defun() was being screwy on me earlier, but after giving
it another go, everything's going right. Excellent. That certainly works a
lot nicer than what I was doing by hand. :smileyhappy:

--Todd Parsons, CCI
*Urban, Reini
Message 10 of 10 (452 Views)

Re:

10-21-1999 07:48 AM in reply to: *Parsons, Todd
Todd Parsons wrote:
> I just put those in right in InitApplication, and it now works as a
> function (d2impt )... However, when I exit out of d2impt, Autolisp
> (cmdline) returns "ADS request error"... And I'm calling
> acedRetStr(returnval), where CString returnval="(setq status 'DONE)";

you need to return RSRSLT not RTNORM -which is returned by acedRetStr()-
once you regfunc'ed it.
otherwise you'll get this error.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.