Author Topic: help to change raster image name  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

cadman6735

  • Guest
help to change raster image name
« on: June 12, 2014, 12:32:39 PM »
How can I change the name of the image?

Code: [Select]
(defun c:test ( / )(vl-load-com)
 
  (setq ActiveDocument (vla-get-activedocument (vlax-get-acad-object))) 

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

    (vla-StartUndoMark ActiveDocument) ;Start of UNDO

;-----------------------------------------------------------------------------------------
 
  (setq *imageObj (vlax-ename->vla-object (cdr (car (entget (car (entsel)))))))

  (setq *imagePath (strcase (vla-get-imageFile *imageObj)))

  (setq *imageString (strcase "*tpf*"))

  (setq *imageName "CorpLogo")

  (if (wcmatch *imagePATH *imageString)
    (progn
      (vla-put-imagefile *imageObj "C:\\AutoDesk\\CAE_Custom\\AutoCAD\\Support\\Icons\\CorpLogo.png")
      (vla-put-name *imageObj *imageName)
    )
  )
 
  (vla-regen ActiveDocument acAllViewports)

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

    (vla-EndUndoMark ActiveDocument) ;End of UNDO

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

(princ)
)

I can change the image fine but it keeps the old name, I need to update the name too...

thanks

ronjonp

  • Needs a day job
  • Posts: 7533
Re: help to change raster image name
« Reply #1 on: June 12, 2014, 12:41:59 PM »
I just tested and the name is changed here using vla-put-name. It did not update in the reference manager until I reopened the drawing though. If you want to see it changed without closing out of the drawing, use the CLASSICIMAGE command.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadman6735

  • Guest
Re: help to change raster image name
« Reply #2 on: June 12, 2014, 12:59:01 PM »
Thanks RonJon,

I just need to reload the image reference for it to update the name...


Code: [Select]
  (if (wcmatch *imagePATH *imageString)
    (progn
      (vla-put-imagefile *imageObj "C:\\AutoDesk\\CAE_Custom\\AutoCAD\\Support\\Icons\\CorpLogo.png")
      (vla-put-name *imageObj *imageName)
      (command "-image" "reload" *imageName)
    )
  )