Author Topic: repathing  (Read 9001 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: repathing
« Reply #15 on: January 27, 2009, 04:22:09 PM »
You're welcome Deegs.  Could you post one of the drawings?  No need for the images, I just want to see if I can get them to repath with the code, as it was working here.

You can do this type of thing with ObjectDBX, so you could run through a folder pretty quickly.  Could be done in any language your comfortable with also.

I'm glad you got something, but you shouldn't have to resort to ' command ' calls.   :wink:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: repathing
« Reply #16 on: January 27, 2009, 04:31:32 PM »
You're welcome Deegs.  Could you post one of the drawings?  No need for the images, I just want to see if I can get them to repath with the code, as it was working here.

I would, but there's way too much proprietary info on them. I was getting an error saying that the file couldn't be accessed, could be that it wasn't released from the first run through...

You can do this type of thing with ObjectDBX, so you could run through a folder pretty quickly.  Could be done in any language your comfortable with also.

Yes, I have some ODBX code for VBA, but it's been quite a few years since I've dived into coding, and I needed something quick. <---------Boilerplate Disclaimer

I'm glad you got something, but you shouldn't have to resort to ' command ' calls.   :wink:

Hehe, I'm just a hack.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: repathing
« Reply #17 on: January 27, 2009, 04:41:55 PM »
Cool.  I understand.  Next time try this little diddy.  I made the variables local, and have it print the old path and the new path per image file, so that you can see if it does change it or not.

Code: [Select]
(defun c:im_upd2 (/ new_path img_file_name)

    (setq new_path (GETVAR "DWGPREFIX"))

    (vlax-for i (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
        (if (= (vla-get-Name i) "00")
            (vlax-for item (vla-get-Block i)
                (if
                    (and
                        (= (vla-get-objectname item) "AcDbRasterImage")
                        (vlax-property-available-p item 'ImageFile)
                    )
                    (progn
                        (setq img_file_name
                            (strcat
                                (vl-filename-base (vla-get-ImageFile item))
                                (vl-filename-extension (vla-get-ImageFile item))
                            )
                        )
                        (print (vla-get-ImageFile item))
                        (vla-put-imagefile
                            item
                            (strcat new_path img_file_name)
                        )
                        (print (vla-get-ImageFile item))
                    )
                )
            )
        )
    )
    (princ)
);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;defun---End Prog
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: repathing
« Reply #18 on: January 27, 2009, 04:44:45 PM »
Quote
error: Automation Error. File access error
   :?

I'm using 04 btw...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: repathing
« Reply #19 on: January 27, 2009, 04:46:40 PM »
Quote
error: Automation Error. File access error
   :?

I'm using 04 btw...
Post the whole error message with this one.
Code: [Select]
(defun c:im_upd2 (/ new_path img_file_name *error*)

    (defun *error* (msg) (vl-bt))
   
    (setq new_path (GETVAR "DWGPREFIX"))

    (vlax-for i (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
        (if (= (vla-get-Name i) "00")
            (vlax-for item (vla-get-Block i)
                (if
                    (and
                        (= (vla-get-objectname item) "AcDbRasterImage")
                        (vlax-property-available-p item 'ImageFile)
                    )
                    (progn
                        (setq img_file_name
                            (strcat
                                (vl-filename-base (vla-get-ImageFile item))
                                (vl-filename-extension (vla-get-ImageFile item))
                            )
                        )
                        (print (vla-get-ImageFile item))
                        (vla-put-imagefile
                            item
                            (strcat new_path img_file_name)
                        )
                        (print (vla-get-ImageFile item))
                    )
                )
            )
        )
    )
    (princ)
);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;defun---End Prog

Don't think that should be an issue with this.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: repathing
« Reply #20 on: January 27, 2009, 04:59:32 PM »
It was erroring from an image file that has a different path altogether, once I detached it all is well. I'll have to add an exclusion for that image, as it's a part of our title blocks, and add something for missing files as well for this to work in variable situations.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: repathing
« Reply #21 on: January 27, 2009, 05:10:55 PM »
It may not work if there is no file at the new path, so you can just check to see if the new path exist, ' findfile ', and if so, then repath it.  If not, print it to the command line that the new path was not found... yada yada yada.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: repathing
« Reply #22 on: January 27, 2009, 05:13:11 PM »
Yes sir, I'll post the code when I get it to work "Correctly".

VVA

  • Newt
  • Posts: 166
Re: repathing
« Reply #23 on: January 28, 2009, 02:26:02 AM »