Sambuddy Posted December 26, 2019 Posted December 26, 2019 (edited) I am trying to retrieve the current dimension style on an open cad file to execute some of my other lisps instead of (Alert blah...), but am not successful. Could someone take a quick look at this and let me know where I am getting it wrong? i had a quick look at tblnext and tblsearch and I think it is right! but maybe VLA could do this more efficiently - I have not gotten too deep into LISP though. I also have two standards ( "STANDARD" and "Standard") depending on which one is the current dim style my code changes. is there a way to make it Case sensitive? ; condition based on current dim stlye ; "Tx Arial 1.65" "Tx CityBlueprint 2.38" "Standard" (defun c:test (/ D1) (setq D1 (tblnext "DIMSTYLE")) ; getting current dimstyle name (setq D1 (cdr (assoc 2 D1))) ; getting dimstyle name (while (/= D1 nil) ; if dimstyle is not nil then proceed (setq D1(tblsearch "DIMSTYLE" D1)) ;; searching for dimstyle (cond ( (= (cdr (assoc 2 D1)) "Standard") (alert "Standard is selected") ) ( (= (cdr (assoc 2 D1)) "Tx Arial 1.65") (alert "Tx Arial 1.65 is selected") ) ( (= (cdr (assoc 2 D1)) "Tx CityBlueprint 2.38") (alert "Tx CityBlueprint 2.38 is selected") ) ); end cond ); end while (princ) ) Please help SAMPLE DIMENSION.dwg Edited December 26, 2019 by Sambuddy edit text Quote
devitg Posted December 26, 2019 Posted December 26, 2019 please upload your sample.dwg, and the whole sample.lsp Quote
Sambuddy Posted December 26, 2019 Author Posted December 26, 2019 @devitg I am not sure it this helps but I just uploaded the dims. my lisp is complete just imagine instead of Alert I have c:do-1 thanks Quote
marko_ribar Posted December 26, 2019 Posted December 26, 2019 (edited) I think you overprogrammed... Shouldn't this be also good ? (defun c:test nil (cond ( (= (getvar 'dimstyle) "Standard") (alert "Standard is selected") ) ( (= (getvar 'dimstyle) "Tx Arial 1.65") (alert "Tx Arial 1.65 is selected") ) ( (= (getvar 'dimstyle) "Tx CityBlueprint 2.38") (alert "Tx CityBlueprint 2.38 is selected") ) ( t (alert "Current DIMSTYLE not match any of hardcoded choices...") ) ) (princ) ) Edited December 26, 2019 by marko_ribar Quote
Sambuddy Posted December 26, 2019 Author Posted December 26, 2019 Quote marko_ribar I think you overprogrammed... Shouldn't this be also good ? I am ashamed of myself - thank you for the getvar 'dimstyle. I knew there is a variable but I kept looking into -dimstyle and never thought about your approach. Thank you very much marko_rebar I guess I am not the one grinding on boxing day! hah! Happy Holidays Quote
Sambuddy Posted December 26, 2019 Author Posted December 26, 2019 now that I have you here, could you help me with another problem I have been facing: (if (not c:BLAH)(load "BLAH")) is there another way to test whether a lisp is or not? Quote
devitg Posted December 26, 2019 Posted December 26, 2019 (IF (FINDFILE "axpropos.lsp") (LOAD "axpropos.lsp")) Quote
hanhphuc Posted December 26, 2019 Posted December 26, 2019 (edited) 3 hours ago, Sambuddy said: ..... is there a way to make it Case sensitive assume you have list (setq lst '( "STANDARD" "standard" "Tx Arial 1.65" "Tx CityBlueprint 2.38" ) ) case sensitive use wcmatch (alert (strcat (cond ( (car (vl-remove-if-not ''((x) (wcmatch x (getvar 'dimstyle))) lst) ) ) ("oops! Nothing")) " is selected" ) ) FWIW another but not case sensitive (alert (if (setq x (vl-position (getvar 'dimstyle) lst)) (strcat (nth x lst) " is selected") "Current DIMSTYLE not match any of hardcoded choices..." ) ) Edited December 26, 2019 by hanhphuc syntax color Quote
Sambuddy Posted January 6, 2020 Author Posted January 6, 2020 @hanhphuc Great! Thank you very much. I can now arrange my lisp based on the dim style criteria much more easier that changing my text every time. Thanks a lot! Quote
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.