Modify DWG / Variable Without Open (ObjectDBX)

Discussion in 'AutoCAD' started by Oberer, Jan 24, 2005.

  1. Oberer

    Oberer Guest

    I started a thread asking for helping with INSBASE. I don't know what we do, but something throughout each day sets this variable to something besides 0,0,0 (for the WCS). this makes xrefing the dwg into others a real pain.

    I was hoping to write a quick app that'd let the user pick the "suspected" dwg, open it (in the back ground), update the var, save it, and then allow the user to try the XREF again.

    I'm very unfamiliar with objectdbx. After finding some sample code, I'm able to get the dwg. however methods like setvar and sendcommand are not available with AxDbDocument, so i'm not sure how to do this.
    I find little to no doco in the help, and the online search hasn't turned up much...


    TIA

    Code:
    Private Sub testit()
    Dim Filter As String
    Dim InitialDir As String
    Dim DialogTitle As String
    Dim strfileName As String
    Dim oDoc As AcadDocument
    Dim varData(0 To 2) As Variant
    
    Dim DbxDoc As Object 'As AxDbDocument
    Set DbxDoc = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument")
    
    
    Filter = "Drawing Files (*.dwg)" + Chr$(0) + "*.dwg" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
    InitialDir = "C:\Program Files\AutoCAD 2002\Sample"
    DialogTitle = "Open a DWG file"
    
    strfileName = ShowOpen(Filter, InitialDir, DialogTitle)
    
    DbxDoc.Open strfileName
    'If DbxDoc.ReadOnly = False Then
    DbxDoc.UserCoordinateSystems (1)
    'DbxDoc.SendCommand ("ucs" & vbCr & "W" & vbCr)
    'reset base
    varData(0) = 0#: varData(1) = 0: varData(2) = 0
    ' reset variable
    DbxDoc.SetVariable "INSBASE", varData
    DbxDoc.Save
    'Else
    '    MsgBox "dwg is read only"
    'End If
    
    
    End Sub
    
     
    Oberer, Jan 24, 2005
    #1
  2. Hi

    Surely it would be easier to write a script file to process every drawing in
    a directory and set it's INSBASE to 0,0,0.


    You will plenty of examples of script files for processing multiple drawings
    in the customisation NG.

    If you ony have a small number of drawings (up to 100) it may be easier to
    do it semi manually with a simple non-looping script which you can put on a
    temporary Icon.

    --

    Regards,


    Laurie Comerford
    www.cadapps.com.au
     
    Laurie Comerford, Jan 24, 2005
    #2
  3. CanĀ“t be done using objecdbx
     
    Jorge Jimenez, Jan 24, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.