Jump to content

Renaming XREF TIFF Reference Name


Steven P

Recommended Posts

Good evening,

 

This has intrigued me today but I haven't found out how to make it work....

I often use Raster files / Tiffs attached as xrefs. The 3rd party software loads them into the drawing and when you look at the details in the xref manager they have a reference name something like "Software_Ref1" for example, we then manually rename this to the actual file name "tiff123"... so is there a LISP out there that will take rename the reference name to the tiff file name? Hop that makes sense.

 

I would be adding this to a routine that adds the TIFFs and sets them up, so it can either loop through all the attached LIPS or use something like entget and entlast after each TIFF has been added

 

Thanks for any pointers

Link to comment
Share on other sites

had this code on my computy , must have used it at some time (just forgotten for what , for who or when 🤔)


(defun c:fip (/ ss img i newname)
  (setq    newname
        "D:\\xx\\Tif recht\\R-0406877 Main distrubution frame MDF-B01-B10\\"
    ss    (ssget "x" (list (cons 0 "image")))
    i    0
  )
  (if ss
    (progn
      (while (ssname ss i)
    (setq img (entget (cdr (assoc 340 (entget (ssname ss i))))))
    (setq img
           (subst (cons 1
                (strcat newname
                    (vl-filename-base (cdr (assoc 1 img)))
                    ".tif"
                )
              )
              (assoc 1 img)
              img
           )
    )
    (entmod img)
    ;;;(entupd img)
    (setq i (1+ i))
      )
    )
  )
)

;;;image select : (setq a (entget (car (entsel))))
;;;image path   : (setq b (entget (cdr (assoc 340 a)))) -> assoc 1 b
;;;image name  : (setq c (entget (cdr (assoc 330 b)))) -> assoc 3 c


fip probably means fix image path

 

and if you prefer vla-


(VLA-GET-NAME (vlax-ename->vla-object (CAR (ENTSEL))));returns name
(VLA-GET-imagefile (vlax-ename->vla-object (CAR (ENTSEL))));returns path

just change vla-get to vla-put

 

 

Edited by rlx
Link to comment
Share on other sites

Thanks RLX

 

Your code will be useful - as it is it updates the saved file path for the TIFF files, which is something we have to do every now and again.. not quite what I was after at the moment - but thanks for remembering you had this, like i say, I'll probably use it in the future

 

I'll look properly later though - might be a clue in there for me

Link to comment
Share on other sites

code above is valid for name and path but here example for name change. Select an image and name is changed to StevenP. Note that external reference dialog wil not show change right after but if you use -image + ? + * you'll see name is updated.


(defun c:t1 ( / im iname ipath)
  (if (setq im (vlax-ename->vla-object (CAR (ENTSEL))))
    (progn
      (setq iname (vla-get-name im))
      (setq ipath (vla-get-imagefile im))
      (princ (strcat "\nImage name : " iname))
      (princ (strcat "\nImage path : " ipath))
      (vla-put-name im "StevenP")
      (setq iname (vla-get-name im))
      (princ (strcat "\nImage name : " iname))
      (princ (strcat "\nImage path : " ipath))
    )
  )
)

  • Like 1
Link to comment
Share on other sites

2 minutes ago, Steven P said:

Thanks RLX that looks like it works.. going to try to break it now just to check of course

 

of course you will , I wouldn't have it any other way :twisted:

Link to comment
Share on other sites

You frustrate me... nearly 24 hours later and it's still working and not broken yet. Thanks.

 

I save the drawing after your routine and that updates the change in the external reference dialog.

  • Funny 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...