乐筑天下

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

[编程交流] 图像分离

[复制链接]

6

主题

26

帖子

20

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 14:53:25 | 显示全部楼层 |阅读模式
我偶尔会遇到一个。包含孤立或卸载图像文件的dwg。
 
我知道我可以做一个“-image”“d”“*”,但这意味着每个图像都会被分离。有人知道lisp或diesel例程只分离那些实际上没有加载到图形中的图像吗?
 
提前谢谢。
回复

使用道具 举报

6

主题

26

帖子

20

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 15:17:14 | 显示全部楼层
为了澄清:
 
我希望外部参照(如果有的话)不受影响。或者换句话说,只有未使用的图像文件被分离。
 
也许我只是没有把谚语中的点点滴滴联系起来,但我不知道该怎么做。
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 15:28:03 | 显示全部楼层
关于卸载的图像定义,我还没有找到一种方法来分离已卸载/未找到的图像定义,可能其他人可以提供帮助。
 
 
  1. (defun c:imgdet (/ im_dict im_ent im_lst wiz_cnt)
  2.    (vl-load-com)
  3.    (setq im_dict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
  4.    (setq wiz_cnt -1)
  5.    (setq im_lst '())
  6.    (while
  7.        (setq im_ent
  8.                 (nth
  9.                     (setq wiz_cnt (1+ wiz_cnt))
  10.                     im_dict
  11.                 ) ;_ {nth
  12.        ) ;_ {setq
  13.           (if (eq (car im_ent) 3)
  14.               (setq im_lst
  15.                        (cons
  16.                            (cons
  17.                                (cdr im_ent)
  18.                                (cdr
  19.                                    (nth
  20.                                        (setq wiz_cnt (+ wiz_cnt 1))
  21.                                        im_dict
  22.                                    ) ;_ {nth
  23.                                ) ;_ {cdr
  24.                            ) ;_ {cons
  25.                            im_lst
  26.                        ) ;_ {cons
  27.               ) ;_ {setq
  28.           ) ;_ {if
  29.    ) ;_ end_while
  30.    (mapcar
  31.        (function
  32.            (lambda (x)
  33.                (if (zerop (cdr (assoc 280 (entget (cdr x)))))
  34.                    (vla-delete (vlax-ename->vla-object (cdr x)))
  35.                ) ;_ {if
  36.            ) ;_ {lamda
  37.        ) ;_ {function
  38.        im_lst
  39.    ) ;_ {mapcar
  40.    (princ)
  41. ) ;_ {defun
回复

使用道具 举报

6

主题

26

帖子

20

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 15:40:19 | 显示全部楼层
谢谢你,威兹曼。
 
我试过了,它照你说的做了。当然,如果它能处理孤儿/未找到的人,那会很好吗。。。。即使这样也能帮上大忙。
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 15:41:35 | 显示全部楼层
请先彻底测试:
 
  1. ;|***********************---wiz24MAR09---**************************
  2. lisproutine for detaching not_found/unreferenced/orphaned/unloaded
  3. images,not yet tested on nested images|;
  4. (defun c:imgdet (/
  5.                 imgpath_lst
  6.                 img_dep
  7.                 img_info
  8.                 img_info340
  9.                 img_path
  10.                 img_set
  11.                 im_dict
  12.                 im_ent
  13.                 im_ent_1
  14.                 im_lst
  15.                 im_lst_1
  16.                 wiz_cnt
  17.                )
  18.    (vl-load-com)
  19. ;;;------------------------------------------------------------
  20.    ;;List all images which are present in the drawing in var = im_lst_1
  21.    (setq img_set (ssget "_x" '((0 . "IMAGE"))))
  22.    (setq i (sslength img_set))
  23.    (while (not (minusp (setq i (1- i))))
  24.        (setq im_ent_1 (ssname img_set i))
  25.        (setq img_info (entget im_ent_1))
  26.        (setq img_info340 (entget (cdr (assoc 340 img_info))))
  27.        (setq img_path (cdr (assoc 1 img_info340)))
  28.        (if (not (member img_path im_lst_1))
  29.            (setq im_lst_1 (cons img_path im_lst_1))
  30.        ) ;_ {if
  31.    ) ;_ {while
  32. ;;;------------------------------------------------------------  
  33.    ;;List all images saved in the file_dependencies in var = imgpath_lst
  34.    (setq imgpath_lst '())
  35.    (vlax-for
  36.             i
  37.              (setq img_dep
  38.                       (vla-get-FileDependencies
  39.                           (vla-get-ActiveDocument
  40.                               (vlax-get-Acad-Object)
  41.                           ) ;_ {vla-get-ActiveDocument
  42.                       ) ;_ {vla-get-FileDependencies
  43.              ) ;_ {vla-get-FileDependencies
  44.        (if (= (vla-get-Feature i) "Acad:Image")
  45.            (setq imgpath_lst
  46.                     (cons
  47.                         (vl-catch-all-apply
  48.                             (function
  49.                                 (lambda ()
  50.                                     (vla-get-FullFileName i)
  51.                                 ) ;_ {lambda
  52.                             ) ;_ {function
  53.                         ) ;_ {VL-CATCH-ALL-APPLY
  54.                         imgpath_lst
  55.                     ) ;_ {cons
  56.            ) ;_ {setq
  57.        ) ;_ {if
  58.    ) ;_ {vlax-for
  59.                    ;(vlax-release-object img_dep)
  60. ;;;------------------------------------------------------------  
  61.    ;;List all images saved in the image_dictionary in var im_lst
  62.    (setq im_dict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
  63.    (setq wiz_cnt -1)
  64.    (setq im_lst '())
  65.    (while
  66.        (setq im_ent
  67.                 (nth
  68.                     (setq wiz_cnt (1+ wiz_cnt))
  69.                     im_dict
  70.                 ) ;_ {nth
  71.        ) ;_ {setq
  72.           (if (eq (car im_ent) 3)
  73.               (setq im_lst ;_Image list to process below
  74.                        (cons
  75.                            (cons
  76.                                (cdr im_ent)
  77.                                (cdr
  78.                                    (nth
  79.                                        (setq wiz_cnt (+ wiz_cnt 1))
  80.                                        im_dict
  81.                                    ) ;_ {nth
  82.                                ) ;_ {cdr
  83.                            ) ;_ {cons
  84.                            im_lst
  85.                        ) ;_ {cons
  86.               ) ;_ {setq
  87.           ) ;_ {if
  88.    ) ;_ end_while
  89. ;;;------------------------------------------------------------  
  90.    ;;Begin Process
  91.    ;;Check if im_lst is present in im_lst_1 and imgpath_lst
  92.    ;;
  93.    (mapcar
  94.        (function
  95.            (lambda (x)
  96.                (if
  97.                    (or
  98.                        ;;If im_lst is not member of im_lst_1
  99.                        ;;then it is orphaned/unreferenced
  100.                        (not (member (cdr (assoc 1 (entget (cdr x)))) im_lst_1))
  101.                        ;;if im_list is not member of imgpath_lst
  102.                        ;;then it is not found
  103.                        (not (member (cdr (assoc 1 (entget (cdr x))))
  104.                                     imgpath_lst
  105.                             ) ;_ {member
  106.                        ) ;_ {not
  107.                        ;;if assoc 280 is 0 then it is unloaded
  108.                        (zerop (cdr (assoc 280 (entget (cdr x)))))
  109.                    ) ;_ {or
  110.                       (vl-catch-all-apply
  111.                           (function
  112.                               (lambda ()
  113.                                   (vla-delete (vlax-ename->vla-object (cdr x)))
  114.                               ) ;_ {lambda
  115.                           ) ;_ {function
  116.                       ) ;_ {vl-catch-all-apply
  117.                ) ;_ {if
  118.            ) ;_ {lamda
  119.        ) ;_ {function
  120.        im_lst
  121.    ) ;_ {mapcar
  122.    (princ)
  123. ) ;_ {defun
回复

使用道具 举报

6

主题

26

帖子

20

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 16:00:18 | 显示全部楼层
对其进行的第一次测试表明,在某些情况下,“加载”的图片也会被转储,但前提是该图片未显示且未被使用。
 
换句话说,它实际上只留下可使用和可查看的图像。
好极了
 
看起来确实很有前途。我会更彻底地测试,如果我发现任何问题,会给你回复。
 
再次感谢你。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 22:04 , Processed in 0.504497 second(s), 64 queries .

© 2020-2025 乐筑天下

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