Steven P Posted June 5, 2020 Posted June 5, 2020 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 Quote
rlx Posted June 5, 2020 Posted June 5, 2020 (edited) 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 June 5, 2020 by rlx Quote
Steven P Posted June 5, 2020 Author Posted June 5, 2020 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 Quote
rlx Posted June 5, 2020 Posted June 5, 2020 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)) ) ) ) 1 Quote
Steven P Posted June 6, 2020 Author Posted June 6, 2020 Thanks RLX, I'll give it a go later when The Boys are in their beds Quote
Steven P Posted June 8, 2020 Author Posted June 8, 2020 Thanks RLX that looks like it works.. going to try to break it now just to check of course Quote
rlx Posted June 8, 2020 Posted June 8, 2020 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 Quote
Steven P Posted June 9, 2020 Author Posted June 9, 2020 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. 1 Quote
Recommended Posts
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.