Author Topic: LISP Guru needed  (Read 6028 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP Guru needed
« on: August 15, 2012, 04:42:16 PM »
OK, so as you might know, or not, I dont use LISP on a regular basis.  What I need is for a GURU who has time, to spend about 30 minutes looking over my poorly written code and make suggestions.  An example of my bad code is the use of COMMAND to create geometry when I should be using ? ? ?.  Its been about 10 years since I have used LISP heavily, and I have never learned the VLISP commands.  Any takers, PM me for more info.
 
edit to remove smiley
« Last Edit: August 15, 2012, 04:48:11 PM by CmdrDuh »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: LISP Guru needed
« Reply #1 on: August 15, 2012, 05:01:17 PM »
PM'd

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: LISP Guru needed
« Reply #2 on: August 15, 2012, 09:27:26 PM »
David,
If Lee can't make the time, give me a yell.

(though I don't qualify as a guru ) :)

Regards
Kerry
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BlackBox

  • King Gator
  • Posts: 3770
Re: LISP Guru needed
« Reply #3 on: August 16, 2012, 03:31:59 AM »
I would hardly consider myself to be a 'guru', but I'm happy to help as well.
"How we think determines what we do, and what we do determines what we get."

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #4 on: August 16, 2012, 10:18:58 AM »
I can post it here, but I cant seem to make the code-tags work.  It really is SIMPLE, but I know I'm not doing it the most efficient way.  If someone can modify this post to fix the tags, that would help.

Code - Auto/Visual Lisp: [Select]
  1.  (defun c:3dSetup ()
  2.   (setup3d)
  3. )
  4.  
  5. (defun Setup3d ()
  6.   (setvar "3dosmode" 0)
  7.   (setq   *Voltage*      (Getint "Select Voltage for Substation: ")
  8.    *HighBus*      (getint "Select High Bus Height: ")
  9.    *LowBus*      (getint "Select Low Bus Height: ")
  10.    *BusDiameter*      (getint "Select Bus Diameter: ")
  11.    *PhaseSpace*      (getint "Select Phase Spacing: ")
  12.    *VerticalBusSpace* (getint "Select Vertical Bus Spacing: ")
  13.   )
  14. )
  15. (defun C:QUICKSetup3d ()
  16.   (setq   *Voltage* 138
  17.    *HighBus* 162
  18.    *LowBus* 90
  19.    *BusDiameter*
  20.     4
  21.    *PhaseSpace*
  22.     120
  23.    *VerticalBusSpace*
  24.     72
  25.   )
  26. )
  27. (defun c:Draw3dWall ()
  28.   (setvar "3dosmode" 0)
  29.   (setq ow (entsel "pick outer wall"))
  30.   (setq iw (entsel "pick inner wall"))
  31.   (command "extrude" ow "" 120)
  32.   (command "extrude" iw "" 125)
  33.   (command "subtract" (cadr ow) "" (cadr iw) "")
  34. )
  35.  
  36. (defun c:HBus ()
  37.   (if (= *BusDiameter* nil)
  38.     (setup3d)
  39.   )
  40.   (Draw3DBus *highbus*)
  41. )
  42.  
  43. (defun c:LBus ()
  44.   (if (= *BusDiameter* nil)
  45.     (setup3d)
  46.   )
  47.   (Draw3DBus *lowbus*)
  48. )
  49.  
  50. (defun Draw3DBus (bushgt)
  51.   (setq   pt1 (getpoint "Select Starting Point of Bus: ")
  52.    pt2 (getpoint pt1 "Select Ending Point of Bus: ")
  53.   )
  54.   (setvar "osmode" 0)
  55.   (setvar "3dosmode" 0)
  56.   (setq   pt1 (list (car pt1) (cadr pt1) bushgt)
  57.    pt2 (list (car pt2) (cadr pt2) bushgt)
  58.   )
  59.   (command "circle" pt1 "D" *BusDiameter*)
  60.   (command "rotate3d" "l" "" "2" pt1 pt2 90)
  61.   (command "rotate" "l" "" pt1 90)
  62.   (command "extrude" "l" "" (distance pt1 pt2))
  63. )
  64.  
  65. (defun insblk (blkname msg1 msg2)
  66.   (if (findfile blkname)
  67.     (progn
  68.       (setq clay (getvar "clayer"))
  69.       (setq osm (getvar "osmode"))
  70.       (setq oth (getvar "orthomode"))
  71.       (setvar "orthomode" 1)
  72.       (setvar "osmode" 32)
  73.       (setvar "3dosmode" 0)
  74.       (setq pt1 (getpoint msg1))
  75.       (setvar "osmode" 512)
  76.       (setq ang (getangle pt1 msg2))
  77.       (command "-layer" "m" "0" "C" 7 "0" "")
  78.       (setvar "osmode" 0)
  79.       (command "-insert"
  80.           blkname
  81.           pt1
  82.           1
  83.           1
  84.           (r->d ang)
  85.       )
  86.       (setvar "orthomode" oth)
  87.       (setvar "osmode" osm)
  88.       (setvar "clayer" clay)
  89.     )
  90.     (Alert "Drawing not found!\nContact D. Hall 3483")
  91.   )
  92. )
  93.  
  94.  
  95.  
  96.  
  97. (defun 3dSwitch   (operator BsHgt / BLKNAME *error*)
  98.   (defun *error* (msg)
  99.     (and osmode (setvar "OSMODE" osmode))
  100.     (and cmdecho (setvar "CMDECHO" cmdecho))
  101.     (and clay (setvar "CLAYER" clay))
  102.     (cond ((not msg))
  103.      ((wcmatch (strcase msg) "*EXIT*,*ABORT*,*CANCEL*,*QUIT*"))
  104.      (t (princ msg))
  105.     )
  106.     (princ)
  107.   )
  108.   (if (= *voltage* nil)
  109.     (setup3d)
  110.   )
  111.   (setq volt (itoa *voltage*))
  112.   (if (/= 3 (strlen volt))
  113.     (setq volt (strcat "0" volt)
  114.     )
  115.   )
  116.  
  117.   (if (= (strcase BsHgt) "LOW")
  118.     (progn
  119.       (if (< *LOWBUS* 98)
  120.    (progn
  121.      (aLERT "Too Low!")
  122.      (exit)
  123.    )
  124.       )
  125.  
  126.  
  127.     )
  128.   )
  129.  
  130.   (if (= (STRCASE BsHgt) "HIGH")
  131.     (SETQ BSHGT (ITOA *HIGHBUS*))
  132.     (SETQ BSHGT (ITOA *LOWBUS*))
  133.   )
  134.  
  135.   (SETQ   BLKNAME   (STRCAT   "SW-"
  136.          VOLT
  137.          "-"
  138.          OPERATOR
  139.          "-"
  140.          (ITOA *PHASESPACE*)
  141.          "-"
  142.          BSHGT
  143.          ".DWG"
  144.       )
  145.   )
  146.   (setq   ms1 "\nPick Insertion Point: "
  147.    ms2 "Pick Operator Side: "
  148.   )
  149.   (insblk blkname ms1 ms2)
  150.  
  151. ;;;  (if (findfile BLKNAME)
  152. ;;;    (progn
  153. ;;;      (setq clay (getvar "clayer"))
  154. ;;;      (setq osm (getvar "osmode"))
  155. ;;;      (setvar "3dosmode" 0)
  156. ;;;      (setq oth (getvar "orthomode"))
  157. ;;;      (setvar "orthomode" 1)
  158. ;;;      (setvar "osmode" 32)
  159. ;;;      (setq pt1 (getpoint "\nPick Insertion Point: "))
  160. ;;;      (setvar "osmode" 512)
  161. ;;;      (setq ang (getangle pt1 "Pick Operator Side: "))
  162. ;;;      (command "-layer" "m" "0" "C" 7 "0" "")
  163. ;;;      (setvar "osmode" 0)
  164. ;;;      (command "-insert"
  165. ;;;          BLKNAME
  166. ;;;          pt1
  167. ;;;          1
  168. ;;;          1
  169. ;;;          (r->d ang)
  170. ;;;      )
  171. ;;;      (setvar "orthomode" oth)
  172. ;;;      (setvar "osmode" osm)
  173. ;;;      (setvar "clayer" clay)
  174. ;;;    )
  175. ;;;    (Alert "Drawing not found!\nContact D. Hall 3483")
  176. ;;;  )
  177.   (*error* nil)
  178. )
  179.  
  180.  
  181. (defun 3dInsBS (BsType BsPhase BsHgt / BsSpace blkname)
  182.   (if (= *voltage* nil)
  183.     (setup3d)
  184.   )
  185.   (setq volt (itoa *voltage*))
  186.   (if (= (STRCASE BsHgt) "HIGH")
  187.     (SETQ BSHGT (ITOA *HIGHBUS*))
  188.     (SETQ BSHGT (ITOA *LOWBUS*))
  189.   )
  190.   (if (/= 3 (strlen BSHGT))
  191.     (setq BSHGT   (strcat "0" BSHGT)
  192.     )
  193.   )
  194.   (if (/= 3 (strlen volt))
  195.     (setq volt (strcat "0" volt)
  196.     )
  197.   )
  198.   (if (/= (STRCASE BsPhase) "3PHS")
  199.     (progn
  200.       (setq BsPhase "1PHS")
  201.       (setq
  202.    blkname   (strcat   "BS-" volt "-" BsType "-" BsPhase "-" BsHgt
  203.          ".dwg"
  204.              )
  205.       )
  206.     )
  207.     (progn
  208.       (setq BsPhase "3PHS")
  209.       (setq BsSpace (itoa *PhaseSpace*))
  210.       (setq
  211.    blkname   (strcat   "BS-" volt "-" BsType "-" BsPhase "-" BsSpace
  212.          "-" BsHgt ".dwg"
  213.              )
  214.       )
  215.     )
  216.   )
  217.  
  218.   (setq   ms1 "\nPick Insertion Point: "
  219.    ms2 "Pick Working Bus: "
  220.   )
  221.   (insblk blkname ms1 ms2)
  222.  
  223. ;;;  (if (findfile BS)
  224. ;;;    (progn
  225. ;;;      (setq clay (getvar "clayer"))
  226. ;;;      (setq osm (getvar "osmode"))
  227. ;;;      (setq oth (getvar "orthomode"))
  228. ;;;      (setvar "orthomode" 1)
  229. ;;;      (setvar "osmode" 32)
  230. ;;;      (setvar "3dosmode" 0)
  231. ;;;      (setq pt1 (getpoint "\nPick Insertion Point: "))
  232. ;;;      (setvar "osmode" 512)
  233. ;;;      (setq ang (getangle pt1 "Pick Working Bus: "))
  234. ;;;      (command "-layer" "m" "0" "C" 7 "0" "")
  235. ;;;      (setvar "osmode" 0)
  236. ;;;      (command "-insert"
  237. ;;;          BS
  238. ;;;          pt1
  239. ;;;          1
  240. ;;;          1
  241. ;;;          (r->d ang)
  242. ;;;      )
  243. ;;;      (setvar "orthomode" oth)
  244. ;;;      (setvar "osmode" osm)
  245. ;;;      (setvar "clayer" clay)
  246. ;;;    )
  247. ;;;    (Alert "Drawing not found!\nContact D. Hall 3483")
  248. ;;;  )
  249.  
  250. )
  251.  
  252.  
  253.  
  254.  
  255. (defun c:3dInsBkr (/ blkname volt)
  256.   (if (= *voltage* nil)
  257.     (setup3d)
  258.   )
  259.   (setq volt (itoa *voltage*))
  260.   (if (/= 3 (strlen volt))
  261.     (setq volt (strcat "0" volt)
  262.     )
  263.   )
  264.   (setq   blkname   (strcat "BK-" volt ".dwg")
  265.   )
  266.  
  267.  
  268.   (setq   ms1 "\nPick Insertion Point: "
  269.    ms2 "Pick Breaker Cabinet Location: "
  270.   )
  271.   (insblk blkname ms1 ms2)
  272.  
  273.  
  274. ;;;  (if (findfile bkr)
  275. ;;;    (progn
  276. ;;;      (setq clay (getvar "clayer"))
  277. ;;;      (setq osm (getvar "osmode"))
  278. ;;;      (setvar "3dosmode" 0)
  279. ;;;      (setq oth (getvar "orthomode"))
  280. ;;;      (setvar "orthomode" 1)
  281. ;;;      (setvar "osmode" 32)
  282. ;;;      (setq pt1 (getpoint "\nPick Insertion Point: "))
  283. ;;;      (setvar "osmode" 512)
  284. ;;;      (setq ang (getangle pt1 "Pick Breaker Cabinet Location: "))
  285. ;;;      (command "-layer" "m" "0" "C" 7 "0" "")
  286. ;;;      (setvar "osmode" 0)
  287. ;;;      (command "-insert"
  288. ;;;          bkr
  289. ;;;          pt1
  290. ;;;          1
  291. ;;;          1
  292. ;;;          (r->d ang)
  293. ;;;      )
  294. ;;;      (setvar "orthomode" oth)
  295. ;;;      (setvar "osmode" osm)
  296. ;;;      (setvar "clayer" clay)
  297. ;;;    )
  298. ;;;    (Alert "Drawing not found!\nContact D. Hall 3483")
  299. ;;;  )
  300. )
  301.  
  302. (defun elbow (direction busheight)
  303.   (if (= *Busdiameter* nil)
  304.     (setup3d)
  305.   )
  306.   (setq BusDiameter (itoa *Busdiameter*))
  307.   (if (/= 2 (strlen BusDiameter))
  308.     (setq BusDiameter
  309.       (strcat "0" BusDiameter)
  310.     )
  311.   )
  312.  
  313.   (if (= (STRCASE busheight) "HIGH")
  314.     (SETQ busheight *HIGHBUS*)
  315.     (SETQ busheight *LOWBUS*)
  316.   )
  317.  
  318.   (setq   elb (strcat "EL-" BusDiameter direction ".dwg")
  319.   )
  320.  
  321. ;;;  (setq   ms1 "\nPick Insertion Point: "
  322. ;;;   ms2 "Pick Working Bus: "
  323. ;;;  )
  324. ;;;  (insblk blkname ms1 ms2)
  325.  
  326.  
  327.   (if (findfile elb)
  328.     (progn
  329.       (setq clay (getvar "clayer"))
  330.       (setq osm (getvar "osmode"))
  331.       (setvar "3dosmode" 0)
  332.       (setq oth (getvar "orthomode"))
  333.       (setvar "orthomode" 1)
  334.       (setvar "osmode" 32)
  335.       (setq pt1 (getpoint "\nPick Insertion Point: "))
  336.       (setvar "osmode" 512)
  337.       (setq ang (getangle pt1 "Pick Working Bus: "))
  338.  
  339.       (setq pt1   (list (car pt1) (cadr pt1) busheight)
  340.       )
  341.  
  342.  
  343.       (command "-layer" "m" "0" "C" 7 "0" "")
  344.       (setvar "osmode" 0)
  345.       (command "-insert"
  346.           elb
  347.           pt1
  348.           1
  349.           1
  350.           (r->d ang)
  351.       )
  352.       (setvar "orthomode" oth)
  353.       (setvar "osmode" osm)
  354.       (setvar "clayer" clay)
  355.     )
  356.     (Alert "Drawing not found!\nContact D. Hall 3483")
  357.   )
  358.  
  359. )
  360.  
  361. ;;;transition
  362. (defun transition (direction / blkname height BusDiameter)
  363.   (if (= *VerticalBusSpace* nil)
  364.     (setup3d)
  365.   )
  366.   (setq BusDiameter (itoa *Busdiameter*))
  367.   (if (/= 2 (strlen BusDiameter))
  368.     (setq BusDiameter
  369.       (strcat "0" BusDiameter)
  370.     )
  371.   )
  372.   (if (= (STRCASE direction) "DN")
  373.     (SETQ height *HIGHBUS*)
  374.     (SETQ height *LOWBUS*)
  375.   )
  376.   (setq   blkname
  377.     (strcat "TN-"
  378.        BusDiameter
  379.        (itoa *VerticalBusSpace*)
  380.        "-"
  381.        direction
  382.        ".dwg"
  383.     )
  384.   )
  385.   (if (findfile blkname)
  386.     (progn
  387.       (setq clay (getvar "clayer"))
  388.       (setq osm (getvar "osmode"))
  389.       (setvar "3dosmode" 0)
  390.       (setq oth (getvar "orthomode"))
  391.       (setvar "orthomode" 1)
  392.       (setvar "osmode" 32)
  393.       (setq pt1 (getpoint "\nPick Insertion Point: "))
  394.       (setvar "osmode" 512)
  395.       (setq ang (getangle pt1 "Pick Working Bus: "))
  396.       (setq pt1   (list (car pt1) (cadr pt1) height)
  397.       )
  398.       (command "-layer" "m" "0" "C" 7 "0" "")
  399.       (setvar "osmode" 0)
  400.       (command "-insert"
  401.           blkname
  402.           pt1
  403.           1
  404.           1
  405.           (r->d ang)
  406.       )
  407.       (setvar "orthomode" oth)
  408.       (setvar "osmode" osm)
  409.       (setvar "clayer" clay)
  410.     )
  411.     (Alert "Drawing not found!\nContact D. Hall 3483")
  412.   )
  413.  
  414. )
  415. ;;;end transition
  416.  
  417.  
  418. (defun 3dendcap   (captype height)
  419.   (if (= *Busdiameter* nil)
  420.     (setup3d)
  421.   )
  422.   (setq BusDiameter (itoa *Busdiameter*))
  423.   (if (/= 2 (strlen BusDiameter))
  424.     (setq BusDiameter
  425.       (strcat "0" BusDiameter)
  426.     )
  427.   )
  428.   (if (= (STRCASE height) "HIGH")
  429.     (SETQ height *HIGHBUS*)
  430.     (SETQ height *LOWBUS*)
  431.   )
  432.   (setq   endcapblk (strcat "EN-" BusDiameter captype ".dwg")
  433.   )
  434.   (if (findfile endcapblk)
  435.     (progn
  436.       (setq clay (getvar "clayer"))
  437.       (setq osm (getvar "osmode"))
  438.       (setvar "3dosmode" 0)
  439.       (setq oth (getvar "orthomode"))
  440.       (setvar "orthomode" 1)
  441.       (setvar "osmode" 32)
  442.       (setq pt1 (getpoint "\nPick Insertion Point: "))
  443.       (setvar "osmode" 512)
  444.       (setq ang (getangle pt1 "Pick Working Bus: "))
  445.       (setq pt1   (list (car pt1) (cadr pt1) height)
  446.       )
  447.       (command "-layer" "m" "0" "C" 7 "0" "")
  448.       (setvar "osmode" 0)
  449.       (command "-insert"
  450.           endcapblk
  451.           pt1
  452.           1
  453.           1
  454.           (r->d ang)
  455.       )
  456.       (setvar "orthomode" oth)
  457.       (setvar "osmode" osm)
  458.       (setvar "clayer" clay)
  459.     )
  460.     (Alert "Drawing not found!\nContact D. Hall 3483")
  461.   )
  462.  
  463. )
  464.  
  465. (defun 3dInlineNema (direction height)
  466.   (if (= *Busdiameter* nil)
  467.     (setup3d)
  468.   )
  469.   (setq BusDiameter (itoa *Busdiameter*))
  470.   (if (/= 2 (strlen BusDiameter))
  471.     (setq BusDiameter
  472.       (strcat "0" BusDiameter)
  473.     )
  474.   )
  475.   (if (= (STRCASE height) "HIGH")
  476.     (SETQ height *HIGHBUS*)
  477.     (SETQ height *LOWBUS*)
  478.   )
  479.   (setq   inlineNema
  480.     (strcat "IN-" BusDiameter direction ".dwg")
  481.   )
  482.   (if (findfile inlineNema)
  483.     (progn
  484.       (setq clay (getvar "clayer"))
  485.       (setq osm (getvar "osmode"))
  486.       (setq oth (getvar "orthomode"))
  487.       (setvar "3dosmode" 0)
  488.       (setvar "orthomode" 1)
  489.       (setvar "osmode" 32)
  490.       (setq pt1 (getpoint "\nPick Insertion Point: "))
  491.       (setvar "osmode" 512)
  492.       (setq ang (getangle pt1 "Pick Working Bus: "))
  493.       (setq pt1   (list (car pt1) (cadr pt1) height)
  494.       )
  495.       (command "-layer" "m" "0" "C" 7 "0" "")
  496.       (setvar "osmode" 0)
  497.       (command "-insert"
  498.           inlineNema
  499.           pt1
  500.           1
  501.           1
  502.           (r->d ang)
  503.       )
  504.       (setvar "orthomode" oth)
  505.       (setvar "osmode" osm)
  506.       (setvar "clayer" clay)
  507.     )
  508.     (Alert "Drawing not found!\nContact D. Hall 3483")
  509.   )
  510.  
  511. )
  512.  
  513. (defun c:Layoutlines ()
  514.   (command "-layer" "m" "3d-Layout" "C" 6 "" "")
  515. )


edit: the code tag works but I thought it was supposed to color code, oh well
« Last Edit: August 16, 2012, 02:32:38 PM by CmdrDuh »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #5 on: August 16, 2012, 10:21:06 AM »
And it should be said that there is VERY little error checking, just what i have added from the other thread.  I know that needs serious help.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #6 on: August 16, 2012, 10:41:53 AM »
And I can upload the 3d blocks if needed for testing
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: LISP Guru needed
« Reply #7 on: August 16, 2012, 01:48:19 PM »
edit: the code tag works but I thought it was supposed to color code, oh well
If you really want to, then modify the code tags to say what type of code it is. Something like this works for AutoLisp/VisualLisp:
Code: [Select]
[code=cadlisp-7](do something)
;;; Some more code
[/ code] ;Without the space
The above would look like this:
Code - Auto/Visual Lisp: [Select]
  1. (do something)
  2.  ;;; Some more code
  3.  
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Cathy

  • Guest
Re: LISP Guru needed
« Reply #8 on: August 16, 2012, 04:02:27 PM »
As a stumbler-around in lisp, I'd love to see the comments from the gurus and the new version of the code, if yall wouldn't mind sharing. 

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #9 on: August 16, 2012, 06:00:16 PM »
i don't mind sharing at all.  That's why i posted it instead of emailing/PMing it to whomever wanted to help.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: LISP Guru needed
« Reply #10 on: August 16, 2012, 06:05:02 PM »
I haven't had a chance to look over the whole program, but for a quick suggestion, the 'Setup3d' and 'C:QUICKSetup3d' could be amalgamated into a single function to set your defaults:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:3dSetup ( )
  2.     (setup3d)
  3. )
  4. (defun Setup3D ( )
  5.     (foreach x
  6.        '(
  7.             ("\nVoltage for Substation" *Voltage*          138)
  8.             ("\nHigh Bus Height"        *HighBus*          162)
  9.             ("\nLow Bus Height"         *LowBus*            90)
  10.             ("\nBus Diameter"           *BusDiameter*        4)
  11.             ("\nPhase Spacing"          *PhaseSpace*       120)
  12.             ("\nVertical Bus Spacing"   *VerticalBusSpace*  72)
  13.         )
  14.         (apply 'LM:getintwithdefault x)
  15.     )
  16.     (princ)
  17. )
  18. (defun LM:getintwithdefault ( msg sym def )
  19.     (set sym (cond ((getint (strcat msg " <" (itoa (cond ((eval sym)) ((set sym def)))) ">: "))) ((eval sym))))
  20. )

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: LISP Guru needed
« Reply #11 on: August 16, 2012, 06:14:36 PM »
David, Can you upload or email a zip of the drawings ?

Are you having problems, or just want a clean-up ?

Personally;  I wouldn't lose any sleep about using COMMAND. By automating your process you are saving a lot of time and encouraging consistancy ... the couple of milliseconds that you lose is of little consequence.
Also personally ; being able to understand and maintain the code is much more important than taking advantage of code constructs that leave your head feeling as if it's been in a spin-dryer.

Regards,
Kerry
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #12 on: August 17, 2012, 10:33:33 AM »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #13 on: August 17, 2012, 11:20:18 AM »
Kerry, I'm not having problems, I just wanted to optimize the code to remove any stupid errors.  I was thinking of the old SENDCOMMAND argument, and trying to avoid the over use of command.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #14 on: August 17, 2012, 11:39:11 AM »
Lee, your amazing!
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: LISP Guru needed
« Reply #15 on: August 17, 2012, 12:30:55 PM »
Lee, your amazing!

That's very kind of you to say David  :-)

With regards to the 'c:Draw3dWall' function, I suppose if you wanted to go the ActiveX route entirely, you could use something like this (probably excessive error-trapping):

Code - Auto/Visual Lisp: [Select]
  1. (defun c:draw3dwall ( / e1 e2 r1 r2 sp )
  2.     (if
  3.         (and
  4.             (setq e1 (LM:select-if "\nSelect Outer Wall: " '(lambda ( x ) (LM:catchapply 'vlax-curve-isclosed (list x)))))
  5.             (setq e2 (LM:select-if "\nSelect Inner Wall: " '(lambda ( x ) (LM:catchapply 'vlax-curve-isclosed (list x)))))
  6.         )
  7.         (progn
  8.             (setq sp (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
  9.             (if
  10.                 (and
  11.                     (setq r1 (car (LM:catchapply 'vlax-invoke (list sp 'addregion (list (vlax-ename->vla-object e1))))))
  12.                     (setq r2 (car (LM:catchapply 'vlax-invoke (list sp 'addregion (list (vlax-ename->vla-object e2))))))
  13.                 )
  14.                 (progn
  15.                     (vla-boolean r1 acsubtraction r2)
  16.                     (vla-addextrudedsolid sp r1 120.0 0.0)
  17.                     (vla-delete r1)
  18.                     (entdel e1)
  19.                     (entdel e2)
  20.                 )
  21.                 (princ "\nUnable to create Region from selected objects.")
  22.             )
  23.         )
  24.     )
  25.     (princ)
  26. )
  27.  
  28. (defun LM:catchapply ( func params / result )
  29.     (if (not (vl-catch-all-error-p (setq result (vl-catch-all-apply func params))))
  30.         result
  31.     )
  32. )
  33.  
  34. (defun LM:select-if ( msg pred / ent )
  35.     (setq pred (eval pred))
  36.     (while
  37.         (progn (setvar 'errno 0) (setq ent (car (entsel msg)))
  38.             (cond
  39.                 (   (= 7 (getvar 'errno))
  40.                     (princ "\nMissed try again.")
  41.                 )
  42.                 (   (= 'ename (type ent))
  43.                     (if (null (pred ent))
  44.                         (princ "\nInvalid Object selected.")
  45.                     )
  46.                 )
  47.             )
  48.         )
  49.     )
  50.     ent
  51. )
  52.  
  53. ;; Active Document  -  Lee Mac
  54. ;; Returns the VLA Active Document Object
  55.  
  56. (defun LM:acdoc nil
  57.     (LM:acdoc)
  58. )

But the extra steps that are required to convert the objects to regions, before performing the boolean subtraction, then creating the extrudedsolid yields lengthy code given the simple command call alternative.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #16 on: August 17, 2012, 12:45:26 PM »
But the extra steps that are required to convert the objects to regions, before performing the boolean subtraction, then creating the extrudedsolid yields lengthy code given the simple command call alternative.

And there is a lot of VL stuff there that I don't know what it is doing.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)