Patch Feature Enable Chaining Where is this in the API

Patch Feature Enable Chaining Where is this in the API

rusty.bird
Advocate Advocate
579 Views
4 Replies
Message 1 of 5

Patch Feature Enable Chaining Where is this in the API

rusty.bird
Advocate
Advocate

Hello I am trying to find "Enable Chaining" for the Patch Feature in the API and I cant seam to find it. Here it is in the UI.chaining.png

0 Likes
580 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

According to the createInput documentation, if you provide a single open curve, the API will automatically attempt to find connected curves to create a closed boundary. You can also build up the set of curves to define the boundary yourself. Some functions that might help with that are Component.createOpenProfile, BRepEdge.tangentiallyConnectedEdges, and Component.createBRepEdgeProfile.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 5

rusty.bird
Advocate
Advocate

Here is my sketch I am trying to patch attached.  I am using the intersectWithSketchPlane to make the curves. My end goal is to remove all the interior lines and keep the outmost lines.  My plan is to use the patch feature to make a patch over the area and then project that patch onto a new sketch. 

 

Using the UI I can Click the "Enable Chaining" which will make the patch area but when I do this in the API it doesn't do this automatically.  From what @BrianEkins was saying I might have to gather more edges to help do this.  I think tangentially Connected Edges might work the best for this.  Here is my code below that gets the profiles and tangentially connected edges.  Although I can't seam to get it working yet.

Ptr<Profiles> sketchProfiles = skt1->profiles();
	Ptr<BRepEdges> bEdges1 = skt1->sketchCurves();

	Ptr<ObjectCollection> collection1 = ObjectCollection::create();
	
	for (int i = 0; i < sketchProfiles->count(); i++) {
		Ptr<Profile> profile = sketchProfiles->item(i);
		collection1->add(profile);
	}

	for (int i = 0; i < bEdges1->count(); i++) {
		Ptr<BRepEdge> bEdge1 = bEdges1->item(i);
		collection1->add(bEdge1->tangentiallyConnectedEdges());
	}

	// Create the patch feature
	Ptr<Features> features = rootComp->features();
	if (!features)
		return false;
	Ptr<PatchFeatures> patches = features->patchFeatures();
	if (!patches)
		return false;
	Ptr<PatchFeatureInput> patchInput = patches->createInput(collection1, adsk::fusion::FeatureOperations::NewBodyFeatureOperation);
	if (!patchInput)
		return false;
	Ptr<PatchFeature> tmp_patch = patches->add(patchInput);
	if (!tmp_patch)
		return false;

    

 

      

0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor

I don't think finding tangent connected edges will work in this case because you've got some corners that are not tangentially connected. The sketch is also quite messy with a lot of overlapping geometry. When I run the command and select the outline, the preview will change depending on the mouse's location, even when moving over the same line. When I looked closer, it wasn't a single line but four sketch lines on top of each other. This makes the "correct" result ambiguous because there are many possible "correct" answers. I was able to get a similar result from the API that I was getting with the command using the simple test program below, but it's difficult to say this is the desired result because there is more than one "correct" result.

 

def SimplePatchTest():
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        des = adsk.fusion.Design.cast(_app.activeProduct)
        root = des.rootComponent

        skCurve = _ui.selectEntity('Select a sketch curve.', 'SketchCurves').entity

        patchInput = root.features.patchFeatures.createInput(skCurve, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        patch = root.features.patchFeatures.add(patchInput)
    except:
        ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Here's the result I got with the script above when selecting the highlighted line.

PatchResult.png

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 5

rusty.bird
Advocate
Advocate

I had the same result when I used select entity when I was playing with it but I was trying to not use that.  I was planning to not have any user interaction. I noticed in your picture that it missed a spot on the left end as well.  Like you said its not liking the overlapping curves.

 

Some Curves/Lines are overlapping which makes this harder.  I did that by purpose to get the full profile(rotation) of the part.  Some of those lines/curves that are overlapping are needed since I am trying to find the outer-most curves/lines of the entire sketch to create an outer profile.  All the lines/Curves on the sketch are on the same plane though. All the other lines/curves are not needed (anything inside the profile) can be removed. This example is probably my worst most complex scenario that doesn't happen alot so maybe I have to edit this one manually.

 

I was trying to use the Patch Feature to overcome this but am realizing that it doesn't like overlapping geometry at all.    

0 Likes