Extrude using API fails on some faces in this model

Extrude using API fails on some faces in this model

rolandas_vegis
Advocate Advocate
446 Views
3 Replies
Message 1 of 4

Extrude using API fails on some faces in this model

rolandas_vegis
Advocate
Advocate

Hello,

 

Got a model where extrude is failing on some faces.

The face being extruded is flat, plane face, yet the error message says: EXTRUDE_CREATION_FAIL_ERROR - Cannot complete extrusion. / ASM_PATH_TANGENT - The path is tangent to the profile. Try adjusting the path or rotating the profile. Which does not make much sense.

 

Demo code which reproduces 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;

extern "C" XI_EXPORT bool run(const char* context)
{
	app = Application::get();
	Ptr<Component> root = app->activeEditObject();
	auto occurrences = root->allOccurrences();
	auto occ = occurrences->itemByName("Cappello_del_corpo_mobile[Q02C-005M]:1");
	auto faces = occ->bRepBodies()->item(0)->faces();
	Ptr<BRepFace> targetFace;
	auto targetFaceArea = 113.759999999;
	for (auto i = 0; i < faces->count(); i++)
	{
		auto face = faces->item(i);
		auto area = face->area();
		if (fabs(area - targetFaceArea) < 0.0000001)
		{
			targetFace = face;
			break;
		}
	}

	//Extrude
	const auto component = occ->component();
	const auto features = component->features();
	const auto extrudeFeatures = features->extrudeFeatures();
	const auto extrudeInput = extrudeFeatures->createInput(targetFace, NewComponentFeatureOperation);
	const auto valueInput = ValueInput::createByReal(1);
	const auto distanceExtent = DistanceExtentDefinition::create(valueInput);
	extrudeInput->setOneSideExtent(distanceExtent, PositiveExtentDirection);
	const auto extrudeFeature = extrudeFeatures->add(extrudeInput);

	std::string lastError;
	app->getLastError(&lastError);
	app->userInterface()->messageBox(lastError);
	return true;
}

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

 

Link to the model: https://a360.co/4dysf22

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

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I was able to reproduce the same error with a Python script.  Very extrange this error, since the extrude path is calculated internally which is perpendicular to the face selected.

 

As a workaround you can create a sketch on that face, project the face into the sketch which creates a profile sketch, and then use that profile to make the extrude.  It worked for me.

 

Regards,

Jorge Jaramillo

 

0 Likes
Message 3 of 4

rolandas_vegis
Advocate
Advocate
Thanks, your workaround does indeed work, but a bug fix for this would be even better.
0 Likes
Message 4 of 4

rolandas_vegis
Advocate
Advocate

Also it looks like the directions returned by orientedMinimumBoundingBox are wrong.

 

rolandas_vegis_0-1724066103077.png

rolandas_vegis_1-1724066199415.png

 

Created 2 same bodies in different models and drew the Axes I get from OrientedBoundingBox3D.  The first screenshot is from the model I provided in this post and is wrong. 

This body has a thickness of 0.001, which is returned as length in the oriented box. So oriented box length should be the red arrow looking directly at the screen, yet it is pointing up.

 

It could be that something in this model is impacting both the extrude and the orientedMinimumBoundingBox.

0 Likes