activating a design project fails

activating a design project fails

Anonymous
Not applicable
854 Views
3 Replies
Message 1 of 4

activating a design project fails

Anonymous
Not applicable

 

Using Inventor 2009 and C# 2005, I'm getting "ArgumentException occurred" - "The parameter is incorrect" when i attempt to activate a design project. What I'm doing is switching the project for the duration of a batch process and then switching it back to what it was. Funny thing is, it works the first time the program code is ran; i only get the error when running the code again with the same inventor instance. if i restart inventor, i can run the code again once without problems.

 

 the initial switch:

DesignProjectManager dpm = inventorApp.DesignProjectManager;
DesignProject activeDesignProject = dpm.ActiveDesignProject;
if (!activeDesignProject.FullFileName.Contains("Default.ipj"))
{
	bool found = false;
	foreach (DesignProject dp in dpm.DesignProjects)
		if (dp.FullFileName.Contains("Default.ipj"))
		{
			found = true;
			dp.Activate(); // ERROR HERE
			break;
		}
	if (!found)
		FormInterface.Update("The default project was not found in the Design Project collection.\r\n");
}

 

the switch back: 

if (dpm.ActiveDesignProject != activeDesignProject)
	activeDesignProject.Activate();

 

Again, the activations work the first time, but won't work again without restarting Inventor.

 

Any ideas?

0 Likes
855 Views
3 Replies
Replies (3)
Message 2 of 4

Mario-Villada
Advocate
Advocate

I think it is better if you use FileLocations.FileLocationsFile to read and set inventor projects, somethning like

 

InventorApplication.FileLocations.FileLocationsFile = "C:\TempMyProject.ipj"

also bear in mind that you need to have 0 documents opened when attepmting to change an project in inventor. (Application.Documents.count = 0)

 

Hope this helps.

 

Mario.

0 Likes
Message 3 of 4

Anonymous
Not applicable

Kevin,

 

You would probably have better luck with the "FileLocation" object as already suggested.... The "DesignProjectManager" was not in the API till release 2011. If somehow you are gaining access to a "DesignProjectManager" thru the API, it may not be stable in release 2009. I don't know for sure, but it may be some of the problem.

 

I am writing an application now that mimics an application I did some years ago (in Inventor 10). IV2011 does not have access to the "FileLocation" object like it used to (it actually is not even in the API object model for 2011). It is still in there and I can still use it, I just don't like using objects that are no longer supported...

 

Bill

0 Likes
Message 4 of 4

Anonymous
Not applicable

That worked beautifully. Thanks.

0 Likes