乐筑天下

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

[编程交流] nentsel, entget, ssget questio

[复制链接]

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 10:51:29 | 显示全部楼层 |阅读模式
I am working on a macro that will put all my entities in a drawing color to bylayer.  Here is my code so far and it works but I have to select each entity one at a time.
 
  1. (defun C:CBL ( / oldData newData);=========================================== (While (setq oldData (entget(car(nentsel)))) (setq newData (subst (cons 62 256)(assoc 62 oldData)oldData)) (entmod newData) (command "REGEN"));end while;========================================== (princ))
 
 
 
Question #1
 
How would I use ssget to accomplish this task?  (ssget "x")
I am having trouble understanding how to use ssget.
 
 
Question #2
 
(subst (cons 62 256)(assoc 62 oldData)oldData) from my above code.
 
I don't 100% understand how this works.  Why do I use oldData at the end of this function?  Why do I have to call oldData twice?  Can someone explain what each oldData is doing?
 
 
Question #3
 
My ultimate goal is to be able to put all entities in a drawing plotstyle to bylayer.  This seems to be a much bigger task from what I am reading.
 
Is there not a DXF code for plot syle?  How do I access the plotsyles to modify it.  Seems it is a vl functions but I am not at that level of understanding LISP yet, so how was it accomplished before Visual Lisp done in "vanilla LISP"?
 
 
Thanks
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 10:56:50 | 显示全部楼层
You can select all the objects in your drawing and stright to the pop-up-list of Layer Colors and select it ByLayer and that will solve the issue.
 
Regards
Tharwat
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 2022-7-6 11:01:30 | 显示全部楼层
this might be a shortcut
(command "change" "all" "" "properties" "color" "bylayer" "")
draw backs are:
if you are in model space it will only change those objects
if you are in paper space it will only chanf that tab
 
if you want to change all objexts in model and paper you need to use ssget "x" then use a while loop with ssname
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 11:01:47 | 显示全部楼层
This will select all entities in your drawing
 
  1. (setq objs (ssget "_x"))
 
 
Regards.
 
Tharwat
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:05:22 | 显示全部楼层
2008 had the SetByLayer command.
回复

使用道具 举报

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 11:09:45 | 显示全部楼层
 
 
 
Thanks Alan
 
 
This command does everything I want my macro to do. I wish I knew about this command before now, This is great. Thanks
 
 
 
But
 
I am still on the quest to understand how to do it via lisp...
 
 
 
Can you take a crack at question #2 for me? I would like to understand how the "assoc" function works and why I have to call out oldData twice.
 
 
Thanks
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:12:44 | 显示全部楼层
I posted this a while back about using SetByLayer:
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:16:00 | 显示全部楼层
Answer to question #2:
 
Subst has three parameters that must be filled.
  1. (subst   )
= the item you want to replace the old with.
   = the old item you want to replace with new (you don't know it, so you must call it from the list)
   = the list you want to edit.
 
eg.
  1. Command: (setq lst (list (cons 1 "ALAN") (cons 2 "THOMPSON")))((1 . "ALAN") (2 . "THOMPSON"))Command: (assoc 1 lst)(1 . "ALAN")Command: (subst (cons 2 "NAME") (assoc 2 lst) lst)((1 . "ALAN") (2 . "NAME"))
If I want to replace item A with B, I have to call it from the list first.
 
You're only calling the list once. The second parameter of subst is you extracting the item to replace from the list.
回复

使用道具 举报

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 11:18:39 | 显示全部楼层
 
 
 
 
Thanks again Alan
 
 
It sounds so straight forward the way you put it, I could not find a good example to explain it to me in a way that I could get my head around it.
 
 
 
Not to be greedy here but...
 
From my understanding so far...  If I want to get information about an element I have to use (entsel) & (entget) together.  Where (entsel) allows me to select the element and (entget) pull the information from the element. (DxF codes)
 
But (ssget) seems to work differently.
(ssget) seems to work as a selection/filter tool.  Where I have to provide (ssget) a dot list to work from.  So if I used (ssget "x") this would put all my drawing elements into a selection set.  But it seems I have to specify what I want to work with from the selection set, example: (0 . "Line") or (8 . 256)
 
I can't use this selection set on multiple object such as "line" & "circles", I have to choose one or the other.
 
 
Am I on the right track or is there more to ssget?
 
Thanks again
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:24:23 | 显示全部楼层
Use of subst outside of editing an entity list:
eg.
  1. Command: (setq lst (list "I'M" "SINGLE"))("I'M" "SINGLE")Command: (subst "MARRIED" "SINGLE" lst)("I'M" "MARRIED")
 
 
This will also come in handy: AutoLISP Reference
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 17:23 , Processed in 0.397102 second(s), 72 queries .

© 2020-2025 乐筑天下

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