MarkytheSparky 发表于 2022-7-5 17:52:29

更改I的引用名称

简化:
 
制作任何类型的autocad dwg文件。
将图像外部参照到in(jpg)
 
图像将有一些与其相关的路径(C:\temp\Daryl.JPG)
 
它还将有一个“参考名称”(myjunkyname)
 
如何将引用名称更改为图像的名称,减去。JPG公司

MarkytheSparky 发表于 2022-7-5 18:08:09

不过,我仍然无法使用Lisp或VB识别和更改图像的引用名称。请-如果有人知道,我真的需要帮助。

MarkytheSparky 发表于 2022-7-5 18:12:00

无论如何,是否需要修改此代码,使其能够查找带有通配符的名称?
我发现有三个公司徽标作为图像加载到我的DWG中。
 
 
有一个前缀和一个后缀的垃圾字符与公司标志名称在中间
 
 
123abcTACOLOGO456def。jpg公司
 
 
(高亮显示的红色部分是我想要更改引用名称的全部内容)

SLW210 发表于 2022-7-5 18:18:35

不要在其他帖子上问你的问题。

Lee Mac 发表于 2022-7-5 18:28:15

请尝试以下操作:
(defun c:renameallimages ( / dic img itm lst )
   (if (setq lst (dictsearch (namedobjdict) "acad_image_dict")
             dic (cdr (assoc -1 lst))
       )
       (while (setq lst (member (assoc 3 lst) lst))
         (setq itm (cdr (assoc 3 lst))
               img (vl-filename-base (cdr (assoc 1 (entget (cdr (assoc 350 lst))))))
               lst (cdr lst)
         )
         (if (not (or (= img itm) (dictsearch dic img)))
               (dictrename dic itm img)
         )
       )
   )
   (princ)
)
运行上述命令后,您需要“重新加载所有引用”。

MarkytheSparky 发表于 2022-7-5 18:41:33

李-成功了!非常感谢。现在,我将花一些时间自学所有步骤的功能(学习词汇和快速眼动)。你刚刚救了我多年的腕管疼痛。

Lee Mac 发表于 2022-7-5 18:44:48

好东西Mark-如果您对代码有任何问题,请随时提问。

Jef! 发表于 2022-7-5 18:54:02

大家好!
 
我星期五做了一个代码,我没有立即在图像dict中看到多个assoc的可能性(顺便说一句,在你的代码中这是一个非常聪明的方法)。我刚回来看到李把我带到终点线。
 
考虑到用户可能不希望系统地将所有图片重命名为其文件名,并提示用户选择需要恢复参考名称的图像,我采取了一种稍微不同的方法。我本可以使用更少的变量和代码行,但选择了更好的可读性。
 
用法:启动,选择屏幕上的图像(加载或卸载),参考名称将恢复。图像的加载/卸载状态不会改变,不需要“手动”重新加载。
 
(defun c:RES ( / img_enam img_entdesc img_hardrefEname image_hardref image_path image_dict img_newiname newiname_dxf newimage_dict)
;Restore image reference name by the name of the source image file (found at, without path/extension)
;made by Jef! on 2016 March 29.
(setvar 'errno 0)
(while (not (and (setq img_enam (car(entsel "\nSelect the image to restore path: ")))
           (eq "IMAGE" (cdr (assoc 0 (entget img_enam))))
             )
)
(cond
         (   (= 52 (getvar 'errno))
               (princ "\nYou must select an image object. Press \"ESCAPE\" to cancel")
      (setvar 'errno 0)
         )          
         (   (null img_enam)
               (princ "\nYou missed, try again.")
         )
    (   (not (eq "IMAGE" (cdr (assoc 0 img_entdesc))))
      (princ "\nYou must select an image object.")
    )
      )
)
(setq img_entdesc   (entget img_enam)
img_hardrefEname (cdr (assoc 340 img_entdesc))
       image_hardref (entget img_hardrefEname)
image_path    (cdr (assoc 1 image_hardref))
image_dict    (entget (cdr (assoc 330 image_hardref)))
img_newiname(substr image_path
                      (+ 2 (vl-string-position 92 image_path 0 t))
                      (- (vl-string-position 46 image_path 0 t)
                       (vl-string-position 92 image_path 0 t)
                       1
                      )
              )
newiname_dxf(cons 3 img_newiname)
newimage_dict (subst newiname_dxf (nth 1 (member (cons 350 img_hardrefEname) (reverse image_dict))) image_dict);massoc!!
)
(entmod newimage_dict)
(entmod image_hardref)
(princ)
)
页: [1]
查看完整版本: 更改I的引用名称