Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change value of a block by LISP

11 REPLIES 11
Reply
Message 1 of 12
gregorykic
615 Views, 11 Replies

Change value of a block by LISP

Hi all,

How can i update by a lisp program different values in a block ?

 

I have got a Lisp program that insert value from MASSPROP in a block but all value are in mm / mm ² / mm3 / mm4 But I want that all this value are in cm / cm² / cm3 / cm4.

 

Thank you for your help,

11 REPLIES 11
Message 2 of 12
pendean
in reply to: gregorykic

Post the LISP and someone can help you rewrite the code for cm
Message 3 of 12
gregorykic
in reply to: pendean

Here, you can find the Lisp file and the block use.

Message 4 of 12
Balaji_Ram
in reply to: gregorykic

Hi Gregory,

 

Sorry about the long delay.

 

Do you still have this issue ? 

 

Will a manual conversion of the values to cm, cm2, cm3, cm4 from mm, mm2, mm3, mm4 not work ?

For example, 

 

;convert length units from mm to cm

(setq len (/ len 10.0))

 

;convert area from mm2 to cm2

(setq area (/ area 100.0))

 

; convert volume from mm3 to cm3

(setq vol (/ vol 1000.0))

 

; convert area moment of inertia from mm4 to cm4

(set ixx (/ ixx 10000.0))

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 12
gregorykic
in reply to: Balaji_Ram

Hi,

 

Thank you for your reply,

 

In my complete lisp file, I introduce for example  (setq CXX (/ CXX 10))  but I have got en error !

 


Error: bad argument type: numberp: "10.695"

in my case CXX is 10.695

 

how can manage this ?

 

I join my lisp file.

 

thank you for your help,

Message 6 of 12
Balaji_Ram
in reply to: gregorykic

Hi,

 

Since you have already converted cxx to string using rtos, the division fails.

 

converting it back to float using atof should help.

 

(setq cxx (/ (atof cxx) 10))

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 12
gregorykic
in reply to: Balaji_Ram

Thank you very much, for your reply.

I found the solution.

(setq CXXmm (atof CXX))
(setq CXX (cvunit cxxmm "mm" "cm"))

But I need to reconvert cxx in string in order to be use in a list.

Do you have any idea ?

Gregory Ostermeier

EMEA Legal Entity Information: http://www.alcoa.com/global/en/general/legal_europe.asp
Message 8 of 12
gregorykic
in reply to: Balaji_Ram

Thank you very much, for your reply.

 

I found the solution.

 

  (setq CXXmm (atof CXX))  

  (setq CXX (cvunit cxxmm "mm" "cm"))

 

But I need to reconvert cxx in string in order to be use in a list.

 

Do you have any idea ?

Message 9 of 12
Balaji_Ram
in reply to: gregorykic

Sorry, I may be missing something here.

 

will  "rtos" and "atof" not help in doing these conversions to and from string ?

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 10 of 12
gregorykic
in reply to: Balaji_Ram

Well, this command line          (setq cxx (/ (atof cxx) 10))      help a lot !

after this cxx is a real value but in my lisp file after i need to insert in a attribut block but does not work.

 

i join my latest lisp file in pdf, please convert it from pdf to lsp.

 

thank you

Message 11 of 12
Balaji_Ram
in reply to: gregorykic

Hi,

 

The link to the PDF does not work ok. Can you please email me the lisp, drawing file and the provide the steps to reproduce the problem ?

You can email me using balaji dot ramamoorthy at autodesk dot com

 

As I mentioned earlier, will "rtos" and "atof" not help in doing these conversions to and from string ?

 

Also, you can simply not replace cxx by using another variable if that will help.

 

 (setq cxx1 (/ (atof cxx) 10))

; Use cxx for the attributes...

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 12 of 12
gregorykic
in reply to: Balaji_Ram

Hello,

 

Thank you for your help, i foud a solution.

 

I learn Lisp program and I arrive to solve my issue.

 

The file in PDF need to be convert in .lsp to be use in AutoCAD.

 

Thanks again,

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

Post to forums  

Autodesk Design & Make Report

”Boost