• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

scripts, lisp, macros and actions: what differences?

ing.dir

Guest
It will be good to all and apologize if the subject has already been dealt with but I have sought both here and on the net and I have failed to make a clear idea about the matter.
I find myself running on a number of files the same operations, so I looked for a way to automate and optimize everything. Now, in my case I realized that I can solve using the stock recorder and a script to open the folder files in turn and run the created macro.

In general, however, I did not understand what the difference between the various features is. The idea that I did was:
- scripts are the simplest version, it is a list of commands to run in sequence
- the lisp are the most complex tool and to create them you pass through a specific computer language that allows to create more articulated operations
- macros seem to me equivalent to more elaborate scripts, for example, to insert messages in operations. are made from a sequence of actions and can be created or with the voice recorded in the management panel or writing the structure in visual basic

Do you confirm the idea I've done so far?
but above all, help me understand for me understand when using various tools?
Thank you.
 
the lisp is a programming language (in reality the full name would be autolisp, a variant of lisp special for autocad).
the lisp does not perform more complex macros, interacts with the design database and you can go to get (change-create) the characteristics of each individual object of the dwg.
and with these make calculations, choices, extracts etc.
I give you a very rough example:
you have two tilted lines between them of x degrees (you do not know it are there to video).
images to create 4 lines that combine the two tilted exactly to 1/5 of each of them. coordinate laws start and end of each line, read its length, divide it for 5, calculate the coordinates of points at 1/5 of each of the inclined lines, create the line at the first fifth of each, then the second, the third so on.
of course 1/5 can be a variable, so you can ask how many parts you can divide so once the routine divides into 5 parts, another deciduous that should divide into 7 parts etc.

this to make you understand that lisp derives all the characteristics of the entity on which it works, so you can reason us on.
with macros and scripts this is not allowed to you.
a script is actually a set of macros on multiple lines, enclosed in an external file.
a macro is on a single line and you can only call it from an icon.
scripts and macros interact very little with the user and can be used for repetitive actions (type "setting the object from->a and then rotate them in point 0.0, and color change them) .
with lisp on the contrary establish the general criterion and make us calculations (if the object is text then change color and move, wondering how much; if it is a broken line in n parts and rotates the individual parts of the corner you will ask me for each of them).

Sorry the huge post
 
I would like to add that there is the autolisp "base" (let's say so), that is the one present since the first versions of autocad, which could be written exclusively by a text editor (type block notes). from autocad 14 (if not erro!), a new version was introduced, derived from vital-lisp. with this new version has been introduced the visuallisp; which greatly helps programming, as it allows you to run the step-by-step program ... to see where there are programming errors. At the same time commands have been introduced that allow you to perform the same things (and even more things)... at a considerably higher speed.
a language called dcl has also been introduced, which allows you to create interactive windows, with buttons and options to select.
not to mention the activex... this allows you to do unimaginable things... but it is definitely complex: only for experienced programmers.
 
Last edited by a moderator:
... and the diesel where we put it? There is also this language. :

(defun c:acadmode ( )
(setvar "modemacro"
(sing)
" [imath](substr.[/imath](getvar,clayer),1.8)"
"[imath](if,[/imath](getvar,orthomode), orto)"
"[imath](if,[/imath](Snapmode, snap)
OSM:[imath](substr.[/imath](getvar,osmode),1,3)"
" $(getvar,dimstyle)"
"[imath](if,[/imath](=,$(getvar,mode),0),"
"[imath](if,[/imath](=,$(getvar,cvport),1), p)
"
)
)

)

this is an example of diesel language that sets (by means of the lisp), the modemacro variable.
in particular this command allows you to have the situation of active osnap on the lower left, orth mode etc.

we say it was useful several versions ago ... when autocad turned on dos and had less information available to the user.... but it was just to make an example.

the diesel language can also be useful for "manipulate" the values expressed in the "data fields":

a my design called a-nomeclient-23-800.dwg, if I put a data field containing:
[imath](substr.[/imath](Getvar, Dwgname)[imath](-,[/imath](strlen,$(getvar,dwgname)),9),6)

I get '23-800' so I delete the rest of the file name and can easily insert it into my tables, having the certainty that you update when I change customer.

ps.
it was just for completeness... not certain to create confusion to @ing.dir !!
 
Thanks to all for your answers, I have to reread everything calmly but I would say that now I have a clear picture of the situation.
I have decided to set up the cartographic database for days and I need to explode the blocks of the various files. I find myself doing different operations always equal for so many files and I'm taking advantage of it to understand how to optimize things rather than work like a mule.
 
great, thank you, I downloaded it, definitely in the future I want to try to learn at least the basics.
 
in the future I want to try to learn at least the basics.
if you start learning it will catch you, for its power and for the prospects it opens.

If I told you that it is rather trivial to write a lisp that, launched on an open file, is:
take the file name;
search all the blocks in that file.
one by one explodes them;
eliminates the original blocks;
saves the file by adding at the end of the name the suffix "-exploded"
:
 
if you start learning it will catch you, for its power and for the prospects it opens.

If I told you that it is rather trivial to write a lisp that, launched on an open file, is:
take the file name;
search all the blocks in that file.
one by one explodes them;
eliminates the original blocks;
saves the file by adding at the end of the name the suffix "-exploded"
:
It's exactly what I'm trying to do, and after a couple of days of fighting, I think I realized there's no other way than writing a lisp.
I managed to do something similar with a script but I can't explode the blocks because the "previous" command works by writing in the command line but not within the script, hallucinating. the whole thing is complicated by the fact that I must first redefine all the blocks otherwise once exploded end on layer 0 (burst takes more time to explode and xplode with inherited option I don't know why but some blocks send them anyway on zero; In addition they are all in a thousand pieces that I joined in redefiniting them.

Can you tell me if there's any valid example around that I can only use as a starting base?
 
a small update even if you are going a bit out of topic: taking reference some code found around I managed to make some lisp that actually work properly, are amazing in their simplicity.
I have a minimum of programming bases, which I have resumed with python lately, so gross I can orient myself but for now I can only move by messing up already made codes.
satisfaction, however, is enormous, when you download already made lisp, think of a way to simplify your life, but when you put your hand, you realize the enormous potential.
 
If not, autocad (not gstarcad, progecad or zwcad), can also perform python codes...
but here I say it and here I deny it...
However, if you already have an infarination of that language, try to deepen it.
 
I will try to inform myself but it is still a very limited knowledge, mostly I have to look for codes already made around, also because not writing quite often I cannot be autonomous, but at least I know I have an idea of what I am doing.
For the rest, I think it's worth reading a bit of the guide that I've been reported here, even to understand what is written in the scripts that are around.
 
If not, autocad (not gstarcad, progecad or zwcad), can also perform python codes...
but here I say it and here I deny it...
However, if you already have an infarination of that language, try to deepen it.
I don't think so. or at least, not natively. maybe with an additional plugin
 
I don't think so. or at least, not natively. maybe with an additional plugin
in the end I think it is not worth delving into the question since if python is working, the codes are all written as autolisp so better understand something than that.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top