乐筑天下

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

[编程交流] XIMPORT dosen't see block

[复制链接]

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 19:44:34 | 显示全部楼层 |阅读模式
I am trying to write a lisp routine that would import blocks from another drawing by attaching the drawing as an xref, xbinding the selected blocks and detaching the xref. When I run the lisp, it says that the drawing file I type in is already attached as xref or has no blocks (both of which are not true). Any idea what's wrong? Below is the code. (tried to wrap code in tags, but no matter how often I highlight the code and hit the tag button it doesn't show. Sorry)
 
 
 
 
(defun C:XIMPORT ( / fname blname toggle nlist index blist)
  (setq fname (ustr 1 "Enter filename to extract block from" nil nil))
  (while (tblnext "block"))
  (command "xref" "a" fname nil)
  (tblnext "block")
  (while (setq blname (tblnext "block"))
    (setq blist (append (list (dxf 2 blname)) blist))
  )
  (if blist
    (progn
      (textpage)
      (setq index -1)
      (while (setq index (1+ index) blname (nth index blist))
        (setq toggle (not toggle))
          (prompt
            (strcat (if toggle "\n " "\t\t") (itoa (1+ index)) " " blname)
      ) );while&prompt
      (while (setq index
                (getint
                  "\nEnter block number to import or Enter to exit : "
        )         )
        (setq blname (nth (1- index) blist))
        (setq nlist (append (list (nth (1- index) blist)) nlist))
     );while
     (foreach blname nlist (command "xbind" "b" blname))
     (command "xref" "d"
       (progn (textpage)
(prompt "\n\nItems listed as Not Detached show assigned names of imported blocks:\n\n")
          fname
      ) )
    );progn then
    (prompt (strcat "\n" fname " already attached as xref or has no blocks."))
  );if blist
  (princ)
);defun C:XIMPORT
回复

使用道具 举报

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 19:56:26 | 显示全部楼层
I forgot to post a subroutine I have built into this lisp. It is as follows:
 
 
;* USTR: User interface string
;* If BIT=1 no null "" input allowed, 0 for none, BIT ignored if DEF present.
;* MSG is the prompt string, to which a default string is added as  (nil
;*  or "" is for none), and a : is added. If SPFLAG T, spaces are allowed in string.
 
(defun ustr (bit msg def spflag / inp nval)
   (if (and def (/= def ""))
       (setq msg (strcat "\n" msg ": ")
               inp (getstring spflag msg)
               inp (if (= inp "") def inp)
       );setq
       (progn
         (if (= " " (substr msg (strlen msg) 1))
             (setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": "))
             (setq msg (strcat "\n" msg ": " ))
    );if
    (if (= bit 1)
        (while (= "" (setq inp (getstring spflag msg)))
          (prompt "\nInvalid string.")
        )
        (setq inp (getstring spflag msg))
        ) );progn&if
    );if
    inp
);defun
;*
 
 
Again, any help would be appreciated.
回复

使用道具 举报

7

主题

80

帖子

73

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 20:09:27 | 显示全部楼层
 
can you upload the drawing for us my friend?
回复

使用道具 举报

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 20:18:15 | 显示全部楼层
I apologize, but I don't know how to post a dwg. to this site. Could you point me to a how to or explain it. Still really new here.
回复

使用道具 举报

7

主题

80

帖子

73

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 20:25:38 | 显示全部楼层
just replay via the "Go Advanced" Button, then you can find the "Manage Attachments" button there
回复

使用道具 举报

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 20:32:49 | 显示全部楼层
Ok, let me know if this didn't work.
TEST.dwg
回复

使用道具 举报

7

主题

80

帖子

73

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 20:36:08 | 显示全部楼层
now I see, paperspace objects cant be imported to a drawings thru xref.
you may try putting those objects to Model space and rety your routine.
回复

使用道具 举报

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 20:46:17 | 显示全部楼层
I copied the blocks into the model space and tried again, but got the same error. I attached the new dwg. into this post. Any other ideas?
TEST.dwg
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 01:19 , Processed in 1.586051 second(s), 68 queries .

© 2020-2025 乐筑天下

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