TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cadman6735 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
(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)
)
-
You can't rename 3 different images with the same names... Names should be different for each different image...
-
I know, I am trying to isolate only one image with the "IF" statement, I don't know why this does not work.
-
Maybe it's a string case issue with your wcmatch ?
-
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