PDA

View Full Version : Saving in ObjectDBX



whdjr
2004-07-28, 02:27 PM
I am having trouble changing a text object and then saving it in a file using ObjectDBX. Can someone shed any light on this for me. It seems to open and close the file properly because it losses the file preview, but it doesn't maintain the change to the text object.

I am working in ADT2005 on XP Pro.

Someone please help,

msretenovic
2004-07-28, 02:43 PM
Try using (vla-saveas dbxDoc dwgName nil). I've been using this and it works well :-D .


dbxDoc is the open drawing.
dwgName is the name and path to save it to.
the last argument will let you specify which file format to use (though I'm having a little trouble with it in 2004 :( ).

HTH,

whdjr
2004-07-28, 03:12 PM
Mike,

Opening and closing I get right, and even deleting objects, but getting it to keep changes to a text object is different.

I'm missing something.

Ed Jobe
2004-07-28, 03:34 PM
The Save method is broken in ObjectDbx, it doesn't work. You have to use SaveAs. Unless there's something wrong with your code that modifies the text. Maybe you need to show it.

whdjr
2004-07-28, 03:53 PM
Saveas works for me. It's just the code the changes the text object that is messed up.

txtobj = Object for the text item
news = new text string
olds = old text string

(defun fandr (txtobj)
(vl-string-subst news olds (vla-get-textstring txtobj))
)

thanks,

matt.worland
2004-07-28, 04:27 PM
Could it be that your two strings are different cases?

whdjr
2004-07-28, 06:01 PM
no the strings are the same case. I used a test drawing with strings that I set up with different cases to see which would work. When I step thru the code it shows the string changing, but for some reason never gets saved back to the dwg. Could it be as simple as saving to a variable.

msretenovic
2004-07-28, 06:07 PM
Are you using a vla-put-string anywhere :idea:. Because vl-string-subst will only replace the pattern but will not place it in the text object.

(setq string (vla-get-textString txtObj))
(setq string (vl-string-substr news olds string))
(vla-put-textString txtObj)

Where txtObj is your text object.

HTH

whdjr
2004-07-28, 06:13 PM
dddduuuuuuhhhhhhhhhhh!!!!!!!!!!!!!!!!!

Thanks Mike. Sometimes I feel like a total idiot.
It works now. Imagine that.

RobertB
2004-07-28, 06:18 PM
Try using (vla-saveas dbxDoc dwgName nil). I've been using this and it works well.

dbxDoc is the open drawing.
dwgName is the name and path to save it to.
the last argument will let you specify which file format to use (though I'm having a little trouble with it in 2004

Warning! Using (vla-SaveAs) is not the same as using the ObjectDBX version of SaveAs. See this post. (http://forums.augi.com/showthread.php?t=6295)

whdjr
2004-07-28, 06:38 PM
What is the preferred method?

(vlax-invoke-method dbxdoc 'saveas filename)

RobertB
2004-07-28, 07:01 PM
(vlax-invoke-method dbxdoc 'saveas filename)

That is a good way to approach it.

I may have mispoken on the (vla-SaveAs) approach too. Mike, please try the above code in your situation, and provide the bogus argument for filetype. Does the C05 occur? Or do you get an invalid argument? It may be an issue with the ActiveX interface.

I did a (vlax-dump-object dbxdoc T) and notice that the SaveAs method for a DBXDoc only accepts two arguments:
; SaveAs (2)

Therefore (vla-SaveAs dbxdoc ...) ought to be running the object's version of SaveAs. But if that call is accepting 3 arguments, something weird is going on.