乐筑天下

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

[编程交流] bl基点之间的PLINE

[复制链接]

1

主题

1

帖子

0

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 06:55:32 | 显示全部楼层 |阅读模式
大家好,
 
我有下面的代码,我用它来插入一个灯具作为一个块。它会提示输入房间大小和灯具数量。我想知道是否有一种方法可以在插入基点后在基点之间绘制多段线?
 
这将是交换线,因此它将有自己的图层和线型。
 
这可能吗?
 
提前感谢
 
  1. ;;;
  2. ;;; LUMTEST.LSP
  3. ;;;
  4. ;;;
  5. ;;;
  6. ;;;
  7. ;;; ***** ERROR HANDLER *****
  8. (defun RLERR (S)
  9. (if (/= S "Function cancelled")      ; If an error (such as CTRL-C)
  10.      (princ (strcat "\nError: " S))   ; occurs while this command is
  11. )
  12. (command)
  13. (command "undo" "end")
  14. (command "undo" 1)                   ; active...
  15. (setq *error* OLDERR)                ; Restore previous settings   
  16. (setvar "clayer" PL)
  17. (setvar "cmdecho" PC)
  18. (princ)
  19. )
  20. ;;; ***** MAIN PROGRAM *****
  21. (DEFUN C:LUMTEST (/ OLDERR BL BN CD IM LC OM PC PD PL PO PR P1 P2 p4 p5 p6 YP1 YP2 XP1 XP2 ly lx ob sc sr
  22.                  tx1 tx2 tx3 ty1 ty2 ty3 na lp1 lp2 lp3 lp4 ln1 ln2 lc lr)
  23. (setq PC (getvar "cmdecho"))
  24. (setvar "cmdecho" 0)
  25. (command "undo" "begin")
  26. (setq SCALE (getvar "USERR3")
  27.        PR (getvar "regenmode")
  28.        PO (getvar "osmode")
  29.        PL (getvar "clayer")
  30.        OLDERR *error*
  31.        *error* RLERR
  32. )
  33. (setvar "clayer" "lighting")
  34. (setvar "regenmode" 0)
  35. (setvar "osmode" 32)
  36. (setq P1 (getpoint " Pick bottom left corner of room: "))   ;RETURNS: (96795.6 -7088.0 0.0)
  37. (setq P2 (getcorner P1 " Pick top right corner of room: ")) ;RETURNS: (138716.0 16469.7 0.0)
  38. ;;;
  39. ;;; From points P1 and P2 calculate the x-distance and y-distance.
  40. ;;;
  41. (setq XP1 (car P1))                                         ;RETURNS: 96795.6 (P1 x-coordinate)
  42. (setq XP2 (car P2))                                         ;RETURNS: 138716.0 (P2 x-coordinate)
  43. (setq YP1 (cadr P1))                                        ;RETURNS: -7088.0 (P1 y-coordinate)
  44. (setq YP2 (cadr P2))                                        ;RETURNS: 16469.7 (P2 y-coordinate)
  45. (setq LX (- XP2 XP1))                                       ;RETURNS: 41920.9 (calc x distance)
  46. (setq LY  (- YP2 YP1))                                      ;RETURNS: 23557.7 (calc y distance)
  47. ;;;
  48. ;;; X-distance divided by number of lights gives column spacing.
  49. ;;; Y-distance divided by number of lights gives row spacing.
  50. ;;;
  51. (setq XVAL (getint "\nNumber of Lights across: "))
  52. (setq YVAL (getint "\nNumber of Lights down: "))
  53. (setq SR (/ LX XVAL))                                       ;RETURNS: 6986.81 (x-dist div. by no. lights)
  54. (setq SC (/ LY YVAL))                                       ;RETURNS: 7852.55m (y-dist div. by no. lights)
  55. (setq SR2 (/ SR 2))                                         ;RETURNS: 3493.41 (x column spacing)
  56. (setq SC2 (/ SC 2))                                         ;RETURNS: 3926.28 (y column spacing)
  57. (setq P3 (list (+ (car P1) SR2) (+ (cadr P1) SC2)))         ;RETURNS: (100289.0 -3161.72) (calculated point to start array)
  58. ;  (command "point" P3)
  59. (command "-insert" "L-Fluoro" P3 "100" "100" pause)               
  60. (progn
  61.    (cond
  62.      ((and (< XVAL 2) (>= YVAL 2))
  63.        (command "array" "l" "" "rectangular" YVAL XVAL SC)
  64.      )
  65.      ((and (< YVAL 2) (>= XVAL 2))
  66.        (command "array" "l" "" "rectangular" YVAL XVAL SR)
  67.      )
  68.      ((and (>= XVAL 2) (>= YVAL 2))
  69.        (command "array" "l" "" "rectangular" YVAL XVAL SC SR)
  70.      )
  71.    )
  72. )
  73. ;;;   **** Restore previous settings ****
  74. (setq *error* olderr)            
  75. (setvar "clayer" PL)
  76. (setvar "osmode" PO)
  77. (setvar "regenmode" PR)
  78. (command "undo" "end")
  79. (setvar "cmdecho" PC)
  80. (princ)
  81. )
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 07:26:45 | 显示全部楼层
加入是很容易的,有点棘手,是自动的,或者是以某种形式的顺序选择
 
问题是,如果你没有按正确的插入顺序放置,你会得到一个spagetti线,自动或拾取实际上是一样的
 
很快回来,给你一个选择的答案。
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 07:43:05 | 显示全部楼层
您的代码将块组生成为一个数组,因此您应该计算插入点,将其存储到列表中,然后使用它生成所需的多段线:
  1. (command "_PLINE")
  2. (foreach thePoint listOfPoints
  3. (command thePoint)
  4. )
  5. (command  "")

要计算点,请检查极函数-请注意点的顺序。
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 08:00:33 | 显示全部楼层
那会是“蛇型”普林吗?左下角第一?
 
  1. (DEFUN C:LUMTEST (/ ;OLDERR BL BN CD IM LC OM PC PD PL PO PR P1 P2 p4 p5 p6 YP1 YP2 XP1 XP2 ly lx ob sc sr
  2.                  ;tx1 tx2 tx3 ty1 ty2 ty3 na lp1 lp2 lp3 lp4 ln1 ln2 lc lr
  3.                  )
  4. [color="blue"](if (and [/color]
  5. (setq P1 (getpoint " Pick First corner of room: "))   
  6. (setq P2 (getcorner P1 " Pick Other corner of room: ")))
  7. [color="blue"]  (progn
  8.           (setq p p1
  9.                 p1 (list (setq XP1 (min (car p1)(car p2)))
  10.                          (setq YP1 (min (cadr p1)(cadr p2))))
  11.                 p2 (list (setq XP2 (max (car p)(car p2)))
  12.                          (setq YP2 (max (cadr p)(cadr p2)))))[/color]
  13.   (setq LX (- XP2 XP1))                                      
  14.   (setq LY  (- YP2 YP1))
  15.         [color="blue"] (initget 7)  [/color]
  16.   (setq XVAL (getint "\nNumber of Lights across: "))
  17.         [color="blue"] (initget 7)  [/color]
  18.   (setq YVAL (getint "\nNumber of Lights down: "))
  19.   (setq SR (/ LX XVAL))                                       
  20.   (setq SC (/ LY YVAL))                                    
  21.   (setq SR2 (/ SR 2))                                         
  22.   (setq SC2 (/ SC 2))                                         
  23.   (setq P3 (list (+ (car P1) SR2) (+ (cadr P1) SC2)))         
  24.   (command "-insert" "L-Fluoro" "_non" P3 "100" "100" pause)
  25.         [color="blue"]  (setq  el (entlast) s2 (ssadd el)
  26.                 ) [/color]
  27.   (command "array" "l" "" "rectangular" YVAL XVAL SC SR)
  28. [color="blue"]  (while (setq el (entnext el))
  29.                     (ssadd el s2)
  30.                 )
  31.   (setq r 1 ptData nil)
  32.         (repeat (setq i (sslength s2))
  33.           (setq pts (cons (cdr (assoc 10 (entget (ssname s2 (setq i (1- i)))))) pts))
  34.           (if (= (length pts) Yval)
  35.             (setq ptData (cons (if (zerop r)
  36.                                  (reverse pts)
  37.                                  pts)
  38.                                ptData)
  39.                   pts    nil
  40.                   r      (boole 6 1 r))))
  41. (command "Pline")
  42. (foreach pt (apply 'append ptdata)
  43.   (command  "_non" pt))
  44. (command "")[/color]
  45.   )
  46. )
  47. (princ)
  48. )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 11:36 , Processed in 0.393641 second(s), 71 queries .

© 2020-2025 乐筑天下

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