convert a .scr file to VBA

Discussion in 'AutoCAD' started by stephenlecompte, Mar 8, 2005.

  1. I have the following VBA code to run a .scr script file. What I would like is to get away from using the .scr script file and just run the commands using all VBA code. Where I run into a roadblock is that the .scr file, most of the time, uses a template file.
    Let's say I had the following VBA and just removed acDocument.SendCommand "script" & vbCr & txtNameFile & vbCr...how I could I re-write the following to adjust the drawings that I have. The script is located well below this series of VBA and the .scr script follows with finally the template ROOMTAG.TXT file shows what's listed inside.


    Dim acDocument As Object
    On Error Resume Next
    Set acadapp = GetObject(, "AutoCAD.application")
    If Err Then
    Err.Clear
    Set acadapp = CreateObject("AutoCAD.application")template file of what is in is listed last...
    Dim acadapp As Object
    End If
    Set acDocument = acadapp.Documents.New
    acadapp.Visible = True
    Set acDocument = acadapp.ActiveDocument
    acDocument.SetVariable "filedia", 0
    acDocument.SendCommand "script" & vbCr & txtNameFile & vbCr
    arrow4.Visible = True
    arrow5.Visible = True
    DoCmd.Hourglass (False)
    cmdExtraction.Visible = True
    acDocument.SetVariable "filedia", 1
    acDocument.Close
    Set acDocument = Nothing
    Set acadapp = Nothing
    MsgBox "Script has finished! Now you are able to create your schedules..."

    Beginning of .scr file- listed from notepad.
    open G:\pj\MHHS\39001-00\CD\Xtag-1-96.dwg
    filedia
    0
    cmddia
    0
    -attext
    c
    I:\data\ACCESS\Template\Records\ROOMTAG.txt
    I:\proj\MHHS\39001-00\CD\TeamDocs\Xplan-01
    open G:\pj\MHHS\39001-00\CD\Xtag-2-96.dwg
    -attext
    c
    I:\data\ACCESS\Template\Records\ROOMTAG.txt
    I:\proj\MHHS\39001-00\CD\TeamDocs\Xplan-02
    close
    open G:\pj\MHHS\39001-00\CD\Xtag-3-96.dwg
    -attext
    c
    I:\data\ACCESS\Template\Records\ROOMTAG.txt
    I:\proj\MHHS\39001-00\CD\TeamDocs\Xplan-03
    close
    filedia
    1
    cmddia
    1
    quit
    y
    ...................end of script file

    ..... start of Template (ROOMTAG.txt)

    ROOMNAME1 C018000
    ROOMNAME2 C018000
    ROOM# N009000

    .... end of template file
     
    stephenlecompte, Mar 8, 2005
    #1
  2. It won't be anywhere near as simple in VBA thanks to the lack of an
    interface for attribute extraction.

    You'll have to iterate your drawings, select the appropropriate blocks,
    retrieve their attributes, write the desired values to a file and repeat
    until you're done.
     
    Frank Oquendo, Mar 8, 2005
    #2
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.