乐筑天下

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

[编程交流] 为每个层生成dwg

[复制链接]

44

主题

139

帖子

95

银币

后起之秀

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

铜币
221
发表于 2022-7-5 15:17:11 | 显示全部楼层 |阅读模式
你好,你能帮我修复这个代码吗?它工作不太好。。。
 
我有一个5层的源dwg,我想用“BORDO”和其中一个生成4个dwg。
例子:
1.BORDO+ARMAT\u INF\u DIR\u X
2.BORDO+ARMAT\u INF\u DIR\u Y
3.BORDO+ARMAT\u SUP\u DIR\u X
4.BORDO+ARMAT\u SUP\u DIR\u Y
 
这是代码:
  1. (defun c:test    (/ continue first name next_lay lay_name objects bordo)
  2. (setq    continue t
  3.    first     t
  4.    name     (getvar "dwgname")
  5.    name     (substr name 1 (- (strlen name) 4))
  6.    name     (strcat (getvar "dwgprefix") name)
  7. )
  8. (setq bordo (ssget "X" (list (cons 8 "BORDO"))))
  9. (while continue
  10.    (setq next_lay (tblnext "LAYER" first)
  11.      first       nil
  12.      objects nil
  13.    )
  14.    (setq lay_name (cdr (assoc 2 next_lay)))
  15.    
  16.    (if    (not next_lay)
  17.      (setq continue nil)
  18.      (progn
  19.    (setq objects (ssget "X" (list (cons 8 lay_name))))
  20.    (if (and objects (/= lay_name "BORDO"))
  21.      (progn
  22.        (setq lay_name (cdr (assoc 2 next_lay)))
  23.        (setq objects (ssgetunion objects bordo))
  24.        (command "-wblock")
  25.        (command (strcat name "_" lay_name))
  26.        (command "" (list 0 0 0))
  27.        (command objects "")
  28.        (command "oops")
  29.      )
  30.      
  31.    )
  32.      )
  33.    )
  34. )
  35. (princ)
  36. )
  37. (defun ssgetunion (sel2 sel1 /)
  38. (if sel1
  39.    (if sel2
  40.      (progn
  41.        (setq ct 0)
  42.        (repeat (sslength sel2)
  43.          (ssadd (ssname sel2 ct) sel1)
  44.          (setq ct (1+ ct))
  45.        )
  46.      )
  47.      sel1
  48.    )
  49.    (princ "\nNIL.")
  50. )
  51. sel1
  52. )

 
看起来最后一个文件包含所有层。我每个周期都将对象设置为“nil”,所以我不理解原因。。。
 
非常感谢。
丹尼斯
 
臂图纸
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 15:25:23 | 显示全部楼层
考虑以下代码:
我已经在谷歌上搜索了这个函数”(vla wblock.)但我什么也没找到。
 
谢谢
回复

使用道具 举报

44

主题

139

帖子

95

银币

后起之秀

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

铜币
221
发表于 2022-7-5 15:39:31 | 显示全部楼层
 
是-更改:
  1. 2
至:
如果愿意,请删除LM:uniquefilename函数的函数定义,因为它不再使用。
 
 
我可能错了,但我不确定在不以新格式保存图形的情况下是否可以实现这一点。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 15:40:33 | 显示全部楼层
回复

使用道具 举报

44

主题

139

帖子

95

银币

后起之秀

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

铜币
221
发表于 2022-7-5 15:48:52 | 显示全部楼层
 
Oh nice  you're very kind!
 
If I had your skills I would work half a day ahah
 
Thank you again, see you soon )
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 15:55:10 | 显示全部楼层
 
But you would code on the other half...
 
And GJ Lee!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:05:07 | 显示全部楼层
Thanks!
回复

使用道具 举报

44

主题

139

帖子

95

银币

后起之秀

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

铜币
221
发表于 2022-7-5 16:17:07 | 显示全部楼层
 
ahah indeed!!
 
May I ask something else?
 
I'm looking at the code  and I have few questions..
1) Is it possible to overwrite the file instead of generate another with a different name with this function "LM:uniquefilename"?
 
2) Is it possible to change the file format output of write block to, for example, autocad 2009?
  1. (vla-wblock doc (LM:uniquefilename (strcat dwg "_" (vla-get-name lay) ".dwg")) sso)
I've googled for this function "(vla-wblock .." but I dind't find anything.
 
Thanks
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:19:56 | 显示全部楼层
 
Yes - change:
  1. (vla-wblock doc (LM:uniquefilename (strcat dwg "_" (vla-get-name lay) ".dwg")) sso)
To:
  1. (vla-wblock doc (strcat dwg "_" (vla-get-name lay) ".dwg") sso)
And remove the function definition for my LM:uniquefilename function if you wish, as this is no longer used.
 
 
I may be wrong, but I'm not sure that this is possible to achieve without subsequently saving the drawing in a new format.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 13:04 , Processed in 1.372062 second(s), 71 queries .

© 2020-2025 乐筑天下

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