vlax-create-object

Discussion in 'AutoCAD' started by Gary J. Orr, Apr 7, 2004.

  1. Gary J. Orr

    Gary J. Orr Guest

    Does anyone know...
    Is there a way to have:
    (vlax-create-object "AutoCAD.Application.16")
    start with a specific profile? Half of our workstations are LDT and I need
    to specify the Land Enabled Map for multi-document mode.

    Thanx for any replies,

    --
    Gary J. Orr
    CADD Administrator
    (218) 279-2421


    LHB, Inc
    21 West Superior Street, Suite 500
    Duluth, Mn 55802
    (218) 727-8446
    www.LHBcorp.com
     
    Gary J. Orr, Apr 7, 2004
    #1
  2. Gary J. Orr

    Rakesh Rao Guest

    Hi Gary,

    Are you trying to launch a new copy of AutoCAD again with your
    (vlax-create-object...)?

    Since you are using Lisp, you must already be inside a running copy of
    AutoCAD and you would want to just make a given profile active. For
    that, you can use the following function:

    If you are using VB, you can launch AutoCAD with a given profile name
    directly but once you are inside AutoCAD, you just need to make that
    profile name active as shown below in the function.


    ;; !
    ******************************************************************************
    ;; ! MI_SetActiveProfile
    ;; !
    ******************************************************************************
    ;; ! Arguments: 'ProfileName' - Profile Name to set current
    ;; ! Function : Set the specified profile as current
    ;; ! Updated : October 30, 2002
    ;; !
    ******************************************************************************

    (defun MI_SetActiveProfile ( ProfileName / acadApp prefObj cProfiles
    profLst )
    (setq profLst (MI_GetAllProfiles))
    (if profLst
    (progn
    (setq profLst (mapcar 'strcase profLst))
    (if (member (strcase ProfileName) profLst)
    (progn
    (setq
    acadApp (vlax-get-acad-object)
    prefObj (vla-get-Preferences acadApp)
    cProfiles (vla-get-Profiles prefObj)
    )
    (vla-put-ActiveProfile cProfiles ProfileName)
    )
    (alert (strcat "Profile: " ProfileName "is not defined for the
    currently logged in AutoCAD user."))
    )
    ))
    )

    ;; !
    ******************************************************************************
    ;; ! MI_GetAllProfiles
    ;; !
    ******************************************************************************
    ;; ! Arguments: none
    ;; ! Function : Returns a list string names of all the currently defined
    profiles
    ;; ! in the drawing
    ;; ! Updated : October 17, 2003
    ;; !
    ******************************************************************************

    (defun MI_GetAllProfiles( / profLst acadApp prefObj cProfiles pNames)
    (setq
    acadApp (vlax-get-acad-object)
    prefObj (vla-get-Preferences acadApp)
    cProfiles (vla-get-Profiles prefObj)
    )
    (vlax-invoke-method cProfiles 'GetAllProfileNames 'pNames)
    (setq profLst (vlax-safearray->list pNames))
    )

    ----------
    Regards
    Rakesh

    --

    Please email me your replies. I may not always be observing the posts here.

    email:

    AutoCAD customization for Engineering/Mapping/GIS
    Get GeoTools @ http://www.4d-technologies.com/geotools
    Build MyGeoTools @ http://www.4d-technologies.com/geotools/my_geotools.htm
    FREE downloads : http://www.4d-technologies.com/techcenter
    </PRE>
     
    Rakesh Rao, Apr 8, 2004
    #2
  3. Gary J. Orr

    Gary J. Orr Guest

    Rakesh,
    Thanks much for your reply.

    Let's think outside the box. Everyone knows that you have to build a script
    file and run that if you want to run a specified routine on the contents of
    a given directory (folder).

    Not anymore.

    I have been working on (and have almost completed) a LISP routine that will
    run a specified selected lisp routine on the drawings within a selected
    folder. (this could be done in VBA and VB of course but why stop there?)

    Now we can have the first session of autocad controlling and sending
    functions to the second session (IE open a drawing, run lisp routine, save
    it, close it, log the results, open next, etc...). It's all being controlled
    by the primary session and can report success/failure, whatever.

    So far the only stopping point is that half of my users use LDT (Land
    DeskTop). LDT requires SDI=1, my routine is built around SDI=0. Land Enabled
    Map (which is installed with LDT) has SDI=0. If I could start up in that
    mode I'd be golden.

    I'll look into switching the profile in that other session. I should be able
    to use the vla-put method for that. Unfortunately I believe that the SDI
    switch is at a deeper level for LDT.

    But I'm still asking my original question:

    --
    Gary J. Orr
    CADD Administrator
    (218) 279-2421


    LHB, Inc
    21 West Superior Street, Suite 500
    Duluth, Mn 55802
    (218) 727-8446
    www.LHBcorp.com
     
    Gary J. Orr, Apr 8, 2004
    #3
  4. Gary J. Orr

    John Uhden Guest

    Gary:

    I'm an LDT user. Just start with the Land Enabled Map version "...acad.exe /p
    <path>\Map.arg"
    Or, if you want to be clever in SDI=1, either set LISPINIT to 1, or use
    (vl-bb-set) and (vl-bb-ref) and acaddoc.lsp to keep the ball rolling between
    drawings in the same session.
     
    John Uhden, Apr 9, 2004
    #4
  5. Gary J. Orr

    Gary J. Orr Guest

    All are very interesting tools. I don't want to get into acaddoc.lsp for
    this (it's busy enough as it is)... Want it to be completely standalone.
    I ended up taking the coward's way out (I ran away from the fight). I
    remembered that the registry gets a flag from the last profile used at
    startup, so I checked for SDI=1 and if so I tell them to run this routine
    from a profile that has SDI=0 (such as Map). When they launch with an SDI=0
    profile (even with LDT still running) the (Default) key in the profile
    branch of the registry gets set to that profile name, then when the routine
    launches it uses that one.

    So,
    I have a solution for my immediate need... But can forsee problems if using
    VB or VBA from another application.
    Thanx much.

    --
    Gary J. Orr
    CADD Administrator
    (218) 279-2421


    LHB, Inc
    21 West Superior Street, Suite 500
    Duluth, Mn 55802
    (218) 727-8446
    www.LHBcorp.com
     
    Gary J. Orr, Apr 9, 2004
    #5
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.