乐筑天下

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

[编程交流] 第一个帖子,已经在问了

[复制链接]

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 04:10:09 | 显示全部楼层 |阅读模式
大家好,我已经阅读这个论坛很多年了,但直到现在才加入。我正在学习一系列复杂的AutoLISP,到目前为止,我已经能够从互联网和一些同事那里拼凑出所有东西。现在我被一件相对简单的事情难住了。我希望从应用程序中获取数据的实体信息。我用李Mac的很棒的实体列表lisp来获取所有数据,但我只关心我要处理的所有文件的第二行,从“Facesamp”即(1000。“1003101”)开始。
 
以下是整个elist显示的内容
  1. (
  2.    (-1 . <Entity name: 7ffff7c7930>)
  3.    (0 . "LWPOLYLINE")
  4.    (5 . "18B")
  5.    (102 . "{ACAD_REACTORS")
  6.    (330 . <Entity name: 7ffff7c7c90>)
  7.    (102 . "}")
  8.    (330 . <Entity name: 7ffff7c19f0>)
  9.    (100 . "AcDbEntity")
  10.    (67 . 0)
  11.    (410 . "Model")
  12.    (8 . "0")
  13.    (100 . "AcDbPolyline")
  14.    (90 . 18)
  15.    (70 . 0)
  16.    (43 . 0.0)
  17.    (38 . 0.0)
  18.    (39 . 0.0)
  19.    (10 -3.29016 -5.0761)
  20.    (40 . 0.0)
  21.    (41 . 0.0)
  22.    (42 . 0.0)
  23.    (91 . 0)
  24.    (10 -5.11682 -4.97795)
  25.    (40 . 0.0)
  26.    (41 . 0.0)
  27.    (42 . 0.0)
  28.    (91 . 0)
  29.    (10 -4.39008 -2.89717)
  30.    (40 . 0.0)
  31.    (41 . 0.0)
  32.    (42 . 0.0)
  33.    (91 . 0)
  34.    (10 -4.05618 -0.384532)
  35.    (40 . 0.0)
  36.    (41 . 0.0)
  37.    (42 . 0.0)
  38.    (91 . 0)
  39.    (10 -3.91869 1.14661)
  40.    (40 . 0.0)
  41.    (41 . 0.0)
  42.    (42 . 0.0)
  43.    (91 . 0)
  44.    (10 -4.31152 3.24702)
  45.    (40 . 0.0)
  46.    (41 . 0.0)
  47.    (42 . 0.0)
  48.    (91 . 0)
  49.    (10 -2.20987 3.22739)
  50.    (40 . 0.0)
  51.    (41 . 0.0)
  52.    (42 . 0.0)
  53.    (91 . 0)
  54.    (10 -2.68127 2.20663)
  55.    (40 . 0.0)
  56.    (41 . 0.0)
  57.    (42 . 0.0)
  58.    (91 . 0)
  59.    (10 -3.34642 0.766316)
  60.    (40 . 0.0)
  61.    (41 . 0.0)
  62.    (42 . 0.0)
  63.    (91 . 0)
  64.    (10 -3.47677 0.0853092)
  65.    (40 . 0.0)
  66.    (41 . 0.0)
  67.    (42 . 0.0)
  68.    (91 . 0)
  69.    (10 -3.7277 -0.638116)
  70.    (40 . 0.0)
  71.    (41 . 0.0)
  72.    (42 . 0.0)
  73.    (91 . 0)
  74.    (10 -3.76631 -1.17827)
  75.    (40 . 0.0)
  76.    (41 . 0.0)
  77.    (42 . 0.0)
  78.    (91 . 0)
  79.    (10 -3.46711 -1.73772)
  80.    (40 . 0.0)
  81.    (41 . 0.0)
  82.    (42 . 0.0)
  83.    (91 . 0)
  84.    (10 -3.07141 -2.0078)
  85.    (40 . 0.0)
  86.    (41 . 0.0)
  87.    (42 . 0.0)
  88.    (91 . 0)
  89.    (10 -2.83282 -2.4172)
  90.    (40 . 0.0)
  91.    (41 . 0.0)
  92.    (42 . 0.0)
  93.    (91 . 0)
  94.    (10 -2.79641 -2.99942)
  95.    (40 . 0.0)
  96.    (41 . 0.0)
  97.    (42 . 0.0)
  98.    (91 . 0)
  99.    (10 -2.92433 -3.82089)
  100.    (40 . 0.0)
  101.    (41 . 0.0)
  102.    (42 . 0.0)
  103.    (91 . 0)
  104.    (10 -3.29016 -5.0761)
  105.    (40 . 0.0)
  106.    (41 . 0.0)
  107.    (42 . 0.0)
  108.    (91 . 0)
  109.    (210 0.0 0.0 1.0)
  110.    (-3
  111.      (
  112.        "FACESAMP"
  113.        (1002 . "{")
  114.        (1000 . "1003101")
  115.        (1002 . "}")
  116.      )
  117.    )
  118. )

 
长话短说,我要做的是遍历我绘制的所有图形,给多段线上色,并根据csv文件中的数字对其进行图案填充。到目前为止,我已经用lisp创建了具有独特颜色的新层,用lisp在每个层中创建填充图案,用lisp正确读取csv文件并将其解析为数字(第二列对应于“(1000)”的第二部分)1003101")".  所以现在我正在慢慢研究如何读取实体信息,然后将csv信息与之关联。有什么想法吗?
 
谢谢大家,这个论坛对我来说是一个巨大的信息来源!
 
斯科特
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 04:17:42 | 显示全部楼层
欢迎来到CADTutor Scott,我很高兴您找到了我的实体列表实用程序
 
以下代码将根据需要从实体DXF数据中检索值1003101:
假设是所讨论对象的实体名称。
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 04:25:24 | 显示全部楼层
哇,谢谢!在我开始学习autolisp的过程中,你帮了我很大的忙!我试试看。看起来每个多段线的实体名称都会更改-我通常每个图形有3到10条闭合多段线-如何自动查看所有多段线?(我有一个图像文件、多段线、文本和块引用。唯一的多段线对象是我想要获取信息的对象)
 
 
令人沮丧的是,我有一个在autocad 2000i中工作的autolisp,但由于某种原因停止了工作,这就是我试图从头开始重建它的原因。它在lisp开始后立即失败。我已经附加了导致故障的部分。
 
  1. (defun c:addnsr (fn)
  2. ; Extend entity data is associated with FACESAMP app
  3. (setq rname "FACESAMP")
  4. (regapp rname)
  5. (setq dr "")
  6. (setq ff (strcat dr fn))
  7. (setq f (open ff "r")) ;Open filename passed as parameter
  8. (setq a (list 0 0))
  9. (setq b (list -999 0))
  10. (setq samplist (list a b))
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 04:31:06 | 显示全部楼层
; 错误:我得到的错误是参数太少。事情是这样的。
 
我已经把它分成越来越小的部分,看看它在哪里崩溃了,这就是上面的代码。
 
  1. (defun addopt (fn)
  2. ; Extend entity data is associated with FACESAMP app
  3. (setq rname "FACESAMP")
  4. (regapp rname)
  5. (setq dr "")
  6. (setq ff (strcat dr fn))
  7. (setq f (open ff "r")) ;Open filename passed as parameter
  8. (setq a (list 0 0))
  9. (setq b (list -999 0))
  10. (setq samplist (list a b))
  11. (while (setq l (read-line f))
  12. ;set variables for reading data from a csv file
  13. ;which contains the fields sample,Au_Opt
  14. (setq linelen (strlen l))   ;line length
  15. (setq cchar (substr l 1 1)) ;current character
  16. (setq fchar 1)              ;first character of field
  17. (setq ccount 1)             ;current count
  18. (while (<= ccount linelen)
  19.         ;read through the current line and find the commas
  20.         (setq cchar (substr l ccount 1))
  21.         (if (= cchar ",")
  22.                 (progn
  23.                 ;charlen is the field length
  24.                         (setq charlen (- ccount fchar))
  25.                         (setq samp (substr l fchar charlen))
  26.                         (setq fchar (+ 1 ccount))
  27.                 )  ;end progn
  28.         )        ;end if
  29.         ;leading spaces are removed
  30.         (if (= cchar " ") (setq fchar (+ 1 ccount)) )
  31.         ;increment character counter
  32.         (setq ccount (+ 1 ccount))
  33. ) ;end while, character reader
  34. (setq Au_Opt (substr l fchar linelen))  
  35. (setq samp (atoi samp))
  36. (setq Au_Opt (atoi Au_Opt))
  37. (setq newlist (list samp Au_Opt))
  38. (setq samplist (cons newlist samplist ))
  39. ); end of WHILE (setq l..
  40. (close f)
  41. ; select polyline, pick null to end
  42. (setq sset (ssget "X" '((0 . "LWPOLYLINE")))); select all LWpolyline in dwg
  43. (command "layer" "n" "LT0" "n" "0-0.08" "n" "0.08-0.15" "n" "0.15-0.30" "n" "0.30-0.50" "n" "0.50-1.00" "n" "GT1.00" "")
  44. (command "layer" "co" "9" "LT0" "co" "5" "0-0.08" "co" "4" "0.08-0.15" "co" "3" "0.15-0.30" "co" "2" "0.30-0.50" "co" "1" "0.50-1.00" "co" "6" "GT1.00" "" )
  45. (command "layer" "LW" "0.35" "LT0" "LW" "0.35" "0-0.08" "LW" "0.35" "0.08-0.15" "LW" "0.35" "0.15-0.30" "LW" "0.35" "0.30-0.50" "LW" "0.35" "0.50-1.00"  "LW" "0.35" "GT1.00" "")
  46. (setq entnum 0); Initilize entnum for while loop
  47. (while (setq p (ssname sset entnum))
  48.    (setq elist (entget p (list "*"))); includes xdata for all regd apps
  49.    (if (assoc -3 elist)
  50.    (progn
  51. (setq sampnum (cdr (nth 2 (nth 1 (assoc -3 elist)))));Get sampleID from elist
  52. (setq samp (atoi sampnum))
  53. (setq Au_Opt (car (cdr (assoc samp samplist))))
  54. (setq layer (cons 8 "LT0"));Default LAYER
  55. (if (> Au_Opt 0)
  56.         (progn (setq layer (cons 8 "0-0.08"))))
  57. (if (> Au_Opt 0.08)
  58.         (progn (setq layer (cons 8 "0.08-0.15"))))
  59. (if (> Au_Opt 0.15)
  60.         (progn (setq layer (cons 8 "0.15-0.30"))))
  61. (if (> Au_Opt 0.30)
  62.         (progn (setq layer (cons 8 "0.30-0.50"))))
  63.    (if (> Au_Opt 0.50)
  64.         (progn (setq layer (cons 8 "0.50-1.00"))))
  65. (if (> Au_Opt 1.00)
  66.         (progn (setq layer (cons 8 "GT1.00"))))
  67. (setq ed (entget p))
  68. (setq ed (subst layer (assoc 8 ed) ed))
  69. (entmod ed)
  70.     );end of PROGN entnum
  71.     ); end of IF (assoc -3 ...
  72.     (setq entnum (+ 1 entnum))
  73.   
  74. ); end of WHILE (setq p..
  75. ;HATCH BY LAYER
  76. (command "layer" "s" "0.08-0.15" "")
  77. (if (setq sset (ssget "X" '((-4 . "<OR")(8 . "0.08-0.15")(8 . "text")(-4 . "OR>")))) (command "HATCH" "NET" "6" "45" "P" ""))
  78. (command "layer" "s" "0.15-0.30" "")
  79. (if (setq sset (ssget "X" '((-4 . "<OR")(8 . "0.15-0.30")(8 . "text")(-4 . "OR>")))) (command "HATCH" "NET" "5" "45" "P" ""))
  80. (command "layer" "s" "0.30-0.50" "")
  81. (if (setq sset (ssget "X" '((-4 . "<OR")(8 . "0.30-0.50")(8 . "text")(-4 . "OR>")))) (command "HATCH" "NET" "4" "45" "P" ""))
  82. (command "layer" "s" "0.50-1.00" "")
  83. (if (setq sset (ssget "X" '((-4 . "<OR")(8 . "0.50-1.00")(8 . "text")(-4 . "OR>")))) (command "HATCH" "NET" "3" "45" "P" ""))
  84. (command "layer" "s" "GT1.00" "")
  85. (if (setq sset (ssget "X" '((-4 . "<OR")(8 . "GT1.00")(8 . "text")(-4 . "OR>")))) (command "HATCH" "NET" "3" "45" "P" ""))
  86. ;(command "layer" "s" "text" "")
  87. ;(command "style" "standard" "arial.ttf" "" "" "" "" "")
  88. (command "layer" "s" "0" "")
  89. (command "zoom" "e" )
  90. (command "zoom" "0.95x" )
  91. (command "lwdisplay" "ON")
  92. (command "WMFBKGND" "OFF")
  93. (command "WMFOUT" "" "ALL" "")
  94. (vl-load-COM)
  95. (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  96. (vla-put-GraphicsWinModelBackgrndColor disp 16777215)
  97. (vla-put-modelcrosshaircolor disp 0)
  98. (command "BMPOUT" "" "ALL" "")
  99. (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  100. (vla-put-GraphicsWinModelBackgrndColor disp 0)
  101. (vla-put-modelcrosshaircolor disp 16777215)
  102. )

 
请注意,在您的第一篇帖子中:
  1. (setq sset (ssget "X" '((0 . "LWPOLYLINE")))); select all LWpolyline in dwg

 
上面的(setq sset)将向选择集中添加所有dxf组0读取LWDOLYLINE的项目,如上面的行,但零件可以不同,它仍将选择它们。我想这就是你想要找到的?
 
那将。。。。那么,选择dwg中的所有多段线,包括模型空间和图纸空间。
请再次从李的网站上查看此链接以获取更多信息。
http://www.lee-mac.com/ssget.html
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-6 04:35:29 | 显示全部楼层
也是为了你;错误:参数太少
如果您输入
在命令提示符下添加nsr FILENAME,它可以修复错误,也可以使用完整例程
  1.    (-1 . <Entity name: 7ffff7c7930>)
  2.    (0 . "LWPOLYLINE")

 
您必须这样做(addopt filename)(只需添加括号,因为函数名的前面没有C:这允许键入它以从命令行执行)
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 04:40:29 | 显示全部楼层
李对此不确定,因为我们的实体没有检查代码cdadr
回复

使用道具 举报

15

主题

243

帖子

228

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 04:45:09 | 显示全部楼层
 
对不起,我不明白你的帖子-比格尔有什么问题?
回复

使用道具 举报

15

主题

243

帖子

228

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 04:48:39 | 显示全部楼层
您是如何确定代码的哪些部分不起作用的?这对你有用吗?
如果是,你是如何使用它的?
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 04:56:22 | 显示全部楼层
啊,得到了修复,基本上我破坏了一个bat文件,该文件将调用之前附加的带有csv文件名的代码
  1. 7

 
我重新加载了一个备份版本,效果很好。抱歉占用大家的时间!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 05:02:34 | 显示全部楼层
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 18:52 , Processed in 0.926762 second(s), 72 queries .

© 2020-2025 乐筑天下

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