abra-CAD-abra Posted October 15, 2015 Share Posted October 15, 2015 I am going insane trying to get this working. Can somebody put me out of my misery? (defun c:demo (/ xprt lst) ;Add Annotation Scales - Metres (setq xprt (getvar 'Expert)) (setvar 'Expert 5) (setq lst '("2000" "2500" "200" "250" "500" "5000")) (foreach annoscale lst (command "_.-ScaleListEdit" "Add" (strcat "1:" annoscale "m") (strcat "1:" (rtos (/ annoscale 1000.00) 2 2)) "Exit") ) (Setvar 'Expert xprt) (princ)) Cheers, Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 15, 2015 Share Posted October 15, 2015 You are dividing a string on a number so you need to convert it into a number. (/ (read annoscale) 1000.00) Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 15, 2015 Author Share Posted October 15, 2015 Thank you Tharwat - So easy! Much appreciated. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 15, 2015 Share Posted October 15, 2015 Thank you Tharwat - So easy! Much appreciated. You are welcome anytime Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 15, 2015 Author Share Posted October 15, 2015 Hi Tharwat, The 'Read' function didn't resolve the issue, so I tried 'atof' which also didn't work. it fell over at the prompt for the scale ratio. So, with a fresh mind, I opted for a different approach, which appears to function as expected. (defun C:Demo (/ xprt lst) (setq xprt (getvar 'expert)) (setvar 'expert 5) (setq lst (list '("1:1000m" "1:1.0") '("1:2000m" "1:2.0") '("1:2500m" "1:2.50") '("1:200m" "1:0.20") '("1:250m" "1:0.25") '("1:500m" "1:0.50") '("1:5000m" "1:5.0"))) (foreach annoscale lst (command "_.-ScaleListEdit" "_A" (car annoscale) (cadr annoscale) "_E") ) (Setvar 'expert xprt) (princ) ) I would still like to get the first code working. I am trying to make it as concise as possible, not that it necessarily needs to be, it's just a learning curve. Cheers Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 16, 2015 Share Posted October 16, 2015 Consider the ATOI function. Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 18, 2015 Author Share Posted October 18, 2015 Thank you BlackBox I will revisit the code again with the 'atoi' function, when I get chance. Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.