乐筑天下

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

[编程交流] Dynamic block - analyzing (LM&

[复制链接]

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:51:28 | 显示全部楼层 |阅读模式
Hi code fellas,
Today I tried to utilize Lee Mac's "Dynamic Block Functions", and his "List Box".
 
So my attempt is to:
Select a dynamic block and it should return its:
1.Effective name
2.Visibility state parameter's name and its value (maybe a list is better?)
3.List of attribute's names and values (in a listbox)
4.List of parameter's names and values (in a listbox)
 
Ofcourse the reason I'm making a thread is because I probably did something wrong:

[code](defun C:test ( / sel blkname ) (vl-load-com) (setvar 'errno 0) (prompt "\nSelect block to analyze" ) (if (and (setq sel (ssget "_:S:E" '((0 . "INSERT"))))          (setq blkname (LM:al-effectivename (ssname sel 0)))                        ;
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 17:58:28 | 显示全部楼层
Hi,
 
Read the comments of each function and compare it to the error message then you should know how to correct it. (hint : convert it)
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:05:03 | 显示全部楼层
Thanks for the hint, Tharwat!
  1.      (if     (setq vis-state-val (LM:getvisibilitystate (vlax-ename->vla-object (ssname sel 0)) ))     (princ (strcat "\nVisibility state value: " vis-state-val " "))    );if
 
 
I'm almost there!
Do you have any more hints up on your sleeve, about this:
  1.      (if     (setq lst-atts (LM:GetAttributes (ssname sel 0)))     (LM:listbox "Select an attribute" lst-atts 1)    );if
The list box flashes(opens and closes immediately) and I get this:
  1. Select objects:BlockName is "VLD_ОСИ_V3"Visibility state parameter: Visibility1Visibility state value: BothVisibleError: bad argument type: stringp ("X1" . "Ж")
 
I know that the problem is because LM:GetAttributes returns an association list, but how do I split the tags and the values from it? So I end up with two lists for the listbox
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:09:17 | 显示全部楼层
 
You can use mapcar function to get each tag name and text string in a separate list.
e.g;
 

[code](mapcar 'car lst-atts) ;;
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:18:45 | 显示全部楼层
Thanks alot, Tharwat!
I often read about mapcar and lambda but they're hard to understand and I rarely use them.
Maybe I'll neeed to learn more about list manipulation, since I'm used to work only with setting quotes in LISP.
 
I have one last question:
 
If I have this list (lst1) , and I filter-out all of its items, except one in a new list (lst2),
and I end up with list which contains only one item - Is it possible to set a quote for that item?
 
Because my current method for handling this problem is this:
  1.     (foreach itm lst ;; For every 'itm' in the list given by 'lst'   (princ (strcat "\nCurrent item is "" itm "" "  ))    ) ;; end foreach
But this seems very limited, as I can't proceed with any IF/COND outside the FOREACH function.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:20:08 | 显示全部楼层
You are welcome.
 
 
That is essential and Lisp word is somehow has the combination meaning of the tow words LISt Processing.
 
 
I am sorry I did not get your point.
Why you are after quoting an item from a list since it would be a list at the end ?
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:26:20 | 显示全部楼层
Yes, I've read why its called LISP ! And I'm ashamed with my lack of knowledge using lists !
 
To my question:
I mean if I'm about to extract per one item from 3-4 different lists, wouldn't be more comfortable to quote these items and then proceed?
Otherwise it would become some wrapping of foreach functions, for one element per list:
  1. (foreach itm1 lst1 (foreach itm2 lst2   (foreach itm3 lst3     (do my stuff with itm1 itm2 and itm3)   ) ))
 
Maybe "last" function would help, but I'm not sure:
  1. (setq itm1 (last lst1) )(setq itm2 (last lst2) )(setq itm3 (last lst3) )(do my stuff with itm1 itm2 and itm3)
My question is because that with every code I try to write:
I'm used first to READ/INPUT information (from user) and then the program proceeds and in the end user gets the RETURN information from the program.
 
I try to avoid those syntaxes from the begining to the end of the program, since its very confusing.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:31:41 | 显示全部楼层
You need to give a practical example , anyway maybe append function would help to reduce the quantity of foreach function by appending lists into one list then proceed with one list.
 
In regard to quote , I am still can't get your point but anyway there is a function call quote , try it.
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:37:19 | 显示全部楼层
Thank you, Tharwat !
I'm glad that in this forum there are guys like you, skilled and helpful!
I'll continue with my experiments now.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:41:11 | 显示全部楼层
I am glad to be of any assistant.
 
Best of luck.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 01:08 , Processed in 0.685350 second(s), 72 queries .

© 2020-2025 乐筑天下

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