Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About IDE some questions?

13 REPLIES 13
Reply
Message 1 of 14
2e4lite
539 Views, 13 Replies

About IDE some questions?

       1.Why local variables defined in the Visual LISP detection in IDE will put local variable as global variables?
       2.In other application processing, why IDE window often automatically jump out, become the current window?
       3.When the IDE is opened, the computer can not stand?

13 REPLIES 13
Message 2 of 14
paullimapa
in reply to: 2e4lite

Question: 1.Why local variables defined in the Visual LISP detection in IDE will put local variable as global variables?

Answer:   1. Provide example as to how you are declaring the variables locally in IDE


Question: 2.In other application processing, why IDE window often automatically jump out, become the current window?

Answer:   2.IDE may be responding to AutoCAD.  If IDE not in use, close IDE application.

 

Question: 3.When the IDE is opened, the computer can not stand?

Answer:   3. Clarify what you mean "stand"?

 

 

 

Area Object Link | Dwg Setup | Feet-Inch Calculator | List on Steroids
Exchange App Store

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 14
JamesMaeding
in reply to: 2e4lite

local vars must be after the / in defun like:

defun ( / <locals here>)

 

The lisp ide is old and does not behave that great IMO. I commonly have to either minimize all windows, then max acad, then max ide to get going.

Or I do Windows->Activate acad, that helps too.

 

The computer can stand if IDE is open, ad even likes is sometimes, so what do you mean?


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 4 of 14
Lee_Mac
in reply to: 2e4lite

2e4lite wrote:

       1.Why local variables defined in the Visual LISP detection in IDE will put local variable as global variables?

 

If a local variable is referenced within an anonymous lambda function it will be listed as global by the VLIDE checking utility, since the symbol referenced within the lambda function is not declared local to the lambda function and is hence global as far as the scope of the lambda function is concerned, e.g.:

 

(defun foo ( / bar )
    (setq bar 1.0)
    (mapcar '(lambda ( x ) (+ x bar)) '(1 2 3 4 5))
)

 

Message 5 of 14
inventordeepan
in reply to: Lee_Mac

hi dr lee mac i hope you can help me with it ,

i need to do some calculation in excell and use the answer as values to my autolisp prog

i mean lik for instance i need to add cell a1 an a2 value and assign it to a variable in autolisp code say to variable a , frm net i got some source to get data from excell . so i request you dr programmer whether you know any code to input values to cells in a new excel sheet and also perform some addition and den retrive value from excell sheet and assign it to a variable say setq a excel data .

 

 

plse some one help asap

 

 

thank you in advance ...:smileywink:

Message 6 of 14

hi lee mac can u let me whether i can use our lisp code to serve as a default code ..

 

ex line command can be called by any lisp  program like (command "line" )

is there any provision tha we too can apply our lisp command in same way ,

 

for instance my command is mir can iuse this in another seperate unrelated lisp like (command "mir" )

 

 

reply asap,

thanks in advance ,

 

Deepan .

Message 7 of 14


@inventordeepan wrote:

hi lee mac can u let me whether i can use our lisp code to serve as a default code ..

 

ex line command can be called by any lisp  program like (command "line" )

is there any provision tha we too can apply our lisp command in same way ,

 

for instance my command is mir can iuse this in another seperate unrelated lisp like (command "mir" )

.....


If mir is a command, defined with (defun C:MIR ..., then you can start it from within other AutoLISP code with this format:

 

(C:MIR)

 

If it is a non-command function, defined with (defun MIR ..., then you can start it this way:

 

(MIR <arguments if any>)

Kent Cooper, AIA
Message 8 of 14

I think the answer is yes, you can call some function defined in another lisp, from another lisp.

You would call like (c:somecommand)

 

you would not call with (command "somecommand") though it may work, I forget, as its just odd IMO.

 

You see, the acad environment does not know where a lisp function came from once loaded.

It allows one lisp function to overwrite another, so the last one loaded wins.

 

I must have 50 lisp files that make up my civil program, and none have duplicate function names.

The best idea is to have a library lisp with generidc functions, then a lisp file for main program, then a lisp for each dialog box.

 

That mimics what you would do in .net or VBA where each form has a code page, except that thos languages treat vars and functions as "local" by default, where lisp treats them global by default.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 9 of 14
Kent1Cooper
in reply to: JamesMaeding


@jmaeding wrote:

.... 

you would not call with (command "somecommand") though it may work, I forget....


No, it doesn't.  The AutoLISP (command) function will recognize only AutoCAD's own command names [provided they haven't been undefined], and not any (defun)'d command definitions.  If a command has been undefined and redefined with (defun), (command) won't recognize the name of the redefinition even if it's the same as the native AutoCAD command's name.  For instance, my ol' Architectural Desktop 2004 here undefines the Layer command and creates its own expanded definition.  If I try to use (command "layer" ...), it fails with a no-such-command-name error message, because here, that's now a (defun)'d command name, and it can't work with those.  I have to use (command ".layer" ...) to force it to dig into the native AutoCAD command definition.

Kent Cooper, AIA
Message 10 of 14
JamesMaeding
in reply to: Kent1Cooper

so a good reminder to anyone reading, you can call an undefined command with . before the name.

 

Since we are talking about the IDE here, I would advide the OP to lok at compiling to vlx, with separate namespace on.

This will "localize" your non-C: functions so you could have duplicate function names within a prog and one prog would not overwrite the others internal functions.

Then, make use of the vlide "projects", as they allow easy loading of all lisps in a project, and also switching by double-clicking an item in the file list. I could not live without that.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 11 of 14
Lee_Mac
in reply to: Kent1Cooper

Kent1Cooper wrote:
jmaeding wrote:

.... 

you would not call with (command "somecommand") though it may work, I forget....

 

No, it doesn't.  The AutoLISP (command) function will recognize only AutoCAD's own command names [provided they haven't been undefined], and not any (defun)'d command definitions.

 

The exception is when vlax-add-cmd has been used.

 

Aside, posts #5 onwards really belong in a separate thread as they are do not relate to the OP's question.

Message 12 of 14

thank you all for spending some valuable time with me ,

i wil tel the problem let see who is so knowledgeable to kill this prob

 

my prob is say i have a lisp code

(defun C:im()

(setq a 3 ) (princ a )  (princ ) )

 

has u ppl answered i can use a script file with lines

 

(c:im)

 

to invoke this lisp command automatically .

 

now i want to know is there any soluction that i can use excel vba to call this script file invoke it  nad run it to do princ statement for me

 

i also wnt to know is there any vba code so that i cna asssign value to variable a which is of integer datatype using vba code

 

 

such that i can remove setq statement in my lisp code mwntioned above and i can just print the value assigned by the vba code fir variable "a" and just use it ....

 

 

 

reply asap

 

 

thank you all inadvance ... Smiley Wink

Message 13 of 14
JamesMaeding
in reply to: Lee_Mac

wow, some good tips here.

This is why I wish this DG had something besides the web interface.

Its just not suitable for daily checking of headers IMO.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 14 of 14

ok, so you want to control autocad from VBA. That is not a beginner thing to do, but is possible.

You will have to get a reference to the autocad object from windows, and use that to send a command to the command line.

 

you need to do some searches using "com control autocad excel" words to find the code needed.

Lee might have the code handy.

We used to do this kind of thing when making batch scripters with VB. Been a while though.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost