乐筑天下

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

[编程交流] [Autolisp] - Download data - q

[复制链接]

41

主题

120

帖子

84

银币

后起之秀

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

铜币
200
发表于 2022-7-6 08:05:31 | 显示全部楼层 |阅读模式
Hello.
I use this feature:
  1. (defun nnnn (nek / ss dana)(if (setq ss (ssget "x" (list (cons 0 "text,mtext") (cons 8 nek))))        (setq dana (dxf 1(entget (ssname s 0))))        (setq dana "0" ))        (if (numberp dana)                (setq dana (rtos dana 2 2))                (setq dana dana)        )                (princ (strcat "\n " nek " --> " dana))dana)(defun c:wer ( / a b c d)(setq a (nnnn "layer1"))(setq b (nnnn "layer2"))(setq c (nnnn "layer3"))(setq d (nnnn "layer4")).....)
Sure, it can be easier to write so please help. Sure, it can be avoided in some way to repeatedly search the drawing database, but do not know how. This function is used to download the text of a particular layer.
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 08:21:42 | 显示全部楼层
Forgive me, but it is hard to understand what it is you're asking for exactly...
 
I believe that you're wanting a sub-function that accepts a layer name argument as string, and are attempting to return a list of text strings for all Mtext and Text entities on the argument layer. If so, these may help:
 
This example uses DXF code -
  1. (defun GetTextStringsByLayer (layerName / ss e textStrings) ;; Example: (GetTextStringsByLayer "SomeLayer") (if (and (tblsearch "layer" layerName)      (setq ss (ssget "_x" (list '(0 . "MTEXT,TEXT") (cons 8 layerName)))))   (progn     (setq i -1)     (while (setq e (ssname ss (setq i (1+ i))))       (setq textStrings (cons (cdr (assoc 1 (entget e))) textStrings)))))
 
This example uses vla-* TextString Property -
  1. (defun GetTextStringsByLayer (acDoc layerName / ss) ;; Example: (GetTextStringsByLayer (vla-get-activedocument (vlax-get-acad-object)) "SomeLayer") (if (and (= 'VLA-OBJECT (type acDoc))          (tblsearch "layer" layerName)          (setq ss (ssget "_x" (list '(0 . "MTEXT,TEXT") (cons 8 layerName)))))   (progn     (vlax-for oText (setq ss (vla-get-activeselectionset acDoc))       (setq textStrings (cons (vla-get-textstring oText) textStrings)))     (vla-delete ss))))
 
HTH
回复

使用道具 举报

41

主题

120

帖子

84

银币

后起之秀

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

铜币
200
发表于 2022-7-6 08:27:48 | 显示全部楼层
I use this function:
"(nnnn "layer1")" about 40 times in my program.
Each time searching the base drawing.
The question is: is it necessary, it may be easier.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 08:41:30 | 显示全部楼层
 
What does the routine do ?
What is your aim of the code ?
 
Explain your needs clearly to get the accurate answer
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 08:52:32 | 显示全部楼层
Without more information it is hard to know for sure... However, redundancy is generally not a good practice, unless necessary.
 
If the purpose of your function is extract information, then simply store the extracted information to a variable and query, or manipulate the variable thereafter.
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 08:58:29 | 显示全部楼层
Just as long as that "data" is not a selection set. From the OP it seems to be. I'd highly advise against saving a selection set into a global variable. 
From the nnnn function it appears you simply want to list the 1st text placed on the specified layer - to the command line. You might save just that text's ename, but then what if it's erased / changed to a different layer?
 
Again, we require some more info on what you're trying to accomplish. We might be pointing you into a direction which could cause problems down the line. It's for your own benefit to explain as clearly as possible for us hard-of-understanding people
回复

使用道具 举报

41

主题

120

帖子

84

银币

后起之秀

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

铜币
200
发表于 2022-7-6 09:07:55 | 显示全部楼层
Sorry it's probably the language difficulties.
The idea is this:
- Creating drawings of interest to me put the data on specific layers.
- Then using Lisp takes this data and somehow, further transformed (multiplying, dividing by typing in other places).
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 21:47 , Processed in 1.789119 second(s), 66 queries .

© 2020-2025 乐筑天下

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