乐筑天下

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

[编程交流] 将旋转功能添加到

[复制链接]

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:22:44 | 显示全部楼层
 
我只是想让这一切对你来说尽可能地无痛。
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:24:39 | 显示全部楼层
使用PDXF。lsp,当我选择坐标0,0处的正方形位置和1处的块比例,并且块处于分解状态时,文本屏幕显示如下:
 
  1. (-1 . <Entity name: 7ef70360>)
  2. (0 . "LWPOLYLINE")
  3. (330 . <Entity name: 7ef59cf8>)
  4. (5 . "11C")
  5. (100 . "AcDbEntity")
  6. (67 . 0)
  7. (410 . "Model")
  8. (8 . "0")
  9. (100 . "AcDbPolyline")
  10. (90 . 4)
  11. (70 . 1)
  12. (43 . 0.0)
  13. (38 . 0.0)
  14. (39 . 0.0)
  15. (10 -0.288267 0.287769)
  16. (40 . 0.0)
  17. (41 . 0.0)
  18. (42 . 0.0)
  19. (10 -0.287604 -0.288432)
  20. (40 . 0.0)
  21. (41 . 0.0)
  22. (42 . 0.0)
  23. (10 0.288598 -0.287769)
  24. (40 . 0.0)
  25. (41 . 0.0)
  26. (42 . 0.0)
  27. (10 0.287935 0.288432)
  28. (40 . 0.0)
  29. (41 . 0.0)
  30. (42 . 0.0)
  31. (210 0.0 0.0 1.0)

 
然后我选择DXF数据作为属性定义,我应该有这样的内容:
 
  1. (-1 . <Entity name: 7ef70368>)
  2. (0 . "ATTDEF")
  3. (330 . <Entity name: 7ef59cf8>)
  4. (5 . "11D")
  5. (100 . "AcDbEntity")
  6. (67 . 0)
  7. (410 . "Model")
  8. (8 . "SQR TEXT")
  9. (100 . "AcDbText")
  10. (10 -0.158648 0.404835 0.0)
  11. (40 . 0.09375)
  12. (1 . "Square")
  13. (50 . 0.0)
  14. (41 . 1.0)
  15. (51 . 0.0)
  16. (7 . "Romans")
  17. (71 . 0)
  18. (72 . 1)
  19. (11 -0.00016575 0.373585 0.0)
  20. (210 0.0 0.0 1.0)
  21. (100 . "AcDbAttributeDefinition")
  22. (3 . "Text:")
  23. (2 . "TEXT")
  24. (70 .
  25. (73 . 0)
  26. (74 . 1)

 
 
如果您将此数据与程序中块定义中的数据进行比较,您应该知道如何安排所有这些。正如我之前在DXF Reference then Entities部分的Developer Help部分中提到的那样,可以找到每一行的含义。每一行都有解释。
 
请注意,我在程序中搜索块定义,如果图形中不存在块定义,程序将转到块定义函数。
 
它应该这样开始,表示它是一个块:
 
  1. (defun BLKLIB_BD ()
  2. (entmake
  3.    (list
  4.      (cons 0   "block")
  5.      (cons 2    SYM)
  6.      (cons 10  (list 0.0 0.0 0.0))
  7.      (cons 70   2)))

 
实体将跟随,函数以以下内容结束:
 
  1. (entmake
  2.    (list
  3.      (cons 0  "endblk")
  4.      (cons 8   "0")))
  5. (princ))
  6. (princ)

 
 
这需要一些时间来适应。
回复

使用道具 举报

10

主题

30

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 10:28:49 | 显示全部楼层
我只是想用我图书馆里的符号。有没有办法将我的目录分到某个地方,以便将该文件路径用于例程?
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:32:01 | 显示全部楼层
 
我的电脑里有一个简单的。我会努力找到它。与此同时,也许其他人会发布一些真正好的东西。
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:35:43 | 显示全部楼层
我找不到我提到的例程,因为它在数千个其他文件中丢失了。因此,我修改了我提供的例程,尽管我不确定我是否正确执行了此操作。如果有人发现问题,请随时纠正我。如果块定义不在图形中,我会使用findfile,但除非符号目录位于ACAD搜索支持路径中,否则这将不起作用。我可以发誓这是没有必要的,但现在我不确定。
 
无论如何,附加的程序有三个外部块,假设它们位于名为C:/Symbols的目录中。该目录需要位于支持路径中,或者可以更改为您想要的名称。这三个块在程序列表中。您也可以将其与为英制单位设置的块比例列表一起更改为所需的值。您可能需要将其更改为公制。
 
我尽可能多地评论了这个节目,让你了解正在发生的事情。我还删除了图像,以防你决定使用这个程序与你的区块。为你的区块制作图像本身可能是一个完整的线程,所以我不想在这一点上进入它。
 
程序名为BLKLIB2。具有BLKLIB2的lsp。dcl
命令语法:BLKLIB2
将这些块放在一个名为Symbols的目录中,或者选择您喜欢的内容,只要您在程序中编辑它。
 
祝你好运,让我知道进展如何。
任何问题,我都乐意回答。
秃鹰
 
P、 如果有人有更好的东西可以提供,请随意张贴。
 
-----------------------------------------------------------------------------------------------------------
 
我只是查找findfile,它仅限于支持搜索路径,如图所示。
圆圈。图纸
三角形。图纸
正方形。图纸
BLKLIB2.dcl
BLKLIB2.lsp
104928cjmzxhqul5jffiqi.jpg
回复

使用道具 举报

10

主题

30

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 10:39:18 | 显示全部楼层
嗨,秃鹰,
 
我使用了新的例程,更改了符号的路径,并在程序中更改了我的符号名称。我收到了这个错误消息。错误:错误的参数类型:stringp nil。
 
有什么想法吗?
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:41:45 | 显示全部楼层
 
 
我不确定你做了哪些改变。你能把你修改过的代码贴出来看看吗?
 
可能有几件事。您使用的块是否具有属性?您是否从头到尾遵循代码并检查零值?
回复

使用道具 举报

10

主题

30

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 10:43:35 | 显示全部楼层
下面是对例程的更改,请注意,仅更改了文件路径和块的名称。也很抱歉cop粘贴,但由于某些原因,我不能上传到这个论坛。
 
谢谢
 
  1. ;
  2. ; BLKLIB2.lsp  Note: This program is only a demo example and has no other purpose.
  3. ;                   There are only three blocks in this program for demonstration.
  4. ;                   It only shows a method of creating blocks with a built-in block
  5. ;                   definition using dxf data and inserting them. No external block
  6. ;                   drawings are required.
  7. ;                   This program inserts a selected block to a selected scale factor
  8. ;                   and places it on its own Object layer with Attribute layer. The
  9. ;                   attributes are filled in with no prompting.
  10. ;
  11. ; Author: Angelo Bozzone
  12. ; Original program was SL.lsp created 03|23|06 and modified 05|10|10 to BLKLIB2.lsp
  13. ;
  14. ; This program requires the following files below to work properly."
  15. ; Make sure to have these files together in the same directory."
  16. ; Also make sure the the directory is in the AutoCAD Support File Search Path."
  17. ;
  18. ; BLKLIB2.dcl - AutoCAD Dialog Definition,   Size 1  KB"
  19. ; BLKLIB2.lsp - AutoLISP Application Source, Size 14 KB"
  20. ;
  21. ; To start this program, At the command prompt type BLKLIB2."
  22. ;
  23. ; The function directory below list all functions in their assembled order.
  24. ;
  25. ;========================================================================================
  26. ; No.  | Function Name       | Function Description      
  27. ;========================================================================================
  28. ; F01  | C:BLKLIB2           | Program Start.
  29. ;----------------------------------------------------------------------------------------
  30. ; F02  | BLKLIB2_MF          | Main Function.
  31. ;----------------------------------------------------------------------------------------
  32. ; F03  | BLKLIB2_RTD         | Radians To Degrees.
  33. ;----------------------------------------------------------------------------------------
  34. ; F04  | BLKLIB2_FS          | Font Style.
  35. ;----------------------------------------------------------------------------------------
  36. ; F05  | BLKLIB2_CL          | Create Layer.
  37. ;----------------------------------------------------------------------------------------
  38. ; F06  | BLKLIB2_CPS         | Change Program Settings.
  39. ;----------------------------------------------------------------------------------------
  40. ; F07  | BLKLIB2_RUS         | Rsstore User Settings.
  41. ;----------------------------------------------------------------------------------------
  42. ; F08  | BLKLIB2_ET          | Error Trap.
  43. ;----------------------------------------------------------------------------------------
  44. ;      |                     |
  45. ;
  46. ;/////////////////////////////////////////////////////////////////////////////////
  47. ;
  48. ; F01 - Program Start.
  49. ;
  50. (defun C:BLKLIB2 (/ ALAY AVAL BNAM BSF BSF_LST CPS DCL_ID DEG INPT IANG OLAY RAD SUS SYM_LST UCLK) ; Declare local variables
  51. (setq SUS_LST (list "orthomode" "osmode" "cmdecho" "blipmode" "clayer")           ; Save User Settings List
  52.        SUS     (mapcar 'getvar SUS_LST)                                            ; Save User Settings Variable
  53.        TERR *error*                                                                ; Store *error
  54.       *error* BLKLIB2_ET)                                                          ; Goto error trap
  55. (BLKLIB2_MF)                                                                      ; Goto to Main Function
  56. (princ))                                                                          ; Exit quietly
  57. (princ "\nBLKLIB2.lsp Loaded, Type BLKLIB2 to start program.")                      ; Print message to command line
  58. ;
  59. ;//////////////////////////////////////////////////////////////////////
  60. ;
  61. ; F02 - Main Function.
  62. ;
  63. (defun BLKLIB2_MF ()
  64. (or BLKLIB2:SYM (setq BLKLIB2:SYM "0"))                                           ; Set default Block Name
  65. (or BLKLIB2:BSF (setq BLKLIB2:BSF "13"))                                          ; Set default Block Scale Factor
  66. (setq SYM_LST (list "plumbingstack" "gooseneckvent" "squarevent")                                 ; Block Names List
  67.        BSF_LST (list "1/32" = 1'" "1/16" = 1'"  "3/32" = 1'"                    ; Scale Factor List
  68.                      "1/8" = 1'"  "3/16" = 1'"  "1/4" = 1'"
  69.                      "3/8" = 1'"  "1/2" = 1'"   "3/4" = 1'"
  70.                      "1" = 1'"    "1-1/2" = 1'" "3" = 1'"
  71.                      "6" = 1'"    "1' = 1'"))
  72. (setq DCL_ID (load_dialog "BLKLIB2.dcl"))                                         ; Load dialog
  73. (if (not (new_dialog "BLKLIB2" DCL_ID))                                           ; Test for dialog, If not found
  74.    (progn                                                                          ; Then do the following
  75.      (ALERT                                                                        ; Display alert message
  76.        (strcat                                                                     ; Concatenate string
  77.          "\nAttention!"                                                            ; Start message
  78.          "\n"
  79.          "\nThe dialog file BLKLIB2.dcl could not be found."
  80.          "\nBe sure the dialog file BLKLIB2.dcl"
  81.          "\nis in the AutoCAD Support File Search Path."))                         ; End message
  82.      (exit)))                                                                      ; Then exit
  83. (start_list "SYM")(mapcar 'add_list SYM_LST)(end_list)                            ; Fill the Symbols List
  84. (start_list "BSF")(mapcar 'add_list BSF_LST)(end_list)                            ; Fill the Block Scale List
  85. (set_tile "SYM" BLKLIB2:SYM)                                                      ; Set the Block Symbol tile
  86. (set_tile "BSF" BLKLIB2:BSF)                                                      ; Set the Block Scale tile
  87. (action_tile "SYM"    "(setq BLKLIB2:SYM $value)")                                ; Get current Block Name value
  88. (action_tile "BSF"    "(setq BLKLIB2:BSF $value)")                                ; Get current Block Scale value
  89. (action_tile "cancel" "(done_dialog)(setq UCLK nil)(BLKLIB2_RUS)")                ; Exit program, Set User Click to nil, Restore ;User Settings
  90. (action_tile "accept" "(done_dialog)(setq UCLK T)")                               ; When OK selected, Set User Click (OK) to true
  91. (start_dialog)                                                                    ; Start dialog
  92. (unload_dialog DCL_ID)                                                            ; Unload dialog
  93. (if UCLK                                                                          ; If OK selected
  94.    (progn                                                                          ; Then do the following
  95.      (cond
  96.        ((= BLKLIB2:SYM "0") (setq BNAM "plumbingstack"))                                ; Set the Block Name
  97.        ((= BLKLIB2:SYM "1") (setq BNAM "gooseneckvent"))
  98.        ((= BLKLIB2:SYM "2") (setq BNAM "squarevent")))
  99.      (cond
  100.        ((= BLKLIB2:BSF "0") (setq BSF 384))                                        ; Set the Block Scale Factor
  101.        ((= BLKLIB2:BSF "1") (setq BSF 192))
  102.        ((= BLKLIB2:BSF "2") (setq BSF 128))
  103.        ((= BLKLIB2:BSF "3") (setq BSF 96))
  104.        ((= BLKLIB2:BSF "4") (setq BSF 64))
  105.        ((= BLKLIB2:BSF "5") (setq BSF 48))
  106.        ((= BLKLIB2:BSF "6") (setq BSF 32))
  107.        ((= BLKLIB2:BSF "7") (setq BSF 24))
  108.        ((= BLKLIB2:BSF "8") (setq BSF 16))
  109.        ((= BLKLIB2:BSF "9") (setq BSF 12))
  110.        ((= BLKLIB2:BSF "10")(setq BSF )
  111.        ((= BLKLIB2:BSF "11")(setq BSF 4))
  112.        ((= BLKLIB2:BSF "12")(setq BSF 2))
  113.        ((= BLKLIB2:BSF "13")(setq BSF 1)))
  114.      (cond
  115.        ((= BNAM "TRIANGLE")(setq ALAY "TRIANGLE TEXT")(setq OLAY BNAM AVAL BNAM)) ; Set the layer attribute layer name, Object layer ;name and Attribute value
  116.        ((= BNAM "SQUARE")  (setq ALAY "SQUARE TEXT")  (setq OLAY BNAM AVAL BNAM))
  117.        ((= BNAM "CIRCLE")  (setq ALAY "CIRCLE TEXT")  (setq OLAY BNAM AVAL BNAM)))
  118.      (BLKLIB2_CPS)                                                                ; Change program settings
  119.      (BLKLIB2_FS "Romans")                                                        ; Set font style to romans Supply One argument
  120.      (BLKLIB2_CL ALAY 2 "Continuous")                                             ; Create attribute layer.  Supply Three arguments
  121.      (BLKLIB2_CL OLAY 1 "Continuous")                                             ; Create object layer.     Supply Three arguments
  122.      (if
  123.        (null
  124.          (tblsearch "block" BNAM)                                                 ; Search drawing for block.
  125.        )
  126.        (findfile (strcat "C:\Documents and Settings\ldibiase\Desktop\Symbol Library" BNAM ".dwg"))                              ; If ;block not found, Find drawing file.
  127.      )
  128.      (setvar "clayer" OLAY)                                                       ; Set the object layer
  129.      (setvar "osmode" (nth 1 SUS))                                                ; Set object snap to saved user object snap
  130.      (while                                                                       ; Program Loop
  131.        (setq INPT (getpoint "\nSpecify insertion point: "))                       ; Get insertion point
  132.        (if (/= INPT nil)                                                          ; If insertion point nil
  133.          (progn                                                                   ; Then do the following
  134.            (setq IANG (getpoint INPT "\nSpecify orientation angle: ")             ; Set insertion angle
  135.                  INPT (trans INPT 1 0)                                            ; Translate coords
  136.                  IANG (trans IANG 1 0)                                            ; Translate coords
  137.                  RAD  (angle INPT IANG)                                           ; Get the angle in radians between insertion point ;and insertion angle
  138.                  DEG  (BLKLIB2_RTD RAD))                                          ; Convert the radians to degrees
  139.            (command "._-insert" BNAM INPT BSF BSF DEG))))                         ; Insert, Block Name, Insertion Point, Block Scale ;Factor, Block Scale Factor, and Angle in degrees
  140.      (BLKLIB2_MF)))                                                               ; If insertion point nill return to the dialog
  141. (princ))                                                                         ; Exit quietly
  142. (princ)
  143. ;
  144. ;//////////////////////////////////////////////////////////////////////
  145. ;
  146. ; F03 - Radians to Degrees.
  147. ;
  148. (defun BLKLIB2_RTD (RAD)(* 180.0 (/ RAD pi)))                                      ; Convert radians to degrees
  149. ;
  150. ;//////////////////////////////////////////////////////////////////////
  151. ;
  152. ; F04 - Font Style.
  153. ;
  154. (defun BLKLIB2_FS (FSTY / TWF TOA PFN BFN)       ;Declare arguments and local variables
  155. (setq TWF 1.0 TOA 0.0 PFN "Romans.shx" BFN "") ;Set the font style parameters
  156. (if (null (tblsearch "style" FSTY))            ;Search drawing for font style
  157.    (entmake                                     ;Entity make
  158.      (list                                      ;List
  159.        (cons 0   "STYLE")                       ;Entity Type
  160.        (cons 100 "AcDbSymbolTableRecord")       ;Subclass marker
  161.        (cons 100 "AcDbTextStyleTableRecord")    ;Subclass marker
  162.        (cons 2    FSTY)                         ;Font Style Name
  163.        (cons 70   0)                            ;Flag value
  164.        (cons 40   0)                            ;Fixed text height, 0 if not fixed
  165.        (cons 41   TWF)                          ;Text width factor
  166.        (cons 50   TOA)                          ;Text obliquing angle
  167.        (cons 3    PFN)                          ;Primary font file name
  168.        (cons 4    BFN))))                       ;Big font file name
  169. (princ))                                       ;Exit quietly
  170. (princ)
  171. ;
  172. ;//////////////////////////////////////////////////////////////////////
  173. ;
  174. ; F05 - Create Layer.
  175. ;
  176. (defun BLKLIB2_CL (LNAM LCLR LTYP)               ;Declare arguments and local variables
  177. (if (null (tblsearch "layer" LNAM))            ;Search drawing for layer name
  178.    (entmake                                     ;Entity make
  179.      (list                                      ;List
  180.        (cons   0 "LAYER")                       ;Entiy type
  181.        (cons 100 "AcDbSymbolTableRecord")       ;Subclass marker
  182.        (cons 100 "AcDbLayerTableRecord")        ;Subclass marker
  183.        (cons   2  LNAM)                         ;Layer name
  184.        (cons  70  0)                            ;Flag value
  185.        (cons  62  LCLR)                         ;Layer color
  186.        (cons   6  LTYP)                         ;Layer linetype
  187.        (cons 290  1))))                         ;Plotting flag
  188. (princ))                                       ;Exit quietly
  189. (princ)
  190. ;
  191. ;//////////////////////////////////////////////////////////////////////
  192. ;
  193. ; F06 - Change Program Settings.
  194. ;
  195. (defun BLKLIB2_CPS ()
  196. (setq CPS (list 1 0 0 0))
  197. (mapcar (function setvar)(list "orthomode" "osmode" "cmdecho" "blipmode") CPS)
  198. (princ))
  199. (princ)
  200. ;
  201. ;//////////////////////////////////////////////////////////////////////
  202. ;
  203. ; F07 - Restore User Settings.
  204. ;
  205. (defun BLKLIB2_RUS ()
  206. (setq *error* TERR)
  207. (if SUS (mapcar 'setvar SUS_LST SUS))
  208. (princ "\nBLKLIB2.lsp has completed and will now restore your settings and exit.")
  209. (princ))
  210. (princ)
  211. ;
  212. ;//////////////////////////////////////////////////////////////////////
  213. ;
  214. ; F08 - Error Trap.
  215. ;
  216. (defun BLKLIB2_ET (ERRORMSG)
  217. (command nil nil nil)
  218. (if (not (member ERRORMSG '("console break" "Function cancelled")))
  219.    (princ (strcat "\nError:" ERRORMSG)))
  220. (if SUS (mapcar 'setvar SUS_LST SUS))
  221. (princ
  222.    (strcat "\nBLKLIB2.lsp has encountered a user error!"
  223.            "\nProgram will now restore your settings and exit."))
  224. (terpri)
  225. (setq *error* TERR)
  226. (princ))
  227. (princ)
  228. ;
  229. ;//////////////////////////////////////////////////////////////////////
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:47:35 | 显示全部楼层
您没有编辑此条件。
层名称是什么?
对象层名称是什么?
是否有属性?
属性是否在不同的层上?
  1.      (cond
  2.        ((= BNAM "TRIANGLE")(setq ALAY "TRIANGLE TEXT")(setq OLAY BNAM AVAL BNAM))
  3.        ((= BNAM "SQUARE")  (setq ALAY "SQUARE TEXT")  (setq OLAY BNAM AVAL BNAM))
  4.        ((= BNAM "CIRCLE")  (setq ALAY "CIRCLE TEXT")  (setq OLAY BNAM AVAL BNAM)))

 
 
 
斜杠不正确。
  1. (findfile (strcat "C:\Documents and Settings\ldibiase\Desktop\Symbol Library" BNAM ".dwg"))

 
 
 
你可以这样做,有两种方式。
  1. (findfile (strcat "C:\\Documents and Settings\\ldibiase\\Desktop\\Symbol Library" BNAM ".dwg"))
  2. (findfile (strcat "C:/Documents and Settings/ldibiase/Desktop/Symbol Library" BNAM ".dwg"))
回复

使用道具 举报

10

主题

30

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 10:51:37 | 显示全部楼层
你好,
 
对不起,我很长时间没来了。我失去了一个家庭成员,我一直在努力使一切井然有序。如果你仍然在那里,我想继续努力,使这再次为我工作。
 
我会等着看你是否还在附近帮忙,我会给你回复更多信息。
 
谢谢
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 00:31 , Processed in 0.600331 second(s), 72 queries .

© 2020-2025 乐筑天下

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