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

LISP routine works in 2002 but not in 2009 (except when run in Drawing1.dwg)

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
tsynnott
633 Views, 11 Replies

LISP routine works in 2002 but not in 2009 (except when run in Drawing1.dwg)

Might someone here be able to take a look at the attached LISP routine, which runs successfuly in 2002, to identify why it doesn't run in 2009? (I am a rank rookie when it comes to AutoCAD, and LISP in particular.)
 
The attached LISP routine was written by a user, long gone, to restore titleblock text attributes (size, font, position, etc) and to populate a field in the upper left corner of the drawing border, based on the contents of a title block field.
 
When I run the command in 2009 it clears the contents of the titleblock, replacing the information in each attribute field with an asterisk.
 
More strangley, the command is successful in 2009 under the following circumstance: If I place a border in Drawing1.dwg and DON'T SAVE IT, then populate the titleblock fields, I am able to run the command and see the field in the upper left corner of the drawing border receive information from the 'associated' field in the title block -- just as in 2002. However, once I save Drawing1.dwg as an actual file and run the command again, the title block gets hosed. The following error appears in the command window:
Searching for block TITLE_BLOCK ...Found block TITLE_BLOCK ...; error: no function definition: FLD.

I am in the process of trying to figure out what 'no function definition: FLD' means..

The attached ZIP contains a sample drawing file, the LISP routine, and a docx file with additional information. Any help is appreciated.

11 REPLIES 11
Message 2 of 12
kpblc2000
in reply to: tsynnott

Within strings like these:

(while (/= (fld 0) "SEQEND") <...>

(if (= (fld 0) "ATTRIB") <...>

You are using fld function. But there is no definition for this function. I think it have to be like this:

(defun fld(code)
(cdr (assoc code e)))

but for more effectively i prefer to use like

(defun fld(ent code)
(cdr(assoc code ent)))

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

Message 3 of 12
tsynnott
in reply to: kpblc2000

Thanks for the quick response. Following these three reminders are the results of the changes made to the DLCRETI.LSP:

 

  • The function works in 2002.
  • The function works in 2009 when performed in Drawing1.dwg - that is, when a 2009 file has not been saved
  • Keep in mind I have zero knowledge of LISP (the function was written by a long-retired engineer).

 

I placed the code at the top of the LISP routine.

 

Your 1st suggestion:

 

(defun fld(code)

 (cdr (assoc code e)))

 

Result:

Searching for block TITLE_BLOCK ...

Found block TITLE_BLOCK ...; error: bad argument type: listp <Entity name:

7ef36c28>

 

Your second suggestion:

 

(defun fld(ent code)

(cdr(assoc code ent)))

 

Result:

Searching for block TITLE_BLOCK ...

Found block TITLE_BLOCK ...; error: too few arguments

Message 4 of 12
kpblc2000
in reply to: tsynnott

Ok 🙂 Try this code:

(defun fld(code)

(cdr (assoc code (car e)))

)

Sorry but i haven't enoght time right now 😞

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

Message 5 of 12
tsynnott
in reply to: kpblc2000

 

I understand, and thanks for your effort. (Just to verify -- am I right to place your code suggestions at the top of the file?)
Here is the result produced by your last code suggestion:
Your suggestion:

(defun fld(code)

(cdr (assoc code (car e)))

)

The result: 
Searching for block TITLE_BLOCK ...
Found block TITLE_BLOCK ...; error: bad argument type: consp <Entity name: 
7ef38d00>

 

Message 6 of 12
Moshe-A
in reply to: tsynnott

try this:-

 

(defun fld (code)

 (cdr (assoc code elist))

)

 

 this should work (hope)

 

 moshe

Message 7 of 12
kpblc2000
in reply to: tsynnott

Another one:

(defun fld(code)

(cdr (assoc code (entget e)))

)

 

But i think there is (at least) one another method to walk throught block definition / block reference. I mean vla-methods.

 

I can't test all codes - there is not enough blocks in dwg file 😞

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

Message 8 of 12
tsynnott
in reply to: Moshe-A

Hope springs eternal - that worked! Thank you very much. Any thoughts on why, prior to you fix, the routine was successful when run in an unsaved file?

 

Again, thank you. 

Message 9 of 12
tsynnott
in reply to: kpblc2000

To kpblc2000: 

Your solution also worked! Thank you very much. Any thoughts on why, prior to you fix, the routine was successful when run in an unsaved file?

 

Again, thank you.

Message 10 of 12
pbejse
in reply to: tsynnott

tsynnott.

 

when you ran this routine on an un-saved drawing:

Is the titleblock inserted? or new drawing using a template?

 

perhaps we could re-write your code  using VL as kpblc2000 suggested , The way it is written now appears to be pretty long for such a  small task.

 

Smiley Happy

 

 

 

 

 

 

 

 

 

Message 11 of 12
tsynnott
in reply to: pbejse

pbejse,

Good question. The unsaved version begins as an empty drawing into which the user places the the border and titleblock.

As to your offer, thanks and please allow me a day or so to complete my testing. (I'm not surprised to read this routine is not as efficient as it could or should be; the system of LISP routines used by the design group has been in place for close to 10 years and I assume the engineer who did the code did not have VL.)

Thanks,

Thomas 

Message 12 of 12
kpblc2000
in reply to: tsynnott

Because of this i think the best way is to create reqired block progammatically. It's not diffcult.

---

P.S. Sorre for my English 😞

 

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

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

Post to forums  

Autodesk Design & Make Report

”Boost