Is there a way to create multiple projects in one batch?

Is there a way to create multiple projects in one batch?

chrisw01a
Collaborator Collaborator
1,240 Views
16 Replies
Message 1 of 17

Is there a way to create multiple projects in one batch?

chrisw01a
Collaborator
Collaborator

We make a unique project for every job. I have to create each one manually. Is there a faster way to do this?

 

In the image below, you can see I am creating 86758. How can we type in a list of job numbers and create new projects in the folder \\server1\Inventor\Job\ 

 

Thank you!

 

chrisw01a_0-1649878247823.png

 

0 Likes
Accepted solutions (1)
1,241 Views
16 Replies
Replies (16)
Message 2 of 17

pcrawley
Advisor
Advisor

The IPJ is just an XML file, so you can edit it with Notepad.

 

Copy & Paste the file, then search and replace the job number (assuming that's the only thing you change.

  

Certainly something you could automate with a batch file, or an add-in.

Peter
Message 3 of 17

jtylerbc
Mentor
Mentor

Every project that my company works for has its own Inventor project file.  On our shared network drive, I would guess there are several thousand of them, and that number goes up every day.  But the last time I made one completely from scratch using the wizard was over 10 years ago.

 

Instead I made one with all the correct library paths and other settings, and saved it in a central location.  We just copy the file to the new workspace location and rename it to make new ones.  It's not a batch operation, but it's a quick and easy way to make individual new ones as you go.

Message 4 of 17

Curtis_Waguespack
Consultant
Consultant

Hi @chrisw01a 

 

Here's an iLogic rule that will read an Excel file and create a new project file for each row in the list.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Curtis_Waguespack_0-1649884336573.png

 

oPath = "\\server1\Inventor\Job\"
oFile = oPath & "Project List.xlsx" 'uses the above path to find the excel file

'look at the rows A2 thru A50, adjust as needed
'note blank rows are ok
Dim oList As New ArrayList
oList = GoExcel.CellValues(oFile, "Sheet1", "A2", "A50")

' Set a reference to the DesignProjectManager object.
Dim oDesignProjectMgr As DesignProjectManager
oDesignProjectMgr = ThisApplication.DesignProjectManager
Dim oProject As DesignProject

For Each oNumber In oList
	' Create a new single user project	
	oProject = oDesignProjectMgr.DesignProjects.Add(kSingleUserMode, _
		oNumber, oPath & "\" & oNumber & "\")
Next

 

Message 5 of 17

chrisw01a
Collaborator
Collaborator
Will look into it. Thank you.
0 Likes
Message 6 of 17

chrisw01a
Collaborator
Collaborator
I have done this before too. I am just wanting something faster since I usually set up and run 10 or 20 jobs at a time. Thank you
0 Likes
Message 7 of 17

chrisw01a
Collaborator
Collaborator
Curtis, you have saved the day for us many times over the years. Much appreciated. I will see how this works and maybe I can incorporate it into our FileCopy VB.net project that we use to copy designs from the master to jobs.
Message 8 of 17

chrisw01a
Collaborator
Collaborator

Curtis,

I am getting this message when I run the code. Any ideas?

 

chrisw01a_0-1649936933469.png

 

Message 9 of 17

Curtis_Waguespack
Consultant
Consultant

Hi @chrisw01a,

 

I think Inventor is having trouble reading from Excel. See these links:

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-export-to-excel-error-error-l...

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-fails-to-talk-to-excel/td-p/6...

 

If you'd prefer not to use Excel or that continues to be problematic, we can probably just use a *.txt file or something else to get the list. Below is an example that just uses an Inventor parameter to supply the list.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Curtis_Waguespack_0-1649946575627.png

 

 

oPath = "C:\Temp\Server\"

Dim oList As New ArrayList
oList = MultiValue.List("ProjectList")

' Set a reference to the DesignProjectManager object.
Dim oDesignProjectMgr As DesignProjectManager
oDesignProjectMgr = ThisApplication.DesignProjectManager
Dim oProject As DesignProject

For Each oNumber In oList
	' Create a new single user project	
	oProject = oDesignProjectMgr.DesignProjects.Add(kSingleUserMode, _
		oNumber, oPath & "\" & oNumber & "\")
Next

 

0 Likes
Message 10 of 17

chrisw01a
Collaborator
Collaborator

Hello Curtis-

I have this working but I cannot figure out how to build the list with this function. Can you help please? As you see in the code below, I have explicitly called two cells to add to the list but how to we automate the process?

 

oPath = "\\server1\Inventor\Job\"
oFile = oPath & "Create Projects.xlsx" 

' Open Excelworkbook
Dim oExcel As Object = CreateObject("Excel.Application")
	oExcel.Visible = False
	oExcel.DisplayAlerts = False
	Dim oWB As Object = oExcel.Workbooks.Open(oFile)
	Dim oWS As Object = oWB.Sheets(1) 'Sheet 1
	oWS.Activate()

' Build the list of project numbers (HELP!)
' How can we specify a range of cells or an entire column here?
Dim oList As New ArrayList
oList.Add(oWS.Cells(2, 1).Value)
oList.Add(oWS.Cells(3, 1).Value)

' Set a reference to the DesignProjectManager object.
Dim oDesignProjectMgr As DesignProjectManager
oDesignProjectMgr = ThisApplication.DesignProjectManager
Dim oProject As DesignProject

For Each oNumber In oList
	MsgBox(oPath & oNumber & "\")
	' Create a new single user project	
	oProject = oDesignProjectMgr.DesignProjects.Add(kSingleUserMode, oNumber, oPath & oNumber & "\")
Next	
	
'oWB.Save() 'Use this to save it
oWB.Close (True)
oExcel.Quit
oExcel = Nothing

  

0 Likes
Message 11 of 17

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @chrisw01a,

 

This version looks at the first column and rows 2  to 10.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
 

 

 

oPath = "\\server1\Inventor\Job\"
oFile = oPath & "Create Projects.xlsx" 

' Open Excelworkbook
Dim oExcel As Object = CreateObject("Excel.Application")
oExcel.Visible = False
oExcel.DisplayAlerts = False
Dim oWB As Object = oExcel.Workbooks.Open(oFile)
Dim oWS As Object = oWB.Sheets(1) 'Sheet 1
oWS.Activate()

Dim oList As New ArrayList
For i = 2 To 10 'look at rows 2 through 10 
	oValue = oWS.Cells(i, "A").value
	If Trim(oValue) = "" Then Continue For
	oList.Add(oValue)
Next

' Set a reference to the DesignProjectManager object.
Dim oDesignProjectMgr As DesignProjectManager
oDesignProjectMgr = ThisApplication.DesignProjectManager
Dim oProject As DesignProject

For Each oNumber In oList
	MsgBox(oPath & oNumber & "\")
	' Create a new single user project	
	Try
		oProject = oDesignProjectMgr.DesignProjects.Add(kSingleUserMode, oNumber, oPath & oNumber & "\")
	Catch 'catch error (example: *.ipj already exists)
	End Try
Next

'oWB.Save() 'Use this to save it
oWB.Close(True)
oExcel.Quit
oExcel = Nothing

 

0 Likes
Message 12 of 17

chrisw01a
Collaborator
Collaborator
This should work! Thank you so much. I'll give it a try next round.
0 Likes
Message 13 of 17

chrisw01a
Collaborator
Collaborator

Curtis,

I have copied this code to a vb.net project that I use for renaming inventor files through apprentice server. I am going to add the option to create a new inventor .ipj project in the new directory at the same time.

 

I am close but I cannot figure out how to fix this error with the designprojectmanger interface. Something is different between the iLogic editor and visual studio 2022. Do you have any clues on this?

 

chrisw01a_1-1652285933175.png

 

 

' Set a reference to the DesignProjectManager object.
Dim oDesignProjectMgr As Inventor.DesignProjectManager
oDesignProjectMgr = Inventor.DesignProjectManager
Dim oProject As Inventor.DesignProject

' Create a new single user project
Dim sFullPath = newPath & newPrefix & ".ipj"


oProject = oDesignProjectMgr.DesignProjects.Add(Inventor.MultiUserModeEnum.kSingleUserMode, newPrefix, newPath)

 

 

Thank You!

 

 

 

0 Likes
Message 14 of 17

A.Acheson
Mentor
Mentor

Hi Chris, Here is the API help written in VBA for the object DesignProjectManager and here is a sample for the Active project which will show that you need ThisApplication object first.

 

Does it give an error when you return it to the original lines?

' Set a reference to the DesignProjectManager object.
Dim oDesignProjectMgr As DesignProjectManager
oDesignProjectMgr = ThisApplication.DesignProjectManager

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 15 of 17

chrisw01a
Collaborator
Collaborator

Hello. Thank you.

yes it gives the error with the original code. I ended up getting it to work with the following code although I still have no Idea why...lol

 

Dim oDesignProjectMgr As Inventor.DesignProjectManager
oDesignProjectMgr = apprentice.DesignProjectManager
Dim oProject As Inventor.DesignProject
0 Likes
Message 16 of 17

A.Acheson
Mentor
Mentor

The apprentice server will have a different object than inventor so you would need to replace ThisApplication which refers to Inventor with the Apprentice server equivalent. With a few tweaks you could run the apprentice server from windows and a vb script (notepad)

Apprentice server and DesignProjectManager

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-6E7B531D-888D-4186-8385-41B78F14F3EF

Apprentice server overview 

 https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-F2A12822-98DE-4638-B1C7-6BEEF821D50A

Apprentice Sample

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-A1C343E0-2324-4AB1-A7A3-E2359D29DB6D

I am sure you will get much more assistance on this if needed in the future on the ilogic forum. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 17 of 17

chrisw01a
Collaborator
Collaborator

Ok. I am writing in Visual Studio 2022 so things are a bit different than iLogic editor.

At any rate, I appreciate your help and information. I'll have to look through it when I have a moment.

 

Chris

0 Likes