+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Jan 2011
    Posts
    3

    Question Check from which directory a *.DWG opens from...

    Registered forum members do not see this ad.

    Dear all,

    To automatically switch profiles at startup I want to create a script that "looks" from which directory a *.DWG drawing is opened from. This detection script runs directly when AutoCAD starts up.

    If the user opens a drawing from c:\tek\ then "profile_one" has to be selected, and if the user opens a drawing from every other directory then "profile_two" must be selected.

    Please can you help me to "detect" from which directory a drawing is opened.

    Thanks in advance!!

    With kind regards,

    Atmoz
    (from the Netherlands, so excuses my English)

  2. #2
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    (setq answer (getvar "dwgprefix"))

    plus a "startup" lsp to change profile

  3. #3
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Jan 2011
    Posts
    3

    Default

    Thanks for the reply!

    In the meanwhile I've had it working with VBA...

    MyDocument.FullName

    if Mid$(GeopendDocument, 1, 7) = "C:\tek\" then... else... end if



    With kind regards,

    Atmoz

  4. #4
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,952

    Default

    Registered forum members do not see this ad.

    Code:
    (defun c:FOO (/ *profs* pNames profNameList myProfName)
      (vl-load-com)
       (if (and
             (setq *profs* (vla-get-profiles
                           (vla-get-preferences (vlax-get-acad-object))))
             (vla-getallprofilenames *profs* 'pNames)
             (setq profNameList (vlax-safearray->list pNames))
             (vl-string-search "C:\\TEK\\" (strcase (getvar 'dwgprefix))))
         (setq myProfName "PROFILE_ONE")
         (setq myProfName "PROFILE_TWO"))
      (if (vl-position myProfName profNameList)
        (progn
          (vla-put-activeprofile *profs* myProfName)
          (prompt (strcat "\n  >>  Profile \"" myProfName "\" Has Been made Active! ")))
        (prompt (strcat "\n  <!>  Profile \"" myProfName "\" Cannot Be Found  <!> ")))
      (princ))
    :: Untested ::

    Hope this helps!
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. Help opens when starting Autocad 2011
    By Diedesigner in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 26th Jan 2011, 11:04 am
  2. Autodesk University Opens
    By The CAD Geek Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 29th Nov 2010, 12:40 pm
  3. CAD2010 opens then closes?
    By Jadgpanther in forum AutoCAD General
    Replies: 8
    Last Post: 18th Nov 2010, 10:38 pm
  4. New Sketch Opens as Under Defined
    By Paul Miller in forum SolidWorks
    Replies: 8
    Last Post: 4th Jun 2010, 07:19 pm
  5. VB opens PDF
    By Botoyava in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 13th Feb 2008, 04:22 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts