乐筑天下

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

[编程交流] Help with Layers, TBLSearch, a

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 11:27:49 | 显示全部楼层 |阅读模式
Hello all,
 
I need some assistance with the following code. I am trying to make a LISP routine that:
1. Verifies if certain layers are present and adds them if not
2. Adds/changes linetype of said layers
3. Adds/changes color of said layers
4. Adds/changes lineweight of said layers
 
The problem I am having is that
  1. (TBLSEARCH "LAYER" layer_name)
is not accepting strings from the lists I've made. It returns
  1. ; error: bad argument type: stringp ("T-Center")
 
Ideally I'd be reading the layer data from cells in Excel, but I've not savvy enough to do that yet. So I am starting with this.
 
Other refinements are more than welcome.
 
Thanks for any help.
 
  1. (DEFUN c:tseat2 (/          layer_list         layer_color_list          current_layer      flayer_color_list  layer_set          linetype_name      layer_name         layer          item          layer_linetype_list          flayer_linetype_list             layer_lineweight_list          flayer_lineweight_list         ) (SETQ    layer_list    (LIST      '("T-Center")      '("T-Seat")    )                ; end list )                    ; end setq (SETQ    layer_linetype_list    (LIST      '("T-Center" "center")      '("T-Seat" "continuous")    )                ; end list )                    ; end setq  (SETQ    layer_color_list    (LIST      '("T-Center" 2)      '("T-Seat" 1)     )                ; end list )                    ; end setq (SETQ    layer_lineweight_list    (LIST      '("T-Center" "0.13")      '("T-Seat" "0.35")     )                ; end list )                    ; end setq (VL-LOAD-COM) ;; Check to see if layer exists, if not create it (FOREACH layer_name layer_list   (IF    (NOT (TBLSEARCH "LAYER" layer_name))     (PROGN   (SETQ layer (VLA-ADD             (VLA-GET-LAYERS           (VLA-GET-ACTIVEDOCUMENT             (VLAX-GET-ACAD-OBJECT)           )             )             layer_name           )   );End setq     )   );End if );End foreach ;; Loading Linetypes (FOREACH linetype_name layer_linetype_list   (IF    (NOT (TBLSEARCH "LTYPE" linetype_name))     (VLA-LOAD   (VLA-GET-LINETYPES     (VLA-GET-ACTIVEDOCUMENT       (VLAX-GET-ACAD-OBJECT)     )   )   linetype_name   "acad.lin"     )   );End if );End foreach ;; Set Layer Colors (FOREACH layer layer_color_list   (IF     (NOT   (VL-CATCH-ALL-ERROR-P     (SETQ    current_layer        (VL-CATCH-ALL-APPLY          'VLA-ITEM          (LIST (VLA-GET-LAYERS              (VLA-GET-ACTIVEDOCUMENT                (VLAX-GET-ACAD-OBJECT)              )            )            (CAR layer)          );End List        )     );End Setq   )     );End If      (PROGN    (VLA-PUT-COLOR current_layer (CADR layer))    (SETQ flayer_color_list       (LIST (CONS 8 (VLA-GET-NAME current_layer)))    );End Setq    (SETQ flayer_linetype_list       (LIST (CONS 8 (VLA-GET-NAME current_layer)))    );End Setq    (SETQ flayer_lineweight_list       (LIST (CONS 8 (VLA-GET-NAME current_layer)))    );End Setq    (IF      (SETQ layer_set (SSGET "_X" flayer_color_list))       (PROGN         (FOREACH item               (MAPCAR 'VLAX-ENAME->VLA-OBJECT                   (VL-REMOVE-IF                     'LISTP                     (MAPCAR 'CADR (SSNAMEX layer_set))                   )               )       (VLA-PUT-COLOR item ACBYLAYER)         )                ; end foreach       )                ; end if    (IF      (SETQ layer_set (SSGET "_X" flayer_linetype_list))       (PROGN         (FOREACH item               (MAPCAR 'VLAX-ENAME->VLA-OBJECT                   (VL-REMOVE-IF                     'LISTP                     (MAPCAR 'CADR (SSNAMEX layer_set))                   )               )       (VLA-PUT-LINETYPE item ACBYLAYER)         )                ; end foreach       )                ; end if     (IF      (SETQ layer_set (SSGET "_X" flayer_lineweight_list))       (PROGN         (FOREACH item               (MAPCAR 'VLAX-ENAME->VLA-OBJECT                   (VL-REMOVE-IF                     'LISTP                     (MAPCAR 'CADR (SSNAMEX layer_set))                   )               )       (VLA-PUT-LINEWEIGHT item ACBYLAYER)         )                ; end foreach       )                ; end if    )                ; end progn      )                ; end progn   )                    ; end if )                    ; end foreach (PRINC))                    ; end
回复

使用道具 举报

12

主题

395

帖子

384

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
60
发表于 2022-7-6 11:39:54 | 显示全部楼层
Sorry I haven't written in a while and i didnt get a chance to look over your code but it seems like you are trying to input a list where a string should go.
 
 
  1. ; error: bad argument type: stringp ("T-Center")
 
("T-Center") should be "T-Center"
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 11:55:01 | 显示全部楼层
Indeed it is acting as though I am passing it a list,instead of a string, but its part of a FOREACH command, so it should be parsing the list entry by entry and passing it to the TBLSEARCH command. That's my dilemma.
 
[/code](FOREACH layer_name layer_list
    (IF    (NOT (TBLSEARCH "LAYER" layer_name))[/code]
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 12:07:51 | 显示全部楼层
 
You are making a list of lists here,not a string list
 
  1. (("T-Center"))
 
where you would want
  1. ("T-Center")
 
  1. (SETQ    layer_list;     (LIST      '("T-Center")      '("T-Seat");     )                ; end list )                    ; end setq
 
 
HTH  -David
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 12:18:40 | 显示全部楼层
I've got a good handle on this now. Thanks everyone.
回复

使用道具 举报

12

主题

395

帖子

384

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
60
发表于 2022-7-6 12:31:05 | 显示全部楼层
The excel portion isn't that hard. I'm not sure to what extent you would be using it but the basics are easy.
  1. (defun basics (vscaleav / thefilename) (vl-load-com) ; This makes it possible to use vl commands (setq thefilename "c://filepath.xls") ; This sets the file you want to open (setq excapp (vlax-get-or-create-object "Excel.Application")) ; This sets the excel application  ; Create VBA objects from data (global) (if excapp   (setq wCells (vlax-get (vlax-get-property (vlax-get (vla-open (vlax-get excapp "Workbooks") thefilename) "Sheets") "Item" 1) "Cells")); this brings you down to the cell level from here everything is easy   ); /If (vlax-put-property wCells "Item" 15 1 vscaleav); this code places a variable "vscaleav" in row 15 column 1 into excel. I you used vlax-get-property it would extract information from that row or cell (princ) ); /Defun
 
If you have a good handle on how lisp works then you should be able to write something basic from here.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 02:19 , Processed in 0.512535 second(s), 64 queries .

© 2020-2025 乐筑天下

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