Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete multiple features

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
VismantasKizelis
326 Views, 7 Replies

Delete multiple features

Hello

My question is similar to this one, just I need to delete multiple CombineFeature objects witch cannot be placed to some sub component. It takes some time to delete them in a loop by calling deleteMe() for every feature. It is much faster to select those features in UI and delete them all at once, but I cannot find how to do it in API.

7 REPLIES 7
Message 2 of 8

Hi @VismantasKizelis .

 

I couldn't imagine this at all just from the text.

 

One way to shorten the processing time is to move the timeline marker.

 

If you move the marker to the front of the first feature among the multiple features to be deleted, and then delete all of them, the processing time will be reduced because you only need to recalculate once.

Message 3 of 8

Take a look at the deleteEntities method on the Design object.  I believe that should work.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7706A1A4-1975-4043-B76B-E9A752BE9DD2

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

Looks like a perfect solution, but unfortunately Fusion360 gives "3 No qualified object(s) to delete;" error when trying to delete the CombineFeature objects.

Message 5 of 8

I just did a quick test where I deleted two combine features at once and it worked without any problem.  There must be something else in your specific case.  Can you provide a simple case that demonstrates the problem?

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

Just created a new script and here is my sample code for it. I get the "invalid parameter entities" error with this script. For simplicity trying to delete one combine feature in object collection (same results if I add more features). 

 

extern "C" XI_EXPORT bool run(const char* context)
{
	app = Application::get();
	const Ptr<Design> design = app->activeProduct();

	const Ptr<CombineFeature> featureToDelete = app
		->userInterface()
		->activeSelections()
		->item(0)
		->entity();
	if (!featureToDelete)
		return app->userInterface()->messageBox("Select the combine feature in timeline");

	const auto objectCollection = ObjectCollection::create();
	objectCollection->add(featureToDelete);
	const auto result = design->deleteEntities(design);
	if (!result)
	{
		std::string description;
		app->getLastError(&description);
		return app->userInterface()->messageBox(description);
	}
	return true;
}

 

 

 

 

 

Message 7 of 8

The problem with this test code is that you're passing in the Design object to the deleteEntities method.  You need to pass in the ObjectCollection.

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

Ooops, my mistake. Seems the example works perfect. I'll check my production code. Thank you for help.

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