Start Autocad w/profile in VB?

Discussion in 'AutoCAD' started by 3DMax, Apr 26, 2004.

  1. 3DMax

    3DMax Guest

    It seems that the code below works only if there is no space in the profile name itself, is there a way to overcome that?

    Thanks

    Private Sub US_Click()

    Dim Test
    Dim n3 As String
    n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p"
    Test = "C:\DOCUME~1\ALLUSE~1\APPLIC~1\Autodesk\AUTOCA~1\Profiles\Test User NA.arg"
    Shell n3 & (Test), 3

    End Sub
     
    3DMax, Apr 26, 2004
    #1
  2. 3DMax

    Ed Jobe Guest

    The Shell command expects a single string as an argument. The delimiter for
    a string is the double quote. Its also what you use to delimit long
    filenames. So you need a delimited string inside a string. There are two
    methods in vb, use a single quote or and escape char with double quote.,
    e.g.
    "main string 'sub string'"
    "main string \"sub string\""

    --
    ----
    Ed
    ----
    profile name itself, is there a way to overcome that?
     
    Ed Jobe, Apr 26, 2004
    #2
  3. 3DMax

    3DMax Guest

    It seems to not work,could you you show the line exactly?

    Thanks
     
    3DMax, Apr 26, 2004
    #3
  4. 3DMax

    Ed Jobe Guest

    The way you had it, it was missing a space between the "/p" switch and the
    argument.

    Dim n3 As String
    n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p " & _
    "'C:\DOCUME~1\ALLUSE~1\APPLIC~1\Autodesk\AUTOCA~1\Profiles\Test User
    NA.arg'"
    Shell n3, 3
     
    Ed Jobe, Apr 26, 2004
    #4
  5. 3DMax

    Ed Jobe Guest

    Watch for word-wrap.
    n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p " & _
    "'C:\DOCUME~1\ALLUSE~1\APPLIC~1\" & _
    "Autodesk\AUTOCA~1\Profiles\Test User NA.arg'"

    --
    ----
    Ed
    ----
    The way you had it, it was missing a space between the "/p" switch and the
    argument.

    Dim n3 As String
    n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p " & _
    "'C:\DOCUME~1\ALLUSE~1\APPLIC~1\Autodesk\AUTOCA~1\Profiles\Test User
    NA.arg'"
    Shell n3, 3
     
    Ed Jobe, Apr 26, 2004
    #5
  6. You should start n instance of AutoCAD through code, not use a shell
    command. From there, I don't think you'll have any issues with the profile
    string.
     
    Mike Tuersley, Apr 26, 2004
    #6
  7. 3DMax

    3DMax Guest

    Can you show me the code?

    Thanks
     
    3DMax, Apr 26, 2004
    #7
  8. 3DMax

    Ed Jobe Guest

    Search this ng for the GetObject and CreateObject functions.
     
    Ed Jobe, Apr 26, 2004
    #8
  9. 3DMax

    Ken Hutson Guest

    3DMax,
    Here is some untested code.

    Public Sub get_autocad()
    dim objAcad as AcadApplication
    set objAcad = GetObject(, "AutoCAD.Application")
    objAcad.Preferences.Profiles.ActiveProfile = strProfileName
    End Sub

    Note: I don't see an Add method for the Profiles collection. That means
    that if strProfileName does not exist, you will get an error. I believe
    that the default profile is always present. Correct me if I am wrong guys.
    I suppose you could to copy the default and rename/set settings on the copy
    in this case.

    Regards,
    Ken Hutson
    San Antonio, TX
     
    Ken Hutson, Apr 26, 2004
    #9
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.