乐筑天下

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

[编程交流] Import point + text on differe

[复制链接]

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 16:42:56 | 显示全部楼层 |阅读模式
Hy,
 
im a rookie with lisp, so i need an help (a big one) to complete a lisp.
I have an external txt file with a lot lines. The columns are in this way:
 
  1. 1st COLUMN: PROGRESSIVE NUMBER2nd COLUMN:        x COORDINATE3rd COLUMN:         y COORDINATE        4th COLUMN:         z COORDINATE                5th COLUMN:  DESCRIPTION
 
and i need to create in autocad a point with the coordinate and three texts at his side: the point and the texts must be on different layers and i need a separate block for every point with its texts (a block for every line of the external file).
 
my idea was something like this:
 
  1. IMPORT POINT + TEXT LISP1-        IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV BLOCK” (INDEX COLOR YELLOW: 2)2-        IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV POINT” (INDEX COLOR YELLOW: 2)3-        IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV TEXT NUMBER” (INDEX COLOR YELLOW: 2)4-        IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV TEXT Z” (INDEX COLOR GREEN: 3)5-        IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV TEXT ANNOTATION” (INDEX COLOR RED: 1)6-        COMMAND “PDMODE” “32”7-        SETQ “HEIGHTofTEXT”8-        HIDE OBJECTS: ALL9-        CURRENT LAYER: LAYER “LEV POINT” 10-        CREATE POINT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN 3rd COLUMN, 4th COLUMN)11-        CURRENT LAYER: LAYER  “LEV TEXT NUMBER”12-        CREATE MTEXT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN+“HEIGHTofTEXT”*1.5,  3rd COLUMN+“HEIGHTofTEXT”*1.5, 4th COLUMN)(TEXT HEIGHT “HEIGHTofTEXT”)(TEXT: NUMBER IN THE 1st COLUMN)13-        CURRENT LAYER: LAYER  “LEV TEXT Z”14-        CREATE MTEXT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN+“HEIGHTofTEXT”*1.5,  3rd COLUMN, 4th COLUMN)(TEXT HEIGHT “HEIGHTofTEXT”)(TEXT: NUMBER IN THE 4th COLUMN)15-        CURRENT LAYER: LAYER  “LEV TEXT ANNOTATION”16-        CREATE MTEXT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN+“HEIGHTofTEXT”*1.5,  3rd COLUMN-“HEIGHTofTEXT”*1.5, 4th COLUMN)(TEXT HEIGHT “HEIGHTofTEXT”)(TEXT: TEXT IN THE 5th COLUMN)17-        CURRENT LAYER: LAYER “LEV BLOCK” 18-        SELECT: ALL19-        CREATE BLOCK20-        HIDE OBJECTS: ALL21-        REPEAT FROM 9 TO 20 FOR ALL THE LINES IN THE EXTERNAL FILE22-        UNHIDE OBJECTS
 
I started to write the lisp and i arrive at the point 9 in this way:
 
  1. (defun C:LEV ()  (command "_.layer" "_MAKE" "LEV BLOCK" "COLOR" "2" ""  "_MAKE" "LEV POINT" "COLOR" "2" ""  "_MAKE" "LEV TEXT NUMBER" "COLOR" "2" ""  "_MAKE" "LEV TEXT Z" "COLOR" "3" ""  "_MAKE" "LEV TEXT ANNOTATION" "COLOR" "1" "" "")     (COMMAND "PDMODE" "32" "")  (COMMAND "HIDEOBJECTS" "ALL" "")  (COMMAND "_.CLAYER" "LEV POINT" "")(PRINC)  )
 
From here i dont know how to import the coordinate to create the points, the coordinate to create the text (my idea is to use the coordinate of the point and move a little bit the text on the right using the height of the text X a number)
 
Somebody can help me? I will appreciate a lot.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:29:02 | 显示全部楼层
A good ideas is write a little defun that checks for the layer and add that to an autoloading lisp like acaddoc.lsp this way its available for any program you write. Items 1-5
(laynew "lev_block" 2 "Continuous")
 
lee-mac has a good read line lisp that can make a list using a delimeter normally it would use the "," or a CSV file but you can use a space etc. If your columns are fixed length always then you can use substr start end to read the number of characters.
 
If you post a sample file it will confirm what your data file looks like, what you are asking for has been done many times only variation is the different layers.
 
Check out http://www.Lee-mac.com  point manager.
 
Another you can set variables directly like current layer (setvar 'clayer "TEXT") pdmode osmode filletrad to mention a few without using Command.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:12:25 | 显示全部楼层
Here is a simple make layer save it to say a autoloading lisp like acaddoc.lsp
 
  1. (defun mynewlayer ( layname col lt / )(if (or (= lt "C")(= lt "c"))(setq lt "Continuos")) ; shorthand typing in calling code(if (= (tblsearch "layer" layname) nil)(command "_.layer" "_MAKE" layname "COLOR" col "" "LT" lt "" ""))); in program; (mynewlayer "BIGAL" 3 "c")
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 13:55 , Processed in 0.408093 second(s), 58 queries .

© 2020-2025 乐筑天下

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