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: 

How do I create a "null" BRepBody to use in CombineFeatures->createInput?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
julian.tilbury
335 Views, 3 Replies

How do I create a "null" BRepBody to use in CombineFeatures->createInput?

 

I would like use the C++ API to create a new component by joining existing components.

I think I need:-

 

Ptr<CombineFeatures> CF = /* get from component */

Ptr<CombineFeaturesInput> CFI = CF->createInput ( TargetBody, ToolBodies );

CFI->isNewComponent(true);

CFI->operation(JoinFeatureOperation);

CF->add(CFI);

 

where ToolBodies is a Ptr<ObjectCollection> of my existing components,

and TargetBody is a Ptr<BRepBody>, which, as I'm creating a new

component, is presumably a blank/null/new object. How do I create it?

 

 

3 REPLIES 3
Message 2 of 4

I used the first component of the ToolBodies as the TargetBody and the code

appears to execute but doesn't create a new combined body.

 

Can anyone give me an API example of joining two components to form

a new component please?


 

Message 3 of 4
BrianEkins
in reply to: julian.tilbury

Below is the run function from a C++ script that demonstrates this.

 

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

	ui = app->userInterface();
	if (!ui)
		return false;

	Ptr<Design> des = app->activeProduct();
	Ptr<Component> root = des->rootComponent();

	Ptr<Selection> select = ui->selectEntity("Select the target body.", "Bodies");
	Ptr<BRepBody> targetBody = select->entity();
	adsk::doEvents();

	select = ui->selectEntity("Select the tool body.", "Bodies");
	Ptr<BRepBody> toolBody = select->entity();
	Ptr<ObjectCollection> tools = adsk::core::ObjectCollection::create();
	tools->add(toolBody);

	Ptr<CombineFeatures> combines = root->features()->combineFeatures();
	Ptr<CombineFeatureInput> combineInput = combines->createInput(targetBody, tools);
	combineInput->isKeepToolBodies(true);
	combineInput->isNewComponent(true);
	combineInput->operation(adsk::fusion::FeatureOperations::CutFeatureOperation);
	Ptr<CombineFeature> combine = combines->add(combineInput);
}
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 4
julian.tilbury
in reply to: BrianEkins

Thank you Brian.

 

I was using an ObjectCollection of Components, not an ObjectCollection of

BRepBodies for the ToolBodies.

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