
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello helpful Lisp Writers,
I've made a quick lisp for creating basic Hex Nuts - as looking up dimensions and modeling them became pretty annoying after a while. I could create a library of blocks, but I rather enjoy the lisp approach.
My issue is that the initget/ getkword functions are auto-completing strings which is choosing 1-4" rather than 1", or 3-4" rather than 3" (even when clicking them in the dynamic user prompt - it doesn't recognize the quotation mark). I could get around this by writing out 'one half inch' rather than '1-2"' and so-on, but I'd rather not have to. I've also tried reversing the order of options given from largest to smallest, hoping the integer numbers would be recognized first but this didn't seem to have any affect.
I also had to use a dash rather than a forward slash for fractions as it messes up the prompt - Haven't been able to find a way around that.
(defun C:HN ( / ANS CEN UNITS WAF BOR HEI P C POL CIR) (setvar "CMDECHO" 0) (initget "1-4\" 1-2\" 3-4\" 1\" 2\" 3\"") (setq ANS (getkword "\nChoose nominal hex nut size: [1-4\"/1-2\"/3-4\"/1\"/2\"/3\"] <1\">: ") ) (if (not ANS) (setq ANS "1\"") ) (setq CEN (getpoint "\nSelect center point of hex nut: ") ) (setq UNITS (getvar "LUNITS") ) (setvar "LUNITS" 2) (cond ((= ANS "1-4\"") (setq WAF 11.1125) (setq BOR 6.35) (setq HEI 5.55625)) ((= ANS "1-2\"") (setq WAF 19.05) (setq BOR 12.7) (setq HEI 11.1125)) ((= ANS "3-4\"") (setq WAF 28.575) (setq BOR 19.05) (setq HEI 16.271875)) ((= ANS "1\"") (setq WAF 38.10) (setq BOR 25.4) (setq HEI 21.828125)) ((= ANS "2\"") (setq WAF 76.20) (setq BOR 50.8) (setq HEI 43.65625)) ((= ANS "3\"") (setq WAF 114.3) (setq BOR 76.2) (setq HEI 65.88125)) ) (command "POLYGON" "6" "_NONE" CEN "C" (/ WAF 2)) (setq P (ssget "L") ) (command "CIRCLE" "_NONE" CEN (/ BOR 2)) (setq C (ssget "L") ) (command "EXTRUDE" P "" HEI) (setq POL (ssget "L") ) (command "EXTRUDE" C "" HEI) (setq CIR (ssget "L") ) (command "SUBTRACT" POL "" CIR "") (setvar "LUNITS" UNITS) (setvar "CMDECHO" 1) )
Any help would be appreciated!
Solved! Go to Solution.