Jump to content

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


Atmoz

Recommended Posts

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

(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 "[color=red]PROFILE_ONE[/color]")
    (setq myProfName "[color=red]PROFILE_TWO[/color]"))
 (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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...