Edit dwg Properties

Edit dwg Properties

Anonymous
Not applicable
4,845 Views
25 Replies
Message 1 of 26

Edit dwg Properties

Anonymous
Not applicable
Is it possible to edit the properties of a dwg file that isn't open in AutoCAD via VB/VBA/VL? I want to add summary information to the comments text box without opening the files.

Thanks
0 Likes
4,846 Views
25 Replies
Replies (25)
Message 2 of 26

Anonymous
Not applicable
ObjectDBX ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5482448@discussion.autodesk.com...
Is it possible to edit the properties of a dwg file that isn't open in AutoCAD via VB/VBA/VL? I want to add summary information to the comments text box without opening the files.

Thanks
0 Likes
Message 3 of 26

Anonymous
Not applicable
Agreed,
Is this code correct?

Option Explicit
' request reference to your current version of
' AutoCAD/ObjectDBX Common XX.0 Type Library
Sub AddSumInfoDBX()

On Error GoTo Err_Control
Dim fn As String
Dim oDBX As AxDbDocument

fn = "C:\temp.dwg"

Set oDBX = New AxDbDocument
Dim sInfo As Object

Set oDBX = Application.GetInterfaceObject("ObjectDBX.AxDbDocument.16") '<--17 for higher then A2005

' Add custom info
Set sInfo = oDBX.SummaryInfo
sInfo.Title = "Title"
sInfo.Author = "Me"
sInfo.Comments = "No comments, sir"
sInfo.Keywords = "Keywords"
sInfo.RevisionNumber = Format(Now, "dd/mm/yyyy")
sInfo.LastSavedBy = "Me"
sInfo.Subject = "Subject"

' Add custom properties (and remove prior one)

Dim cusKeys As Variant
Dim cusPropArr As Variant
Dim cusValArr As Variant
Dim i As Integer
Dim keyName1, keyName2, keyName3, keyName4

cusKeys = Array(keyName1, keyName2, keyName3, keyName4)
cusPropArr = Array("First Property", "Second Property", "Third Property", "Fourth Property")
cusValArr = Array("First Property Value", "Second Property Value", "Third Property Value", "Fourth Property Value")

For i = 0 To UBound(cusKeys)
sInfo.AddCustomInfo cusPropArr(i), cusValArr(i)
Next


oDBX.SaveAs fn
Set oDBX = Nothing

Err_Control:

MsgBox "Error Number: " & Err.Number & vbNewLine & _
"Error: " & vbNewLine & Err.Description

End Sub

~'J'~
Message 4 of 26

Anonymous
Not applicable
works great, thanks
0 Likes
Message 5 of 26

Anonymous
Not applicable
Glad if that helps

Cheers 🙂

~'J'~
0 Likes
Message 6 of 26

Anonymous
Not applicable
Ok this works to put in the author info, but drawing is set to a new drawing. I need it to edit an existing drawing, Any ideas? Thanks for the help.

Option Explicit
' request reference to your current version of
' AutoCAD/ObjectDBX Common XX.0 Type Library
Sub AddSumInfoDBX()
Dim fn As String
Dim oDBX As AxDbDocument
fn = "C:\temp.dwg"
Dim sInfo As Object
Set oDBX = Application.GetInterfaceObject("ObjectDBX.AxDbDocument.17")
Set sInfo = oDBX.SummaryInfo
sInfo.Author = "Me"
oDBX.SaveAs fn
Set oDBX = Nothing
End Sub
0 Likes
Message 7 of 26

Anonymous
Not applicable
wrote in message news:5484240@discussion.autodesk.com...
Ok this works to put in the author info, but drawing is set to a new
drawing. I need it to edit an existing drawing, Any ideas? Thanks for the
help.

Option Explicit
' request reference to your current version of
' AutoCAD/ObjectDBX Common XX.0 Type Library
Sub AddSumInfoDBX()
Dim fn As String
Dim oDBX As AxDbDocument

fn = FilenameToOpen '<----------

Dim sInfo As Object
Set oDBX = Application.GetInterfaceObject("ObjectDBX.AxDbDocument.17")

'trap for errors of course...
oDbx.Open fn '<----------

Set sInfo = oDBX.SummaryInfo
sInfo.Author = "Me"
oDBX.SaveAs fn
Set oDBX = Nothing
End Sub

hth
Mark
0 Likes
Message 8 of 26

meck
Collaborator
Collaborator

Hi everyone,

I've been programming Inventor for 8 years now so programming AutoCAD is rather new to me. We are implementing Vault Pro and we have a huge amount of legacy drawing in AutoCAD that need to go into the vault. So I am trying to set the properties of these drawings using VB6. I have used the code provided here in this thread, but I am getting an error that says "Problem in loading application" on this line...

Set oDBX = oAcadApp.GetInterfaceObject("ObjectDBX.AxDbDocument.17")

I have referenced the AutoCAD Type Library 2013 and the AutoCAD/ObjectDBX Common 19.0 Type Library (which for some reason I have 2 in my reference list and I've tried both).

 

Any help here would be greatly appreciated! 

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 9 of 26

meck
Collaborator
Collaborator

I tried changing the ObjectDBX.AxDbDocument.17 to ObjectDBX.AxDbDocument.19 and now I get a Type Mismatch error.

 

BTW will I be able to edit the property values?

 

This is my code...

Dim oAcadApp As AcadApplication          'The AutoCAD application object
Set oAcadApp = GetObject(, "AutoCAD.Application")

Dim oDBX As AxDbDocument
Set oDBX = oAcadApp.GetInterfaceObject("ObjectDBX.AxDbDocument.19")

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 10 of 26

meck
Collaborator
Collaborator

No help?

Anyone?

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 11 of 26

Anonymous
Not applicable
Can this be done with Microsoft access?
0 Likes
Message 12 of 26

Ed__Jobe
Mentor
Mentor

@Anonymous wrote:
Can this be done with Microsoft access?

Yes, but acad needs to be installed on the pc in order for the class to be registered, and your project needs to reference AutoCAD/ObjectDBX Common ##.# Type Library.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 13 of 26

Anonymous
Not applicable

Done...  Can you suggest code?

0 Likes
Message 14 of 26

Ed__Jobe
Mentor
Mentor

^^ Look above.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 15 of 26

Anonymous
Not applicable

AcadApplication does not work with the 22.0 library.

0 Likes
Message 16 of 26

Ed__Jobe
Mentor
Mentor

Look at Marks' reply in post 7. You don't need to use AcadApplication. You use the odbx app instead.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 17 of 26

Anonymous
Not applicable

Working on it now.  Thanks for your help!

0 Likes
Message 18 of 26

Anonymous
Not applicable

Ugh...  GetInterfaceObject doesn't work either...

0 Likes
Message 19 of 26

Ed__Jobe
Mentor
Mentor

Did you substitute 22 for 19? Is 22 the version you have installed? What version of acad are you running? You can check the registry in the Classes section.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 20 of 26

Anonymous
Not applicable

The object library is 22.0.  We are running Civil 3d 2018.

0 Likes