Possible bug: extrude feature

Possible bug: extrude feature

rolandas_vegis
Advocate Advocate
408 Views
1 Reply
Message 1 of 2

Possible bug: extrude feature

rolandas_vegis
Advocate
Advocate

Hello,

 

I encountered a weird behavior while with extrude features through API. It only reproduces on specific model.

 

Screencast showing the issue:

https://autode.sk/3gxdhge

 

As you can see in the screen cast, when running the code it fails to create the extrude feature - the error is shown in the message box. However when editing the feature in Fusion you can see it shows everything is fine with it and after clicking ok - the extrude is made. Therefore I can only conclude that this is an API bug.

 

Demo code to reproduce the issue:

 

 

#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>


using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;

Ptr<Application> app;
Ptr<UserInterface> ui;

extern "C" XI_EXPORT bool run(const char* context)
{
	app = Application::get();

	Ptr<Component> activeObj = app->activeEditObject();
	for (const auto& occ : activeObj->allOccurrences())
	{
		const auto name = occ->component()->name();
		if (name == "Virs_sp_virsus (1)")
		{
			const auto body = occ->bRepBodies()->item(0);
			const auto face = body->faces()->item(0);
			const auto extrudeFeatures = occ->component()->features()->extrudeFeatures();
			const auto input = extrudeFeatures->createInput(face, CutFeatureOperation);
			const auto distanceExtent = DistanceExtentDefinition::create(ValueInput::createByReal(2));
			input->setOneSideExtent(distanceExtent, NegativeExtentDirection);
			input->participantBodies({ body });

			const auto feature = extrudeFeatures->add(input);
			if (!feature)
			{
				std::string description;
				const auto errorNumber = app->getLastError(&description);

				app->userInterface()->messageBox(description);
			}

			break;
		}
	}


	return true;
}

extern "C" XI_EXPORT bool stop(const char* context)
{
	return true;
}

 

 

Link to the model:

https://a360.co/3oCL1M1

0 Likes
409 Views
1 Reply
Reply (1)
Message 2 of 2

KrisKaplan
Autodesk
Autodesk

Hi,

 

There is something going wrong here, and I filed issue FUS-76537 for this.

 

The issue is related to the complexities introduced by the assembly context. From the error, I can guess that your design has:

  1. More than one instance of this component.
  2. The Occurrence you are working on is not the first occurrence of this component.
  3. This Occurrence is rotated perpendicular to the selected face relative to the first occurrence of this component.

The complexity being that you are selecting a Face proxy in the assembly context of that Occurrence (because you obtained the Body from the Occurrence, and not the Component). So the participant body and the profile face are in the context of this occurrence. But the ExtrudeFeatures collection obtained from the Component does not have an assembly context (it is in the 'component space', unaware of any of the occurrence transforms). Without a 'creationOccurrence' specified on the input, the features collection just uses the first occurrence of this component in the assembly for the context, and in your case it looks like that occurrence is perpendicular to the one you got the body from. So the first problem is that your script is not specifying the creationOccurrence on the input. The second problem (that I filed the issue for) is that the creationOccurrence is not being used properly in this case, and it is using the first occurrence of the component even if the creationOccurrence is specified.

 

But in your specific case where the profile face and participant body are both in the Component, you can just avoid the assembly context issues entirely by just staying in the 'component space'. It should work correctly if you just change the line that gets the Body to:

const auto body = occ->component()->bRepBodies()->item(0);

Kris



Kris Kaplan
0 Likes