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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Move face with MoveFeature not working

Message 1 of 5
101 Views, 4 Replies

Move face with MoveFeature not working



I have been trying to move a face using API and it does not seem to be working. I always get invalidEntity error.

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

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

extern "C" XI_EXPORT bool run(const char* context)
	auto app = Application::get();
	const auto select = app->userInterface()->activeSelections()->item(0);
	Ptr<BRepFace> face = select->entity();
	const auto moveFeatures = face->body()->parentComponent()->features()->moveFeatures();

	const auto objectCollection = ObjectCollection::create();

	Ptr<Vector3D> normal;
	face->evaluator()->getNormalAtParameter(Point2D::create(0.5, 0.5), normal);
	auto matrix = Matrix3D::create();
	const auto input = moveFeatures->createInput(objectCollection, matrix);
	const auto feature = moveFeatures->add(input);
	if (!feature)
		std::string error;

	return true;


As you can see in sample code it is as simple as it gets, yet I get errors. 

Is this a bug or am I doing something wrong?

Message 2 of 5

Hi @rolandas.vegis ,


The problem you have in your script is on line #15.  On it you selected a body's face to be moved.

The MoveFeature is intended to works over bodys, not over faces as it states in the API documentation:


inputEntitiesObjectCollectionAn ObjectCollection containing the entities to move. This collection can only contain BRepBody objects in parametric modeling. It can be BRep bodies, T-Spline bodies, mesh bodies mixed or faces and features mixed in non-parametric modeling.


I believe you might need a ExtrudeFeature instead.


Hope this help.




Message 3 of 5

But you can move faces using move command in the UI. And in documentation it says: "or faces and features mixed in non-parametric modeling."

For my purposes move would be better than extrude.
Message 4 of 5



Yes, you're right.


Two answers about what you wrote:

1.  In non-parametric mode your script works well.  Just disable capture design history.

Good point. I didn't read it completely as you did.




2. For parametric design:


You can move a face in the UI, but it is not registered as a MoveFeature in the component's MoveFeatures's property.

You can check it with this commands before and after you make the move in the UI (run them from the text commands (make it visible with Ctrl-Alt-C or File > View > Show Text Commands)):

# set app variable
app = adsk.core.Application.get()

# print moveFeatures's and extrudeFeatures's in root component

# print type of action on last item in the timeline
app.activeProduct.timeline.item(app.activeProduct.timeline.count - 1).entity


In my case I got this before:




And this is the output after I made a move face in the UI:



Take a look at the counters, their remain the same. And the last sentence returned an error trying to the get .entity property for this type of action (this use to happen with other types of operations like adding a canvas, and some others).

So, with the information in the data model of the design at the moment, I don't know the type of action it was registered as, but for sure, it isn't move neither extrude feature.  Something weird here. Isn't it?




Message 5 of 5

It is also weird that it only works in non-parametric mode, while using Fusion tools works in parametric also. Official Autodesk answer would be nice.

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