ObjectDBX and saving.

ObjectDBX and saving.

Anonymous
Not applicable
460 Views
21 Replies
Message 1 of 22

ObjectDBX and saving.

Anonymous
Not applicable
Hi all, and help!
I am trying to save a document after having altered the path
of an attached image file, using ObjectDBX.
Everything is smooth until it comes time to save and close.
The path is indeed being altered but I'm having a hard time
grasping what kind of argument the save method wants.
Since the documentation is "VBA and ActiveX centric",
I'm hearing Twighlight Zone, and X-files theme music
as I try to apply it.
The sticking point is at ***, at the bottom of
the hastily written fragment below. Any help would
sure be appreciated.

(defun process (pathhandname)
(setq dbxdoc
(vla-GetInterfaceObject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
(vla-open dbxdoc pathhandname)
(setq mdl (vla-get-modelspace dbxdoc))
(setq lis nil)
(vlax-for thing mdl (setq lis (cons thing lis)))
(setq ilis nil)
(foreach obj lis (if (= "AcDbRasterImage" (vla-get-objectname
obj))(setq ilis (cons obj ilis))))
(setq k 0 )
(while (< k (length ilis))
(setq imagefile (vla-get-imagefile (nth k ilis))
pieces (parse "\\" imagefile)
newimagefile (strcat newpath (last pieces))
)
(vla-put-imagefile (nth k ilis) newimagefile)
(setq k (1+ k))
);
(vla-save dbxdoc);*** what do we want here?
(vla-close dbxdoc);*** or, what kind of argument am I supposed to
supply?
(vlax-release-object dbxdoc)
)
0 Likes
461 Views
21 Replies
Replies (21)
Message 21 of 22

Anonymous
Not applicable
Tom,

I was able to get the following code to work without fail.

Note: I changed (setq mdl (vlax-get-property dbxdoc 'modelspace))
to
(setq mdl (vlax-get-property dbxdoc 'paperspace))
because I was using a drawing with nothing in model space.

(defun process (pathhandname)
(setq dbxdoc (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject
"ObjectDBX.AxDbDocument"))
(vlax-invoke-method dbxdoc 'open pathhandname)
(setq mdl (vlax-get-property dbxdoc 'paperspace))
(setq lis nil)
(vlax-for thing mdl (setq lis (cons thing lis)))
(setq ilis nil)
(princ lis)
(foreach obj lis
(if (= "AcDbRasterImage" (vlax-get-property obj 'objectname))
(setq ilis (cons obj ilis))
(princ obj)
);if
);foreach
(setq k 0 )
(while (< k (length ilis))
(setq imagefile (vlax-get-property (nth k ilis) 'imagefile)
pieces (parse "\\" imagefile)
newimagefile (strcat *newpath* (last pieces))
);setq
(vlax-put-property (nth k ilis) 'imagefile newimagefile)
(setq k (1+ k))
);while
;;;;;;;;;;;;;;;;;;;;;;;;I removed the stuff that edits the drawing file.
(vlax-invoke-method dbxdoc 'saveas pathhandname)
;;;;;;;;;;;;;;;;;;;;;;;;Here I used saveas with the original path.
(vlax-release-object dbxdoc)
);defun

(process (findfile "template1.dwg"))
0 Likes
Message 22 of 22

Anonymous
Not applicable
James,
Thanks! Saveas overwrote old file for me as well.
Save. Who needs it?

Tony,
Commented out

(vlax-put-property (nth k ilis) 'imagefile newimagefile)

and received no error.

On Wed, 30 Aug 2000 03:05:55 +0000, "CADDee.com"
wrote:

>Tom,
>
>I was able to get the following code to work without fail.
>
>Note: I changed (setq mdl (vlax-get-property dbxdoc 'modelspace))
>to
>(setq mdl (vlax-get-property dbxdoc 'paperspace))
>because I was using a drawing with nothing in model space.
>
>(defun process (pathhandname)
> (setq dbxdoc (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject
>"ObjectDBX.AxDbDocument"))
> (vlax-invoke-method dbxdoc 'open pathhandname)
> (setq mdl (vlax-get-property dbxdoc 'paperspace))
> (setq lis nil)
> (vlax-for thing mdl (setq lis (cons thing lis)))
> (setq ilis nil)
> (princ lis)
> (foreach obj lis
> (if (= "AcDbRasterImage" (vlax-get-property obj 'objectname))
> (setq ilis (cons obj ilis))
> (princ obj)
> );if
> );foreach
> (setq k 0 )
> (while (< k (length ilis))
> (setq imagefile (vlax-get-property (nth k ilis) 'imagefile)
> pieces (parse "\\" imagefile)
> newimagefile (strcat *newpath* (last pieces))
> );setq
> (vlax-put-property (nth k ilis) 'imagefile newimagefile)
> (setq k (1+ k))
> );while
> ;;;;;;;;;;;;;;;;;;;;;;;;I removed the stuff that edits the drawing file.
> (vlax-invoke-method dbxdoc 'saveas pathhandname)
>;;;;;;;;;;;;;;;;;;;;;;;;Here I used saveas with the original path.
> (vlax-release-object dbxdoc)
>);defun
>
>(process (findfile "template1.dwg"))
>
0 Likes