Delete multiple features

Delete multiple features

VismantasKizelis
Enthusiast Enthusiast
1,044 Views
7 Replies
Message 1 of 8

Delete multiple features

VismantasKizelis
Enthusiast
Enthusiast

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.

0 Likes
Accepted solutions (1)
1,045 Views
7 Replies
Replies (7)
Message 2 of 8

kandennti
Mentor
Mentor

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

BrianEkins
Mentor
Mentor
Accepted solution

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
0 Likes
Message 4 of 8

VismantasKizelis
Enthusiast
Enthusiast

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

0 Likes
Message 5 of 8

BrianEkins
Mentor
Mentor

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
0 Likes
Message 6 of 8

VismantasKizelis
Enthusiast
Enthusiast

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;
}

 

 

 

 

 

0 Likes
Message 7 of 8

BrianEkins
Mentor
Mentor

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
0 Likes
Message 8 of 8

VismantasKizelis
Enthusiast
Enthusiast

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

0 Likes