How to do a SplitFeature on a SketchLine3D and a SurfaceBody in C#?

How to do a SplitFeature on a SketchLine3D and a SurfaceBody in C#?

Jo_Perturbable
Contributor Contributor
712 Views
4 Replies
Message 1 of 5

How to do a SplitFeature on a SketchLine3D and a SurfaceBody in C#?

Jo_Perturbable
Contributor
Contributor

Hi,

I want to split a BoundaryPatch with a SketchLine in C# in Inventor Professional 2021.1.2 Build 245.

I've tried with SplitFeatures.SplitBody:

  • SketchLine3D with a SurfaceBody
  • Create a Path from the SketchLine3D and then with a SurfaceBody

I've also tried with SplitFeatures.SplitFaces to no avail.

This works manually in the UI. But I don't get it to work in code. How do I create a Path object correctly?
See attached code and part.

Code in short also here:

 

var componentDefinition = sketch3D.Parent as ComponentDefinition;
var partComponentDefinition = sketch3D.Parent as PartComponentDefinition;
var splitFeatures = partComponentDefinition.Features.SplitFeatures;
SketchLine3D line = sketch3D.SketchLines3D[5];
SurfaceBody surfBody = partComponentDefinition.WorkSurfaces[1].SurfaceBodies[1];

// Try directly with SketchLine3D
try
{
    splitFeatures.SplitBody(line, surfBody);
}
catch (Exception) { }

// Try creating a Path
try
{
    var path = partComponentDefinition.Features.CreatePath(line);
    splitFeatures.SplitBody(path, surfBody);
}
catch (Exception) { }

 

 
Many thanks in advance!

0 Likes
Accepted solutions (1)
713 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

did you ever solve this?

0 Likes
Message 3 of 5

Jo_Perturbable
Contributor
Contributor
Accepted solution

@Anonymous Yes. We use SplitFeatures.SplitFaces.

Some C#-like pseudocode:

Path path = PartFeatures.CreatePath(SketchLine3D);
var objColl = TransientObjects.CreateObjectCollection();
objColl.Add(SurfaceBody.Faces[1]);
var split = splitFeatures.SplitFaces(path, false, objColl);

 

Message 4 of 5

Anonymous
Not applicable

do happen to have any completed addins or ilogic code to share in regards to this?

I am about to embark on working on this and could potentially save days of research and work. 

0 Likes
Message 5 of 5

Jo_Perturbable
Contributor
Contributor

@Anonymous  No, sorry. I don't know iLogic and our full C# code is private.

You could use the SimpleAddIn and start from there. If you installed the DeveloperTools, it should be at C:\Users\Public\Documents\Autodesk\Inventor 2022\SDK\DeveloperTools\Samples\VCSharp.NET\AddIns\SimpleAddIn

I guess you already know where to look for the API anyway, but here is a link to the PartFeatures.

 

0 Likes