- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have the next problem.
A lot of my blocks in a drawing have a great number of attributes, with many serial tags namely NAME01, NAME02, .. NAME32.
Other are KIND01, KIND02, .. KIND32 etc.
I try to run a personal AutoLISP program having a function (CngAttr) to change each attribute tag value.
Every attribute has a corresponding cell in a DCL file, so their values are changing frequently, but this is the purpose of my AutoLISP program.
My function has three arguments and its call is like (CngAttr "NAME01" (nth (atoi (get_tile "NAME01")) LNAME01) *Blk_name*) where:
NAME01 is the key of the cell in the DCL file associated with the attribute
LNAME01 is the name of the AutoLISP variable which acts as a recipient of the tile value to be processed by the CngAttr function
*Blk_name* is the name of the block with a tag attribute named NAME01
My solution is actually to use the next (32) repeated code:
(CngAttr "NAME01" (nth (atoi (get_tile "NAME01")) LNAME01) *Blk_name*)
(CngAttr "NAME02" (nth (atoi (get_tile "NAME01")) LNAME02) *Blk_name*)
.
.
(CngAttr "NAME32" (nth (atoi (get_tile "NAME01")) LNAME32) *Blk_name*)
As you can see, I have to manually change LNAME01 with LNAME02 .. LNAME32, and I have to make this also for the strings "NAME01" etc..
When I have strings only, I change "NAME01" with (strcat "NAME" CC), where CC is the subject for a while or repeat cycle from 1 to 32, of course.
To be more specific, I also use other functions instead CngAttr, which have more then one line of code, where I have to manually change 01 with 02 etc. to 32 for many boring times. Sometimes a whole function must be repeated, so I reached now 98 forms to load for a not so difficult program to run.
Given the necessity of refining the program, which imply many changes to the code, when I make a change to a code zone with "01", I have to make the same change to "02", "03" a.s.o.. This is why I made a brand new AutoLISP program called CodeMultiply.lsp to change the text of my AutoLISP program file by inserting some (commented) marks in the code. Using that program I am happy - I change the code zone with "01"in the original program, then I run CodeMultiply, and all the changes are correctly incremented - so you see how cheap can be the happiness for an individual...
I have to do this because I have no idea of how to create a simulation of an array (like say, BASIC arrays, where the variable LNAME01 can be defined as LNAME(01) by using the Dim NAME(32) As Byte statement, for instance). You note that my big obstacle is the changing of the bloody name of a LISP variable, not the changing of a string value.
Since LISP is the language for Artificial Inteligence, I suppose that there must be a magic procedure in AutoLISP by using list functions like eval, cons or read and so on to create such structures, isn't it?
If you have a solution for my problem I would be delighted, believe me...
When I shall present a new short and compact program of say, 50 forms instead of 100, to my boss I am sure that this would have a big impact...
Yours,
Constantin from Romania
PS: Sorry for my long story and for my poor English, BTW!
Solved! Go to Solution.