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: 

Sweep and move

3 REPLIES 3
Reply
Message 1 of 4
niklaskp
223 Views, 3 Replies

Sweep and move

I had a problem with a bug in sweepfeature, that it didn't extrude my profiles. https://forums.autodesk.com/t5/api-and-scripts/sweep-with-guide-distance-always-0-problem/m-p/665239...

 

I decided to try and tackle the problem and do it in another way instead of waiting for a bug-fix, but encountered some other difficulties.

 

The sweep seems to work properly when the profile is not rotated before the sweep,  so I thought I could just do a sweep and rotate the body afterwards. Now I'm taking the body with

Ptr<BRepBodies> bodies = sweepfeature->bodies();

Ptr<BRepBody> body = sweepfeature->item(0);

 

But for some reason when I now do a move feature, with the example you have online, this just does not work? The error testing does not indicate anything so seems like it finds the body but does not move it. Is there something more I should do to make the body movable?

3 REPLIES 3
Message 2 of 4
niklaskp
in reply to: niklaskp

And sorry about the double post. Please remove the other one. The site told me that the first one failed. I also notified about this though the report service. 

Message 3 of 4
ekinsb
in reply to: niklaskp

I don't know if the code in your post is actual code from your project or you just typed it in for the post but in the second line you're trying to call the item method of the sweepFeature variable instead of the bodies variable that you set in the previous line.

 

If it's something else, can you supply a model and code that demonstrates the issue?


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 4 of 4
niklaskp
in reply to: ekinsb

Just typed it in, I also tried looping through the bodies without luck. I did something like this but with error handling:

 

 

        /*  createSweepWithGuide returns a working Ptr<SweepFeature> */

        Ptr<SweepFeature> sweepWithGuide = createSweepWithGuide(profsToExtrude->item(0), spline2, spline1);

        Ptr<BRepBodies> bodies = sweepWithGuide->bodies();

        Ptr<BRepBody> body = bodies->item(0);

        Ptr<ObjectCollection> entities1 = ObjectCollection::create();

        entities1->add(body);

        Ptr<Vector3D> vector = Vector3D::create(100.0, 50.0, 0.0);

        Ptr<Matrix3D> transform = Matrix3D::create();

        transform->translation(vector);

 

 

        Ptr<Product> product = app->activeProduct();

        Ptr<Design> design = product;

        Ptr<Component> rootComp = design->rootComponent();

        Ptr<Features> features = rootComp->features();

        Ptr<MoveFeatures> moveFeats = features->moveFeatures();

        Ptr<MoveFeatureInput> moveFeatureInput = moveFeats->createInput(entities1, transform);

        Ptr<MoveFeature> moveFeature = moveFeats->add(moveFeatureInput);

 

 

edit: Actually, i'm getting an InternalValidationError : XI::Utils::getObjectPath(pBody, objPath, nullptr, compPath); now with this code. Seems like I get the body since I can print its area. Also doing a circularPath directly instead works, but I am using the "sweepWithGuide" as an input for that. 

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