乐筑天下

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

[编程交流] Editing sub-entities in a obje

[复制链接]

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 18:10:24 | 显示全部楼层 |阅读模式
While checking for dxf group codes in a text with a field inside I've found some  inside it, wich i looked further. For example, i would directly get
 
Select entity((-1 . ) (0 . "TEXT") (5 . "602428") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "est.Texto") (6 . "Continuous") (370 . 0) (100 . "AcDbText") (10 3811.01 -3721.81 0.0) (40 . 0.15) (1 . "1.05") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Leg0.15") (71 . 0) (72 . 1) (11 3811.22 -3721.73 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 2))
 
And when looking for what was inside code group 360 I'd go further and find other properties.
 
So I've partially written the following to reach a field code path
 
 
  1. (defun c:dump3 ( / a e o s x texto tipodepeca z y ent ent2 ent3 ent4)   (if (setq s (ssget "_:L" '((0 . "TEXT")) ))       (repeat (setq i (sslength s))           (setq e (ssname s (setq i (1- i)))                 x (entget e)                 ent (entget(cdr (assoc 360 x)))                          ent2 (entget(cdr (assoc 360 ent)))                          ent3 (entget(cdr (assoc 360 ent2)))                          ent4 (entget(cdr (assoc 360 ent3)))           )                                (prin1 ent4) ;shows groups with field expression paths(entmod (subst '(331 . "") (assoc 331 ent4) ent4)); attempt to edit the codegroup 331 on entity "4 levels below"        ))(princ))(princ)
 
I've tried to change the entity on groupcode 331, but i'm getting the following error everytime:
 
error: bad DXF group: (331 . "")
 
Any hint?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:24:58 | 显示全部楼层
Entity names are pointers to locations within the drawing database, they are not strings and cannot be represented as literal data in code; entity names (and hence Object IDs) are also not persistent between drawing sessions, but are allocated ad hoc.
回复

使用道具 举报

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 18:36:05 | 显示全部楼层
Thanks, I've just closed my drawing, re-opened, and yes its true, the id changes. The vla-fieldcode can only read the current code. Which means I'm out of ways to edit the table linked to the field. Do you have any idea how to do this Lee Mac? (no need to code for me, just point me in the direction)
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:42:24 | 显示全部楼层
Retrieve the Object ID of the new object to be referenced by the field code, rebuild the field code using the new Object ID, and then update the content of the object which is to contain the field using vla-put-textstring to automatically rebuild the associated field dictionaries.
回复

使用道具 举报

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 19:00:12 | 显示全部楼层
So I would get the ID from codegroup -1 of the table in that session,
 
then rebuild the field as in
 
  1. (entmod (subst '(2 . "\\AcExpr (Table(%%).C3) \\f "%lu2%pr3"") (assoc 2 ent4) ent4))
 
replacing (%%) by the decimal value of the number in codegroup -1
 
and then update the content of the text object? When i perform a list on the text object I get the following:
 
Select entity((-1 . ) (0 . "TEXT") (5 . "61BFA6") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "est.Texto") (6 . "Continuous") (370 . 0) (100 . "AcDbText") (10 3811.01 -3721.81 0.0) (40 . 0.15) (1 . "1.05") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Leg0.15") (71 . 0) (72 . 1) (11 3811.22 -3721.73 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 2))
 
Nothing here seems a text string i could replace to finalize your steps
回复

使用道具 举报

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 19:00:52 | 显示全部楼层
The first 2 steps are working, but when I save and re-open the drawing, #### shows up instead of the value I had before. So I'm missing just that last step. What kind of string should I apply? It's on the text object for sure, but, what string it is? I mean literally, I have no idea what string I should place on a text object to simulate a field
回复

使用道具 举报

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 19:13:04 | 显示全部楼层
Done..
 
  1. (defun c:dump6 ( / a e o s x texto tipodepeca z y ent ent2 ent3 ent4 obj tabela count count2)   (setq count 2)    ;(setq tabela (entget (entsel "\nEscolher tabela")))   (if (setq s (ssget "_:L" '((0 . "TEXT")) ))       (repeat (setq i (sslength s))           (setq e (ssname s (setq i (1- i)))                 x (entget e)                 ent (entget(cdr (assoc 360 x)))                          ent2 (entget(cdr (assoc 360 ent)))                          ent3 (entget(cdr (assoc 360 ent2)))                          ent4 (entget(cdr (assoc 360 ent3)))           )                    (setq count (1+ count))                     ;o codigo da table é convertido de hexa para decimal e colocado aqui                (entmod (subst (cons 2 (strcat "\\AcExpr (Table(8796085420640).B" (itoa count) ") \\f "%lu2%pr3"")) (assoc 2 ent4) ent4))                (prin1 count)                ;FAZER REGEN ANTES DE SAIR        ))(princ))(princ)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 20:22 , Processed in 0.436679 second(s), 66 queries .

© 2020-2025 乐筑天下

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