import file read/change parameters

import file read/change parameters

nClarke0101
Contributor Contributor
464 Views
2 Replies
Message 1 of 3

import file read/change parameters

nClarke0101
Contributor
Contributor

Im trying to read/change parameters of a imported file.

How would i do this?

Thanks

 

	Ptr<FileDialog> fileDialog = ui->createFileDialog();
	fileDialog->filter("fusion File (*.f3d);;All files (*.*)");
	if (fileDialog->showOpen() == adsk::core::DialogResults::DialogOK)
	{
		std::string filename = fileDialog->filename();

		Ptr<Component> rootComp = des->rootComponent();
		if (!rootComp)
			return false;
		
		Ptr<FusionArchiveImportOptions> archive_options = im->createFusionArchiveImportOptions(filename);
		if (!archive_options)
			return false;

		im->importToTarget2(archive_options, rootComp);
	}
0 Likes
465 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor

The importToTarget2 method returns an ObjectCollection of occurrences.  In most cases this will contain a collection of one occurrences but it depends on the file being read in.  An occurrence represents a component in an assembly. It defines it's position and can have color overrides.  From an occurrence you can use its component property to get the component it's representing. The component you get is a regular component and from it you can use the modelParameters property to get the parameters specific to that component. You can use the Parameters.itemByName property to get a specific parameter and you can change the value of the parameter.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

nClarke0101
Contributor
Contributor

sorry replied to wrong message

 

0 Likes