乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 68|回复: 5

[编程交流] 停车场错误:无功能

[复制链接]

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 11:59:49 | 显示全部楼层 |阅读模式
含糖的公园lsp生成90度停车位:
 
  1. ; PARK.LSP  Copyright 1989,90,91  Tony Tanzillo  All Rights Reserved.
  2. ;
  3. ; This program automates the layout of rows of right-angle parking spaces
  4. ; (or more accurately, the striping for parking spaces).  Great for site
  5. ; planning/layout work.  Automatically calculates the reqired stall width
  6. ; above a specified minimum, to fit the maximum number of stalls into the
  7. ; specified area.
  8. ;
  9. ; No further documentation available, just follow the prompts.
  10. (defun C:STALL90 ( / +pi/2 -pi/2 sc sw sl sxw st p1 p2 p3 p4 a d l hi bm)
  11.      (setq +pi/2 '((a) (+ a (/ pi 2.0)))
  12.            -pi/2 '((a) (- a (/ pi 2.0))))
  13.      (initget 7)
  14.      (setq sw (getdist "\nMinimum stall width: "))
  15.      (setq sl (getdist "\nStall depth: "))
  16.      (initget 1 "Single Double  Double")
  17.      (setq st (getkword "Single- or Double-loaded <Double>: "))
  18.      (initget 1 "Entity  Entity")
  19.      (setq p1 (getpoint "\nFirst alignment point/<Entity>: "))
  20.      (cond (  (eq p1 "Entity")
  21.               (setq l (entsel "\nSelect line: "))
  22.               (setq l (entget (car l)))
  23.               (setq p1 (cdr (assoc 10 l))
  24.                     p2 (cdr (assoc 11 l))))
  25.            (t (setq p2 (getpoint p1 "\nSecond alignment point: "))))
  26.      (cond (  (eq st "Single")
  27.               (setq p3 (getpoint "\nWhich side of alignment: "))))
  28.      (setq d (distance p1 p2))
  29.      (setq a (angle p1 p2))
  30.      (setq sc (fix (/ d sw)))
  31.      (setq sxw (/ d sc))
  32.      (if p3 (setq p4 (inters p1 p2 p3 (polar p3 (+pi/2 a) 1.0) nil)))
  33.      (princ (strcat "\nDrawing "
  34.                     (cond (p3 "") (t "2 x "))
  35.                     (itoa sc) " stalls @ " (rtos sxw) " wide x "
  36.                     (rtos sl) " deep."))
  37.      (printf "\nDrawing ~i x ~i stalls @ ~d wide x ~d deep."
  38.              (list n sc sxw sl))
  39.      (setvar "cmdecho" 0)
  40.      (setq hi (getvar "highlight"))
  41.      (setq bm (getvar "blipmode"))
  42.      (setvar "highlight" 0)
  43.      (setvar "blipmode" 0)
  44.      (command ".line" p1 p2 "")
  45.      (cond (p3 (command ".line" p1 (polar p1 (angle p4 p3) sl) ""))
  46.            (t  (command ".line" (polar p1 (+pi/2 a) sl)
  47.                                 (polar p1 (-pi/2 a) sl) "")))
  48.      (command ".UCS" "Z" (* a (/ 180.0 pi))
  49.               ".array" (entlast) "" "R" "1" (1+ sc) sxw
  50.               ".UCS" "P"
  51.      )
  52.      (setvar "highlight" hi)
  53.      (setvar "blipmode" bm)
  54.      (princ)
  55. )
  56. ; --------------------------------eof park.lsp-------------------------

 
不过,它不起作用。我已经在AutoCAD 2007 ADT和BricsCAD Classic v9上试用过。两者给出的错误消息大致相同:
 
  1. Command: (LOAD "S:/LISP/PARK.LSP") C:STALL90
  2. Command: stall90
  3. Minimum stall width: 5
  4. Stall depth: 20
  5. Single- or Double-loaded <Double>: single
  6. First alignment point/<Entity>:
  7. Second alignment point:
  8. Which side of alignment:
  9. Drawing 522 stalls @ 5" wide x 1'-8" deep.; error: no function definition:
  10. PRINTF
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:18:48 | 显示全部楼层
哈哈,代码里有点C。。。
 
快速模式:
 
  1. ; PARK.LSP  Copyright 1989,90,91  Tony Tanzillo  All Rights Reserved.
  2. ;
  3. ; This program automates the layout of rows of right-angle parking spaces
  4. ; (or more accurately, the striping for parking spaces).  Great for site
  5. ; planning/layout work.  Automatically calculates the reqired stall width
  6. ; above a specified minimum, to fit the maximum number of stalls into the
  7. ; specified area.
  8. ;
  9. ; No further documentation available, just follow the prompts.
  10. (defun C:STALL90 ( / +pi/2 -pi/2 sc sw sl sxw st p1 p2 p3 p4 a d l hi bm)
  11.      (setq +pi/2 '((a) (+ a (/ pi 2.0)))
  12.            -pi/2 '((a) (- a (/ pi 2.0))))
  13.      (initget 7)
  14.      (setq sw (getdist "\nMinimum stall width: "))
  15.      (setq sl (getdist "\nStall depth: "))
  16.      (initget 1 "Single Double  Double")
  17.      (setq st (getkword "Single- or Double-loaded <Double>: "))
  18.      (initget 1 "Entity  Entity")
  19.      (setq p1 (getpoint "\nFirst alignment point/<Entity>: "))
  20.      (cond (  (eq p1 "Entity")
  21.               (setq l (entsel "\nSelect line: "))
  22.               (setq l (entget (car l)))
  23.               (setq p1 (cdr (assoc 10 l))
  24.                     p2 (cdr (assoc 11 l))))
  25.            (t (setq p2 (getpoint p1 "\nSecond alignment point: "))))
  26.      (cond (  (eq st "Single")
  27.               (setq p3 (getpoint "\nWhich side of alignment: "))))
  28.      (setq d (distance p1 p2))
  29.      (setq a (angle p1 p2))
  30.      (setq sc (fix (/ d sw)))
  31.      (setq sxw (/ d sc))
  32.      (if p3 (setq p4 (inters p1 p2 p3 (polar p3 (+pi/2 a) 1.0) nil)))
  33.      (princ (strcat "\nDrawing "
  34.                     (cond (p3 "") (t "2 x "))
  35.                     (itoa sc) " stalls @ " (rtos sxw) " wide x "
  36.                     (rtos sl) " deep."))
  37.      ;(printf "\nDrawing ~i x ~i stalls @ ~d wide x ~d deep."
  38.            ;  (list n sc sxw sl))
  39.      (setvar "cmdecho" 0)
  40.      (setq hi (getvar "highlight"))
  41.      (setq bm (getvar "blipmode"))
  42.      (setvar "highlight" 0)
  43.      (setvar "blipmode" 0)
  44.      (command ".line" p1 p2 "")
  45.      (cond (p3 (command ".line" p1 (polar p1 (angle p4 p3) sl) ""))
  46.            (t  (command ".line" (polar p1 (+pi/2 a) sl)
  47.                                 (polar p1 (-pi/2 a) sl) "")))
  48.      (command ".UCS" "Z" (* a (/ 180.0 pi))
  49.               ".array" (entlast) "" "R" "1" (1+ sc) sxw
  50.               ".UCS" "P"
  51.      )
  52.      (setvar "highlight" hi)
  53.      (setvar "blipmode" bm)
  54.      (princ)
  55. )
  56. ; --------------------------------eof park.lsp-------------------------
回复

使用道具 举报

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 12:31:35 | 显示全部楼层
李,你修好了!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:38:15 | 显示全部楼层
没有问题
 
这可能更快:
 
  1. ; PARK.LSP  Copyright 1989,90,91  Tony Tanzillo  All Rights Reserved.
  2. ;
  3. ; This program automates the layout of rows of right-angle parking spaces
  4. ; (or more accurately, the striping for parking spaces).  Great for site
  5. ; planning/layout work.  Automatically calculates the reqired stall width
  6. ; above a specified minimum, to fit the maximum number of stalls into the
  7. ; specified area.
  8. ;
  9. ; No further documentation available, just follow the prompts.
  10. ; Modified by Lee Mac  ~  21.12.2009
  11. (defun C:STALL90  (/ *error* lin +pi/2 -pi/2  A ALINE D DOC L OV P1
  12.                                  P2 P3 P4 SC SL ST SW SXW UFLAG VL)
  13. (vl-load-com)
  14. (defun *error* (msg)
  15.    (and ov (mapcar 'setvar vl ov))
  16.    (and uflag (vla-EndUndoMark doc))
  17.    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
  18.        (princ (strcat "\n** Error: " msg " **")))
  19.    (princ))
  20. (setq lin '((pt1 pt2) (entmakex (list (cons 0 "LINE") (cons 10 pt1) (cons 11 pt2))))
  21.        +pi/2 '((a) (+ a (/ pi 2.0)))
  22.        -pi/2 '((a) (- a (/ pi 2.0))))
  23. (initget 7)
  24. (setq sw (getdist "\nMinimum stall width: "))
  25. (initget 7)
  26. (setq sl (getdist "\nStall depth: "))
  27. (initget "Single Double")
  28. (setq st (cond ((getkword "\nSingle- or Double-loaded <Double>: ")) ("Double")))
  29. (initget "Entity")
  30. (setq p1 (getpoint "\nFirst alignment point/<Entity>: "))
  31. (cond (  (or (not p1) (eq p1 "Entity"))
  32.           (while
  33.             (progn
  34.               (setq l (car (entsel "\nSelect line: ")))
  35.               (cond (  (eq 'ENAME (type l))
  36.                        (if (not (eq "LINE" (cdr (assoc 0 (setq l (entget l))))))
  37.                          (princ "\n** Object must be a Line **")))
  38.                     (  (princ "\n** Nothing Selected **")))))
  39.           (setq p1 (cdr (assoc 10 l)) p2 (cdr (assoc 11 l))))
  40.        (t (setq p2 (getpoint p1 "\nSecond alignment point: "))))
  41. (cond (  (eq st "Single")
  42.           (setq p3 (getpoint "\nWhich side of alignment: "))))
  43. (setq d (distance p1 p2) a (angle p1 p2) sc (fix (/ d sw)) sxw (/ d sc))
  44. (if p3 (setq p4 (inters p1 p2 p3 (polar p3 (+pi/2 a) 1.0) nil)))
  45. (princ (strcat "\nDrawing " (cond (p3 "") (t "2 x ")) (itoa sc)
  46.                 " stalls @ " (rtos sxw) " wide x " (rtos sl) " deep."))
  47. (setq vl '("CMDECHO" "HIGHLIGHT" "BLIPMODE") ov (mapcar 'getvar vl))
  48. (mapcar 'setvar vl '(0 0 0))
  49. (setq uFlag (not (vla-StartUndoMark
  50.                     (setq doc (vla-get-ActiveDocument
  51.                                 (vlax-get-acad-object))))))
  52. (lin p1 p2)
  53. (setq aLine
  54.    (cond (p3 (lin p1 (polar p1 (angle p4 p3) sl)))
  55.          (t  (lin (polar p1 (+pi/2 a) sl) (polar p1 (-pi/2 a) sl)))))
  56. (command "_.UCS" "_Z" (* a (/ 180.0 pi)) "_.-array" aLine "" "_R" "1" (1+ sc) sxw "_.UCS" "_P")  
  57. (setq uFlag (vla-EndUndoMark doc))
  58. (mapcar 'setvar vl ov)
  59. (princ))
回复

使用道具 举报

2

主题

47

帖子

45

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 12:52:51 | 显示全部楼层
我打赌它可以更新,以更好地工作,并适应创造双档停车场。。。
 
这是前一段时间做的事情。。。看看是否有帮助或提供了新的想法。
部分。lsp
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:59:58 | 显示全部楼层
很好,路易斯
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 10:05 , Processed in 0.782424 second(s), 75 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表