Author Topic: Trying to swap images  (Read 1138 times)

0 Members and 1 Guest are viewing this topic.

cadman6735

  • Guest
Trying to swap images
« on: March 20, 2015, 05:04:58 PM »
I have a some logos that I am trying to repath, Rename and make relative.  It is suppose to look thru all the images for a desired name and the swap it for a another image with a different name and rename the image and make relative, I got 2 out of the 3 to work but when it comes to changing the name it changes the last image in the list, I thought my "IF" statement would have captured it and done all three to the correct image but it is not and driving me crazy to figure out.  Any assistance would be wonderful, thanks

Code: [Select]
(defun c:test ( / );|el newpath oldName)|;  (vl-load-com)

  (setq ActiveDocument (vla-get-ActiveDocument (vlax-get-acad-object)))

;-----------------------------------------------------------------------------------------

    (vla-StartUndoMark ActiveDocument) ;Start of UNDO

;-----------------------------------------------------------------------------------------
  (setq newPath "D:\\Beer\\New folder\\Logo.png"
Name "*Stout*"
newName "Logo"
relPath "Logo.png"
  )


  (foreach imagedef (mapcar 'cdr
    (vl-remove-if-not
      '(lambda (x) (= (car x) 350))
      (dictsearch (namedobjdict) "acad_image_dict")
    )
    )
   
    (setq el (entget imagedef))
(if  (wcmatch (cdr (assoc 1 el)) Name)
   (progn
     (entmod (setq el (subst (cons 1 newPath) (assoc 1 el) el))); set path
     (entmod (setq el (subst (cons 1 relPath) (assoc 1 el) el))); set relative path
     (setq x (entget (cdr (assoc 330 el)))); enter dictionary
     (entmod (subst (cons 3 newName) (assoc 3 x) x)); & change name
     
   
   )
)
  )
 
  (command "-image" "reload" "*")
 
;-----------------------------------------------------------------------------------------

    (vla-EndUndoMark ActiveDocument) ;End of UNDO

;-----------------------------------------------------------------------------------------
 
(princ)
)

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Trying to swap images
« Reply #1 on: March 20, 2015, 05:51:48 PM »
You can't rename 3 different images with the same names... Names should be different for each different image...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

cadman6735

  • Guest
Re: Trying to swap images
« Reply #2 on: March 20, 2015, 05:53:49 PM »
I know, I am trying to isolate only one image with the "IF" statement, I don't know why this does not work.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Trying to swap images
« Reply #3 on: March 21, 2015, 12:06:50 AM »
Maybe it's a string case issue with your wcmatch ?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadman6735

  • Guest
Re: Trying to swap images
« Reply #4 on: March 23, 2015, 10:16:11 AM »
thanks for the replies,

I ran this macro this morning and it worked, I noticed my images where all jacked up from me trying and trying and retrying that once I put it back to a normal state it ran just fine.

Thanks again