.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Plant 3D - Creating Project Folders

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
martin.wright
1547 Views, 10 Replies

Plant 3D - Creating Project Folders

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

10 REPLIES 10
Message 2 of 11
dave.evans
in reply to: martin.wright

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

Message 3 of 11
martin.wright
in reply to: dave.evans

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

Message 4 of 11
fenton.webb
in reply to: martin.wright

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. 
 




Fenton Webb
AutoCAD Engineering
Autodesk

Message 5 of 11
martin.wright
in reply to: fenton.webb

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

Message 6 of 11
fenton.webb
in reply to: martin.wright

I think if you pass null to CreateFolder it will do the magic for you...

 

e.g.

 

string FldrGuid = oPrjPiping.CreateFolder(null, MyFolder);

 




Fenton Webb
AutoCAD Engineering
Autodesk

Message 7 of 11
martin.wright
in reply to: fenton.webb

Hi Fenton

Excellent.

I’m using VB and used Nothing in place of null but that did the job.

 

Regards

Martin

Message 8 of 11
Ender157
in reply to: martin.wright

this is good but is it possible to create subfolders?

 

Message 9 of 11
jabowabo
in reply to: Ender157


@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)

 

Message 10 of 11
Ender157
in reply to: jabowabo

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.

 

Message 11 of 11
jabowabo
in reply to: Ender157

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost