乐筑天下

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

[编程交流] copy layer and sort, sometime

[复制链接]

11

主题

33

帖子

22

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 09:45:09 | 显示全部楼层 |阅读模式
this code is for detailing by layer name the layer must all open/show, user select the all layer and give the place point, my problem with this code is, the layer is not sort by number (my layer is 01 02 03 04 and so on) and sometime double copy with same layer name.  any solution pls  tq
  1. (defun dtr (a)   (* pi (/ a 180.0)) )(defun c:detlay    ()   (setq ppt1 (getpoint "\nPlace:"))(setq ssob (ssget))(setq ii 0)(setq dwqty 0)(while (setq obnum (cdr (assoc 8 (entget (ssname ssob ii)))))(setq lyr (tblsearch "LAYER" obnum)) (setq lnm (cdr (assoc 2 lyr))) (setq sellay (ssget "_X" (list (cons 8 obnum))))(command    "_copy" sellay "" (polar ppt1 (dtr 270.0) dwqty)"")(setq ii (1+ ii))(setq dwqty (+ dwqty 50))     )   )
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 09:49:23 | 显示全部楼层
First of all. wrap your code using the button -> #
(read Sticky Thread: posting guidelines)
 
as it stands now:
  1. (setq obnum (cdr (assoc 8 (entget (ssname ssob ii)))))
 
This will generate an error as this line will not issue a nil value for the while function.
 
better to use
  1.   (repeat (sslength ssob) (setq obnum....
 
This line is irrelevant
  1. (setq lyr (tblsearch "LAYER" obnum))(setq lnm (cdr (assoc 2 lyr)))
 
Also make it a point localize your variable
 
  1. (defun c:detlay (/ ppt1 ssob ii dwqty )
 
and since you're only going to use this oince
  1. (defun dtr (a) (* pi (/ a 180.0)) )
 

[code] (command "_copy" sellay "" (polar ppt1 (dtr 270.0) dwqty)"")
回复

使用道具 举报

11

主题

33

帖子

22

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 09:52:38 | 显示全部楼层
the code you re-create it's was no error but the result is still same
with my old code, the selected object copy repeated with same layer name
i dont want like that, what i want only 1 time copy and place it to new location
 
let say: i have 3 different layer all opened with same place (overlap)
i want to copy each layer to other place with distance (setq dwqty (+ dwqty 50)) each other
so user can see the object of layer without crossing object with all layer
 
 
 
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 09:55:29 | 显示全部楼层
 
Well. i suggest you look at it again  and i meant it to do the same thing as i dont know yet what you wanted in the first place
 
 
I see, so copy the layer to another location: 3 overlapping entities, different layers, make a copy of the 1st of 3 layers and place it at a given angle and distance after that the 2nd of 3 layers at the same angle and twice the distance as the 1st one, and so on. but limited only to the selected objects? is this correct?
回复

使用道具 举报

11

主题

33

帖子

22

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 09:58:11 | 显示全部楼层
selected by user only
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 10:01:56 | 显示全部楼层
 
okidoki,
to clarify, make a copy and not move? (sort of separate)
回复

使用道具 举报

11

主题

33

帖子

22

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 10:06:36 | 显示全部楼层
 
user will make selection of object than coding will separate the each layer and copy layer to other place input by user
and repeat next layer till the layer finish
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 10:09:01 | 显示全部楼层
 
 
Not sure if this is want you want
 
try this one for now
 
  1. (defun c:test(/ ppt1 ssob lys dwqty )(setvar 'cmdecho 0)  (setq ppt1 (getpoint "\nPlace:")) (setq ssob (ssget)) (setq dwqty 0)(mapcar(function (lambda (j / k)          (if (not              (member (setq k (cdr (assoc 8 (entget j)))) lys))             (setq lys (cons k lys)))            )) (vl-remove-if 'listp          (mapcar 'cadr (ssnamex ssob))) ) (foreach ln lys    (sssetfirst nil ssob)    (setq sellay (ssget "_p" (list (cons 8 ln))))     (command "_copy" sellay "" "" "_none" ppt1                 (polar ppt1 (* pi (/ 45 180.0)) (setq dwqty (+ 50 dwqty)))     )   ) )
 
I'm trying as much as possible not to deviate from your original code
回复

使用道具 举报

11

主题

33

帖子

22

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 10:12:13 | 显示全部楼层
got error!
 
  1. Point or option keyword required.; error: Function cancelledSpecify base point or displacement, or [Multiple]: *Cancel*
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 10:16:01 | 显示全部楼层
 
 
hmmmn wonder why.. thats the reason as much as possible i try to avoid using command functions
 
any other error message?
 
give me a minute, i think i'll just re-write everything..
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

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

© 2020-2025 乐筑天下

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