乐筑天下

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

[编程交流] 导入贴图分幅

[复制链接]

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 06:41:56 | 显示全部楼层 |阅读模式
我收到我们绘图室的人的请求。我们插入地图块以形成背景映射。这意味着在图纸上搜索正确的数字,并在目录中搜索以找到正确的瓷砖并插入它们。
 
我正在考虑创建一个具有“缩略图”的图形,它只是一个带有地图分幅编号的矩形,这样当用户选择一些“缩略图”时,就会打开一个新图形,并插入正确的分幅。
 
我想知道以前是否有人做过这样或类似的事情?
 
谢谢
布莱恩。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 06:47:53 | 显示全部楼层
就像20年前一样,只需创建一个带有文本标签的网格,一个非常简单的隐藏地图,这样你就知道你在哪里,选择文本,然后运行插入正确的图像,使用lisp中的STRCAT将目录添加到标签名称,我们有多层瓷砖,所以使用自定义侧菜单选择瓷砖图像、块、nottes等的样式
 
非真实代码
  1. (setq gridder (Entsel "pick grid lable))
  2. do normal pull out gridtext plus work out the insert pt in real worl co0ords based on text insertion point -xinc -yinc
  3. (setq gridname (strcat "c:\mydir\images" gridtext))
  4. (command "insertimage" gridname pt 1 1 )

 
您可以执行类似于自动打开网格dwg拾取网格关闭它并将图像插入原始dwg的操作,而无需多个用户输入。
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 06:50:14 | 显示全部楼层
谢谢Bigal,
 
你给了我一些想法。让我进一步解释一下设置。我们的地图分为1:5000、1:2500、1:1000。它们位于映射文件夹的3个子目录中。我没有权限,也不希望以任何方式更改此文件夹结构。我想把瓷砖从里面拿出来。每个文件夹中的文件名如下:(见下图)。
1: 5000地图块编号,无添加-(示例)5411。图纸
1: 2500地图块编号加上A、B、C或D-(示例)5411-A.dwg
1: 1000地图块数加上1到25-(示例)5411-18。图纸
 
(编辑:每个地图分幅可以有一个1:5000,以及几个1:2500和1:1000来完成整个分幅,分幅不同)
 
074157l0g00z0v09v9zggu.jpg
 
这是我现在掌握的代码:
  1. (defun c:Getmaptile  (/ bn chk pp bnloc)
  2. (setq bn "" chk nil); set block name nil
  3. (while (= chk nil)
  4. (setq chk (entsel "\nPick a Block: "))
  5. )
  6. (setq pp (cadr chk))
  7. (setq chk (entget (car chk)))
  8. (setq bn (cdr (assoc 2 chk))); get block name
  9. (setq bnloc (strcat "M:\\os\\Maps\\AutoCAD\\2500\" bn "-D"))
  10. (command "_.-insert" bnloc "0,0,0" "1" "1" "0")
  11. (princ)
  12. )

 
此代码的工作原理是,它将按照代码中的规定插入平铺,并将其插入到当前图形中。我需要获取代码来搜索“M:\\os\\Maps\\AutoCAD\”目录中以我在图形中选择的块“缩略图”中的四位数字开头的所有块。但我需要把它们放在一张新的画里。。。。。。
 
有人能帮我从这里开始怎么走吗?
我试图创建一个基于模板的新绘图,但代码创建了绘图,但随后恢复到原始绘图。。。
 
谢谢
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 06:53:37 | 显示全部楼层
最后一小时的进展。我找到了这个链接:
http://www.cadtutor.net/forum/showthread.php?57051-使用Lisp搜索并插入多个图形作为块。
 
所以我把它合并到代码中,除了新的绘图之外,它运行得很好。我需要启动一个新的绘图并将块插入其中。。。。
也可以选择多个块并插入所选块的所有块。。。。
 
不管怎样,这就是我所拥有的。。
  1. (defun c:Getmaptile  (/ bn chk pp bnloc)
  2. (setq bn "" chk nil); set block name nil
  3. (while (= chk nil)
  4. (setq chk (entsel "\nPick a Block: "))
  5. )
  6. (setq pp (cadr chk))
  7. (setq chk (entget (car chk)))
  8. (setq bn (cdr (assoc 2 chk))); get block name
  9. ;(setq bnloc (strcat "M:\\os\\Maps\\AutoCAD\\2500\" bn))
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\" bn "*.dwg")))
  12. (foreach Dwg Drawings
  13.    (command "_.insert" Dwg "0,0,0" "1" "1" "0")
  14. )
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\" bn "*.dwg")))
  17. (foreach Dwg Drawings
  18.    (command "_.insert" Dwg "0,0,0" "1" "1" "0")
  19. )
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\" bn "*.dwg")))
  22. (foreach Dwg Drawings
  23.    (command "_.insert" Dwg "0,0,0" "1" "1" "0")
  24. )
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. ;(command "_.-insert" bnloc "0,0,0" "1" "1" "0")
  27. (princ)
  28. )
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30. ;; Function to list files from a wildcard match
  31. (defun matchfiles (path / item dir match lst fil files)
  32. (setq path (strsplit "," path))
  33. (foreach item path
  34.    (setq dir   (strcat (vl-string-right-trim "\" (vl-filename-directory item)) "\")
  35.          match (substr item (1+ (strlen dir)))
  36.          lst   (vl-directory-files dir match 1)
  37.    )
  38.    (foreach fil lst
  39.      (setq files (cons (strcat dir fil) files))
  40.    )
  41. )
  42. (reverse files)
  43. )
  44. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  45. ;; Function to split a string on a specified character
  46. (defun strsplit (c str / lst p n)
  47. (setq n 0)
  48. (while (setq p (vl-string-search c str n))
  49.    (setq lst (cons (substr str (1+ n) (- p n)) lst))
  50.    (setq n (1+ p))
  51. )
  52. (if (< n (strlen str))
  53.    (setq lst (cons (substr str (1+ n)) lst))
  54. )
  55. (reverse lst)
  56. )
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 06:57:50 | 显示全部楼层
你需要沿着脚本路径走,这样你可以打开一个新的dwg并继续,我会使用你删除的“插入”并更改为写入文件插入新的dwg等
 
使用ssget而不是entsel,然后您可以选择一个或多个网格标签,再进行一次包含所有代码的foreach。为什么不是网格标签的文本?与块相同的方法
 
最后一行代码是脚本平铺
 
  1. (setq fout (open "C:\acadtemp\tiles.scr" "w"))
  2. (setvar "filedia" 0)
  3. (write-line "new  " fout) ; note 2 spaces check for using default dwt etc
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\" bn "*.dwg")))
  6. (foreach Dwg Drawings
  7.    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  8. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  9. (Write-line dwgtile fout)
  10. )
  11. (close fout)
  12. ; last line
  13. (command "script" "C:\acadtemp\tiles")
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 06:58:24 | 显示全部楼层
比加尔,
 
谢谢你的帮助。我今天才回到办公室。复活节我们在爱尔兰度过了一个漫长的周末假期。
我正试图找出如何将你给我的东西整合到代码中。我知道“插入”被替换了。但是最后的剧本呢?我需要在那个位置存储什么脚本?
 
还有,我该如何按照你的建议使用“网格标签”?
我以前从未使用过或听说过它们,这就是我选择使用积木的原因。。
 
谢谢
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 07:01:36 | 显示全部楼层
这就是我的Bigal,但我在加载时遇到了一个错误:
 
  1. (defun c:Getmaptile  (/ bn chk pp bnloc)
  2. (setq bn "" chk nil); set block name nil
  3. (while (= chk nil)
  4. (setq chk (ssget "\nPick a Block: "))
  5. )
  6. (setq pp (cadr chk))
  7. (setq chk (entget (car chk)))
  8. (setq bn (cdr (assoc 2 chk))); get block name
  9. [color="red"](setq fout (open "C:\acadtemp\tiles.scr "w"))
  10. (setvar "filedia" 0)
  11. (write-line "new  " fout) ; note 2 spaces check for using default dwt etc[/color]
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\" bn "*.dwg")))
  14. (foreach Dwg Drawings
  15. [color="red"]    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  16. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  17. (Write-line dwgtile fout)
  18. (close fout)
  19. )[/color]
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\" bn "*.dwg")))
  22. (foreach Dwg Drawings
  23. [color="red"]    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  24. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  25. (Write-line dwgtile fout)
  26. (close fout)
  27. )[/color]
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\" bn "*.dwg")))
  30. (foreach Dwg Drawings
  31. [color="red"]    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  32. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  33. (Write-line dwgtile fout)
  34. (close fout)
  35. )[/color]
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. (princ)
  38. )
  39. [color="red"](command "script" "C:\acadtemp\tiles")[/color]
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41. ;; Function to list files from a wildcard match
  42. (defun matchfiles (path / item dir match lst fil files)
  43. (setq path (strsplit "," path))
  44. (foreach item path
  45.    (setq dir   (strcat (vl-string-right-trim "\" (vl-filename-directory item)) "\")
  46.          match (substr item (1+ (strlen dir)))
  47.          lst   (vl-directory-files dir match 1)
  48.    )
  49.    (foreach fil lst
  50.      (setq files (cons (strcat dir fil) files))
  51.    )
  52. )
  53. (reverse files)
  54. )
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. ;; Function to split a string on a specified character
  57. (defun strsplit (c str / lst p n)
  58. (setq n 0)
  59. (while (setq p (vl-string-search c str n))
  60.    (setq lst (cons (substr str (1+ n) (- p n)) lst))
  61.    (setq n (1+ p))
  62. )
  63. (if (< n (strlen str))
  64.    (setq lst (cons (substr str (1+ n)) lst))
  65. )
  66. (reverse lst)
  67. )

 
你能看一下吗?
谢谢
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 07:05:28 | 显示全部楼层
我犯的错误
“C:\acadtemp\tiles.scr”w“缺失”
“C:\acadtemp\tiles.scr”“w”
固定在上面
 
 
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 07:09:59 | 显示全部楼层
比加尔,
 
我对代码进行了更改以获得以下内容:
 
  1. (defun c:Getmaptile  (/ bn chk pp bnloc)
  2. (setq bn "" chk nil); set block name nil
  3. (while (= chk nil)
  4. (setq chk (ssget "\nPick a Block: "))
  5. )
  6. (setq pp (cadr chk))
  7. (setq chk (entget (car chk)))
  8. (setq bn (cdr (assoc 2 chk))); get block name
  9. (setq fout (open "C:\acadtemp\tiles.scr" "w"))
  10. (setvar "filedia" 0)
  11. (write-line "new  " fout) ; note 2 spaces check for using default dwt etc
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\" bn "*.dwg")))
  14. (foreach Dwg Drawings
  15.    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  16. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  17. (Write-line dwgtile fout)
  18. (close fout)
  19. )
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\" bn "*.dwg")))
  22. (foreach Dwg Drawings
  23.    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  24. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  25. (Write-line dwgtile fout)
  26. (close fout)
  27. )
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\" bn "*.dwg")))
  30. (foreach Dwg Drawings
  31.    ;(command "_.insert" Dwg "0,0,0" "1" "1" "0")
  32. (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0"))
  33. (Write-line dwgtile fout)
  34. (close fout)
  35. )
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. (princ)
  38. )
  39. (command "script" "C:\acadtemp\tiles")
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41. ;; Function to list files from a wildcard match
  42. (defun matchfiles (path / item dir match lst fil files)
  43. (setq path (strsplit "," path))
  44. (foreach item path
  45.    (setq dir   (strcat (vl-string-right-trim "\" (vl-filename-directory item)) "\")
  46.          match (substr item (1+ (strlen dir)))
  47.          lst   (vl-directory-files dir match 1)
  48.    )
  49.    (foreach fil lst
  50.      (setq files (cons (strcat dir fil) files))
  51.    )
  52. )
  53. (reverse files)
  54. )
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. ;; Function to split a string on a specified character
  57. (defun strsplit (c str / lst p n)
  58. (setq n 0)
  59. (while (setq p (vl-string-search c str n))
  60.    (setq lst (cons (substr str (1+ n) (- p n)) lst))
  61.    (setq n (1+ p))
  62. )
  63. (if (< n (strlen str))
  64.    (setq lst (cons (substr str (1+ n)) lst))
  65. )
  66. (reverse lst)
  67. )

 
每当我尝试运行它时,都会出现以下错误:
  1. GETM ; error: bad point argument

 
你知道这是什么吗?
回复

使用道具 举报

5

主题

194

帖子

193

银币

初来乍到

Rank: 1

铜币
24
发表于 2022-7-6 07:12:23 | 显示全部楼层
你好,woodman78,
 
错误消息的来源来自此行
 
  1. (setq chk (ssget "\nPick a Block: "))

 
在这种情况下,如果ssget,则需要使用entsel
 
当做
 
杰米
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 15:09 , Processed in 0.643942 second(s), 74 queries .

© 2020-2025 乐筑天下

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