I am currently looking at writing a function to create our folder structure within the Plant 3D project.
I have looked at the PnPProjectFolder object but am unable to determine how to create a new project folder.
I do not understand how I obtain a folderGUID or the best way to discover if the folder exists. (I can loop through the ProjectItems collection).
We need to add 30 folders, including sub-folders, setting their paths as we are not using virtual folders.
I am not at a stage where I have any code worth publishing here.
I would appreciate and guidance on this.
Regards
Martin
Solved! Go to Solution.
Solved by fenton.webb. Go to Solution.
Hi Martin,
Let me possibly save you some work.
If you make a template project, build your folder structure under the template. Then, when you create a new project in Project Manager, use the "Copy settings form existing proect" radio button.
This will buid the project strucure under the new project.
This is how we deploy all our customisation / configuration changes in a consisytent manner for all clients.
I hope this helps.
Regards
Dave
Technical Specialist - Plant
Nothern Europe
Hi Dave
I have looked at this method and found that I can achieve what I require.
The trick for me was to specify the same folder for the P&ID drawings and the Plant 3D model drawings, then the project folders were built on top of that, as I required them.
I would still like to know how to achieve this programatically as the API does imply it can be done.
Thanks
Martin
The PnpProjectFolder class only creates the Virtual entries in the project database, not the physical entries on disk - to do that you need to use the normal Microsoft APIs.
The Autodesk.ProcessPower.ProjectManager.Project.CreateFolder(string, Autodesk.ProcessPower.ProjectManager.PnPProjectFolder) actually returns the GUID based on a new row in the DCF file.
I hope this explains.
Hi Fenton
Unfortunately I need more information
<CommandMethod("AddMyFolder")> _
Public Sub AddMyFolder()
Dim oPrjPiping As Project = DirectCast(PlantApplication.CurrentProject.ProjectParts("Piping"), _
Project)
Dim MyFolder As New PnPProjectFolder
Dim FldrName As String = "C:\CAD_Dwg"
System.IO.Directory.CreateDirectory(FldrName)
MyFolder.Name = "CAD_DWG"
MyFolder.AbsoluteFolderPath = FldrName
Dim FldrGuid As String = oPrjPiping.CreateFolder("Plant 3D Drawings", MyFolder)
oPrjPiping.Save()
End Sub
Can you advise where I am going wrong?
In this FldrGuid = “”
Regards
Martin
I think if you pass null to CreateFolder it will do the magic for you...
e.g.
string FldrGuid = oPrjPiping.CreateFolder(null, MyFolder);
Hi Fenton
Excellent.
I’m using VB and used Nothing in place of null but that did the job.
Regards
Martin
@Ender157 wrote:
this is good but is it possible to create subfolders?
Yes, pass the GUID of the target parent folder as a string to the first argument:
Autodesk.ProcessPower.ProjectManager.Project.CreateFolder(string, Autodesk.ProcessPower.ProjectManager.PnPProjectFolder)
Thank you for the insite. i will try that.
does this work when the project is in vault.
I get the folder to show in vault but files will not check in
9/15/2021 11:16:22 AM
Merging drawing file <--asf.dwg> into the project.
S001: Exception: ProjectItemDoesNotExist
ProjectItemDoesNotExist.
1 issues found.
I'm not familiar with the API interaction with Vault.
Can't find what you're looking for? Ask the community or share your knowledge.