View Full Version : LISP Routine needed to set up Project Paths
stusic
2004-10-28, 05:58 PM
Hey All,
Recently I asked about writing a LISP routine that would set up our project paths and support paths. I got some very helpful information and a good pointer to code similar to what I need. I've included this code below... The question I have now is: How do I use LISP to set up different directories? See, the support path is easy enough, it has the support path tree with directories located right under it, as shown in the code. The project path tree is a little different. It has the tree, but it also requires you to enter a project name and the directories for that project in a subtree. I am completely LISP illiterate, but I can't imagine it would be that hard. Can someone tell me how to show the project name and the directories associated with the project? You all ave been great. Thanks.
(defun C:SetupProjectPaths (/ AcadFiles ProjectPath)
(vl-load-com)
;; retrieve the AcadPreferencesFiles object
(setq AcadFiles
(vla-get-files
(vla-get-preferences
(vlax-get-Acad-Object)
)
)
)
;; Set up the Project paths.
;; Use double backslashes for each directory backslash
;; and separate folders with a semicolon.
(setq ProjectPath
(strcat
"O:\\Alexandria International Airport\\Approvals"
";"
"O:\\Alexandria International Airport\\Approvals\\Profile Sections
)
)
;; Set the ProjectPath Property
(vlax-put-property AcadFiles "ProjectPath" ProjectPath)
(princ)
)
;;defun
Peace,
Phillip
Glenn Pope
2004-10-28, 06:06 PM
I have move this thread from the CAD Management forum to this one.
whdjr
2004-10-29, 01:11 PM
Can someone tell me how to show the project name and the directories associated with the project?
What do you mean "to show"?
Do you mean at the command line?
Do you mean in a dialog box?
Dude we're from the same town. Imagine that. That's cool.
Mike.Perry
2004-10-29, 08:14 PM
What do you mean "to show"?
Do you mean at the command line?
Do you mean in a dialog box?
Hi
The following thread should help explain what Phillip is after -
PROJECTNAME Variable dilemma (http://forums.augi.com/showthread.php?t=9470)
:beer: Mike
stusic
2004-11-01, 01:51 PM
What do you mean "to show"?
Do you mean at the command line?
Do you mean in a dialog box?
Dude we're from the same town. Imagine that. That's cool.
It's in the actual LISP routine that I need to show it. While setting up the Support File Search Path, I can easily see where you define the directories (see LISP above). However, if you look at the Project Files Search Path, it doesn't have a directory right under it - it's got project names then that particular project's support directories under it. It is here I have problems. I can't figure out how to create these projects in LISP. Grrr.... The support directories under it should be easy enough to write (maybe) if I can just create these Projects...
Thanks for any help. Any help at all.
Phillip
stig.madsen
2004-11-01, 02:28 PM
Is it the GetProjectFilePath and SetProjectFilePath methods you need?
stusic
2004-11-01, 02:55 PM
It may be the "SetProjectFilePath" variable. I don't think it's the "GetProjectFilePath" - it's this LISP routine that will define what projects are in the Projects File Search Path. First I must define the projects, then define the directories that support those projects.
So it should look something like this:
(setq SetProjectFilePath
(strcat
"O:\\Alexandria International Airport\\Approvals"
";"
"O:\\Alexandria International Airport\\Approvals\\Profile Sections
)
Except, where do I add the Project's name?
Thanks!
Phillip
stig.madsen
2004-11-01, 06:44 PM
What I meant was to access the projectnames/-paths through the Preferences object:
(setq acadapp (vlax-get-acad-object))
(setq prefs (vla-get-preferences acadapp))
(setq fileprefs (vla-get-files prefs))
This will get you the PreferencesFiles object from the application. GetProjectFilePath and SetProjectFilePath are methods of that object.
Say you get a projectname from the drawings PROJECTNAME variable (sysvar). This can be passed to GetProjectFilePath to find if such a projectname exists and, if so, extract the path associated with it:
(setq projName (getvar "PROJECTNAME"))
(setq projPath (vla-getProjectFilePath fileprefs projName))
If you want to add a new projectname, you can add it and set up a path with SetProjectFilePath:
(setq projName "newProject"
projPath "C:\\newProjectFolder")
(vla-setProjectFilePath fileprefs projName projPath)
stusic
2004-11-03, 01:41 PM
I am completely lost. I think I have tried to delve into task that is beyond me. I have tried to assemble the code you posted stig.madsen, along with code found elsewhere to create support paths, but I can't get it to work. It keeps giving me syntax errors, but I am not familiar enough with LISP to find the errors. Here is the code I have so far:
****************************************************************************
(defun C:getProjectFilePath (/ AcadFiles ProjectFilePath)
(vl-load-com)
;; retrieve the AcadPreferencesFiles object
(setq acadapp (vlax-get-acad-object))
(setq prefs (vla-get-preferences acadapp))
(setq fileprefs (vla-get-files prefs))
)
)
)
(setq projName (getvar "PROJECTNAME"))
(setq projPath (vla-getProjectFilePath fileprefs projName))
)
)
(vlax-put-property AcadFiles "SupportPath" SupportPath)
(princ)
(setq projName "newProject"
projPath "C:\\newProjectFolder")
(vla-setProjectFilePath fileprefs projName projPath)
)
;;defun
*************************************************************************
I don't know why I'm having so much trouble setting the Projects and the paths for them, I had expected it to be much easier. Let me tell you, through this experience, I have gained much respect for programmers. I have been trying to get this routine done so we can abandon using profiles to load the projects, allowing the end-users to be able to customize their environment. Grr...
Thanks All.
Sincerely,
Frustrated & Confused
CAB2k
2004-11-03, 04:16 PM
This will get you a little closer. Deleted the extra parentheses.
Did not test the code though.
(defun c:getprojectfilepath (/ acadfiles projectfilepath)
(vl-load-com)
;; retrieve the AcadPreferencesFiles object
(setq acadapp (vlax-get-acad-object))
(setq prefs (vla-get-preferences acadapp))
(setq fileprefs (vla-get-files prefs))
(setq projname (getvar "PROJECTNAME"))
(setq projpath (vla-getprojectfilepath fileprefs projname))
(vlax-put-property acadfiles "SupportPath" supportpath)
(princ)
(setq projname "newProject"
projpath "C:\\newProjectFolder"
)
(vla-setprojectfilepath fileprefs projname projpath)
)
;;defun
stusic
2004-11-09, 03:13 PM
I tried the code and , as much as I think it should work, I get an error message:" error: Automation Error. Error getting preference property" How come it givces this? I dunna-a-understand...
Thanks All,
Phillip
MHultgren
2005-05-31, 07:34 PM
Did you have LDT initialized before you ran the code?
LT.Seabee
2007-09-10, 03:19 PM
I got the following error.
Automation Error. Error getting preference property
CAB2k
2007-09-10, 04:50 PM
Try this:
http://www.theswamp.org/index.php?topic=7400.msg92366#msg92366
I got the following error.
Automation Error. Error getting preference property
The Automation Error is due to either the ProjectName not being specified, or the ProjectName is not listed in the Projects for the active profile.
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.